class documentation

class UltranestResultSet:

Constructor: UltranestResultSet(result_set_directory)

View In Hierarchy

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_metadata Remove all metadata from this instance. Will not update the saved metadata until self.save_metadata() is called.
Method get_params_vs_run_index Gets all parameters (and optionally metadata) for each run in the resultset
Method get_result_data_from_path Pulls the results of an ultranest run from a "result_set_directory/run[INT]" path.
Method get_result_data_path Ultranest has "result_set_directory/run[INT]" to hold data for each run
Method get_run_indices Gets the indices of all runs in a result set
Method load_metadata Loads metadata for the result set (saved as a json file)
Method plot_params_vs_run_index Variable to display along x-axis. If None, uses run index.
Method plot_results Plots all results in the resultset
Method save_metadata Saves metadata for the result set as a json file.
Class Variable metadata_file Undocumented
Instance Variable directory Undocumented
Instance Variable metadata Undocumented
Instance Variable metadata_path Undocumented
Property plot_directory Directory (within self.directory) where plots are saved. Defaults to `self.directory / "resultset_plots"
def __init__(self, result_set_directory: Path | str):

Initialises a result set

# ARGUMENTS #
result_set_directory : Path | str
The directory where ultranest should put it's run_N folders.
def __repr__(self):

Undocumented

def clear_metadata(self):

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
def get_result_data_from_path(self, result_data_path: Path):

Pulls the results of an ultranest run from a "result_set_directory/run[INT]" path.

def get_result_data_path(self, idx):

Ultranest has "result_set_directory/run[INT]" to hold data for each run

def get_run_indices(self) -> tuple[int, ...] | list[int, ...]:

Gets the indices of all runs in a result set

def load_metadata(self):

Loads metadata for the result set (saved as a json file)

def plot_params_vs_run_index(self, x_var=None, show=False, save=True, **kwargs):

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 to self.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 to self.plot_directory
def save_metadata(self, make_parent_dirs: bool = True):

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
metadata_file: str =

Undocumented

directory =

Undocumented

metadata =

Undocumented

metadata_path =

Undocumented

@property
plot_directory: Path =

Directory (within self.directory) where plots are saved. Defaults to `self.directory / "resultset_plots"