Metadata#

Parameters#

class respace.Parameter(name: str, default: ~collections.abc.Hashable, values: list[collections.abc.Hashable] = <factory>)[source]#

Represent a parameter with a mandatory default value.

Attributes:
namestr

Name of the parameter.

defaultHashable

Default value for this parameter.

valueslist[Hashable]

List of possible values for the parameter. Will contain the default in first position even if it was not supplied thus at initialization.

class respace.ParameterSet(parameters: Parameter | Iterable[Parameter] | Mapping[str, Hashable | Sequence[Hashable]])[source]#

Hold a list of Parameter instances and facilitate iteration over them.

The Parameter instances will be sorted according to their name attribute.

Parameters:
parametersParameter | list[Parameter] | ParamsArgType

Input respace.Parameter or list of Parameter instances, or dictionary whose keys are parameter names, and whose values are either a single value, which will be the default, or a sequence of values, the first of which will be the default.

Attributes:
parameterslist[Parameter]

Sorted list of Parameter instances.

to_dict() dict[str, list[Hashable]][source]#

Return a dictionary giving the possible values of all parameters.

Results#

class respace.ResultMetadata(name: str, compute_fun: ~collections.abc.Callable[[...], ~typing.Any], save_fun: ~collections.abc.Callable[[~typing.Any, ~pathlib.Path | str], ~typing.Any] = <function save_pickle>, load_fun: ~collections.abc.Callable[[~pathlib.Path | str], ~typing.Any] = <function load_pickle>, save_suffix: str = '.pickle', save_path_fmt: str | None = None)[source]#

Represent a result with a mandatory name and computing function.

Attributes:
namestr

Name of the result.

compute_funComputeFunType

Function to call to compute the result.

save_funSaveFunType, default respace.save_pickle()

Save object to pickle format at save_path.

save_suffixstr

Suffix of the file where the result would be saved. Should be set to match what’s expected by to save_fun. Default is “.pickle”

save_path_fmtstr, optional

Default format for the path where to save the result. Will be formatted with the str.format() method. If not set, respace.ResultSet’s default will be used. Good practice is to include the name of the result and the parameters’ with format fields for their values.

load_fun() Any[source]#

Load object from file in pickle format at save_path.

Parameters:
save_pathPath

Path where to load the object from.

Returns:
Any
save_fun(save_path: Path | str) None[source]#

Save object to pickle format at save_path.

Parameters:
objectAny

Oject to save.

save_pathPath

Path where to save object.

class respace.ResultSetMetadata(results: ResultMetadata | List[ResultMetadata] | Mapping[str, Callable[[...], Any] | ResultSetDict])[source]#

Represent a set of results with a mandatory name and computing function.

Parameters:
resultsResultSetMetadataInput

Input respace.Parameter or list of respace.Parameter instances, or dictionary whose keys are result names, and whose values are either a computing function, or a dictionary matching the keys of respace.ResultMetadata.

Attributes:
resultslist[ResultMetadata]

List of respace.ResultMetadata instances.

respace.save_pickle(object: Any, save_path: Path | str) None[source]#

Save object to pickle format at save_path.

Parameters:
objectAny

Oject to save.

save_pathPath

Path where to save object.