class documentation
Defines some routines for interacting with a folder that has ultranest runs in it. Allows association of metadata with ultranest runs and some simple plotting routines.
Method | __init__ |
Initialises a result set |
Method | __repr__ |
Undocumented |
Method | clear |
Remove all metadata from this instance. Will not update the saved metadata until self.save_metadata() is called. |
Method | get |
Gets all parameters (and optionally metadata) for each run in the resultset |
Method | get |
Pulls the results of an ultranest run from a "result_set_directory/run[INT]" path. |
Method | get |
Ultranest has "result_set_directory/run[INT]" to hold data for each run |
Method | get |
Gets the indices of all runs in a result set |
Method | load |
Loads metadata for the result set (saved as a json file) |
Method | plot |
Variable to display along x-axis. If None , uses run index. |
Method | plot |
Plots all results in the resultset |
Method | save |
Saves metadata for the result set as a json file. |
Class Variable | metadata |
Undocumented |
Instance Variable | directory |
Undocumented |
Instance Variable | metadata |
Undocumented |
Instance Variable | metadata |
Undocumented |
Property | plot |
Directory (within self.directory ) where plots are saved. Defaults to `self.directory / "resultset_plots" |
Initialises a result set
- # ARGUMENTS #
- result_set_directory : Path | str
- The directory where ultranest should put it's run_N folders.
Remove all metadata from this instance. Will not update the saved metadata until self.save_metadata()
is called.
def get_params_vs_run_index(self, metadata_keys_to_include:
list[ str]
= [], sort_by: str | None
= None) -> tuple[ list[ int, ...], dict[ str, np.array], dict[ str, np.array]]
:
¶
Gets all parameters (and optionally metadata) for each run in the resultset
- # ARGUMENTS #
- metadata_keys_to_include : list[str]
- Will include these metadata keys in the results
- sort_by : None | str = None
- Metadata or parameter name to sort by. If
None
, sort by run index
- # RETURNS #
- run_indices : list[int,...]
- A list of all run indices found
- metadata_values : dict[str, np.ndarray]
- A dictionary of metadata values for each run
- param_values : dict[str, np.ndarray]
- A dictionary of parameter values for each run
- x_var : str | None
- Variable to display along x-axis. If
None
, uses run index. - show : bool = False
- If
True
will display plots - save : bool = True
- If
True
will save plots toself.plot_directory
- kwargs : dict[str,Any]
- Forwarded to
self.get_params_vs_run_index(...)
def plot_results(self, result_providers:
list[ Callable[ tuple[ float, ...], np.ndarray]]
, ref_data: np.ndarray
, show: bool
= False, save: bool
= True):
¶
Plots all results in the resultset
- # ARGUMENTS #
- result_providers : list[Callable[tuple[float,...], np.ndarray]]
- A list of callables that accept an ordered tuple of results, much like objective functions for the scipy library. Should be ordered corresponding to the index of a run (i.e., 0th entry gives results for lowest run number)
- ref_data : np.ndarray
- An array of data, it should have an entry for each run index (i.e., for run folder "run_128", we use ref_data[128])
- show : bool = False
- If
True
will show the plots as they are made - save : bool = True
- If
True
will save the results toself.plot_directory
Saves metadata for the result set as a json file.
- # ARGUMENTS #
- make_parent_dirs : bool
- If
True
(default) will create parent directory (the result set directory) when saving the metadata