Validation Result

Container for figures and tables returned by tests.

ValidationResult

A class to handle validation results and plotting functionality.

This class stores validation data and provides methods to plot and save figures using the mocharts library.

Attributes

key : str
Name of the validation result

data : str, default=None
Data used in the validation

model : str, default=None
Model used in the validation

inputs : dict, default=None
Input arguments used in the validation

value : any, default=None
Detailed validation result values

table : pd.DataFrame or dict of pd.DataFrame, default=None
Table data associated with the validation

func : any, default=None
Function used in the validation

options : dict, default=None
Plotting options and configurations

__init__(key, data=None, model=None, inputs=None, value=None, table=None, func=None, options=None)

get_figure_names()

Show the list of figure names.

Returns

name_list: list of str
The list of figure names. Will return an empty list if there is only one figure, and it has no names.

plot_save(name: Union[str, int, float, Tuple]=None, figsize: Tuple[int]=(6, 6), file_name: str=None, format: str='png')

Generate and save figures based on validation options.

This method visualizes and saves figures created from the validation options using the mocharts library. The figures can be filtered by name, resized, and saved to a specified file path in the given format.

Parameters

name : str, int, float, tuple, default=None
The name(s) of the figure(s) to visualize and save. Can be a single name or a tuple/list of names. To retrieve valid figure names, call self.get_figure_names(). If None, all available figures are processed.

figsize : tuple, default=(6, 6)
The size (width, height) of the figure(s) to save, in inches.

file_name : str, default=None
The base file path and name to save the figure(s). If None, the figure will be saved in the ‘images/’ directory using the self.key as the filename prefix. If multiple figures are saved, this will serve as the prefix for each figure’s name.

format : str, default=‘png’
The format to save the figure(s), e.g., ‘png’, ‘jpg’, ‘svg’.

Raises

ValueError
If an invalid name is provided, or if an unsupported key type is encountered.

Notes

  • The function automatically creates an ‘images/’ folder if no file path is specified.
  • Figure names are constructed by combining the file_name (if provided) and the figure’s key.

plot(name: [str, int, float, Tuple]=None, figsize: Tuple[int]=(6, 6), display: bool=False, n_bars: int=None, popup: bool=True)

Show the figure results.

Parameters

name : str, int, float, tuple, default=None
The name of the figure to visualize. The available figure names can be fetched by func get_figure_names. If None, then all figures will be displayed.

figsize : tuple, default=(6, 6)
The size of displayed figure(s).

display : bool, default=False
Whether to display the figure.

n_bars: int, default=None
The number of displayed bars (from top).

popup: bool, default=True
Whether to support popup for each plot

Returns

fig : HTML object
The figure object in html format.