Storage¶
Saving and loading traces and results objects.
-
class
pypesto.store.
OptimizationResultHDF5Reader
(storage_filename: str)[source]¶ Bases:
object
Reader of the HDF5 result files written by class OptimizationResultHDF5Writer.
-
storage_filename
¶ HDF5 result file name
-
read
() → pypesto.result.Result[source]¶ Read HDF5 result file and return pyPESTO result object.
-
-
class
pypesto.store.
OptimizationResultHDF5Writer
(storage_filename: str)[source]¶ Bases:
object
Writer of the HDF5 result files.
-
storage_filename
¶ HDF5 result file name
-
write
(result: pypesto.result.Result, overwrite=False)[source]¶ Write HDF5 result file from pyPESTO result object.
-
-
class
pypesto.store.
ProblemHDF5Reader
(storage_filename: str)[source]¶ Bases:
object
Reader of the HDF5 problem files written by class ProblemHDF5Writer.
-
storage_filename
¶ HDF5 problem file name
-
read
(objective: Optional[pypesto.objective.base.ObjectiveBase] = None) → pypesto.problem.Problem[source]¶ Read HDF5 problem file and return pyPESTO problem object.
- Parameters
objective – Objective function which is currently not saved to storage.
- Returns
A problem instance with all attributes read in.
- Return type
problem
-
-
class
pypesto.store.
ProblemHDF5Writer
(storage_filename: str)[source]¶ Bases:
object
Writer of the HDF5 problem files.
-
storage_filename
¶ HDF5 result file name
-
-
class
pypesto.store.
ProfileResultHDF5Reader
(storage_filename: str)[source]¶ Bases:
object
Reader of the HDF5 result files written by class OptimizationResultHDF5Writer.
-
storage_filename
¶ HDF5 result file name
-
read
() → pypesto.result.Result[source]¶ Read HDF5 result file and return pyPESTO result object.
-
-
class
pypesto.store.
ProfileResultHDF5Writer
(storage_filename: str)[source]¶ Bases:
object
Writer of the HDF5 result files.
-
storage_filename
¶ HDF5 result file name
-
write
(result: pypesto.result.Result, overwrite: bool = False)[source]¶ Write HDF5 result file from pyPESTO result object.
-
-
class
pypesto.store.
SamplingResultHDF5Reader
(storage_filename: str)[source]¶ Bases:
object
Reader of the HDF5 result files written by class SamplingResultHDF5Writer.
-
storage_filename
¶ HDF5 result file name
-
read
() → pypesto.result.Result[source]¶ Read HDF5 result file and return pyPESTO result object.
-
-
class
pypesto.store.
SamplingResultHDF5Writer
(storage_filename: str)[source]¶ Bases:
object
Writer of the HDF5 sampling files.
-
storage_filename
¶ HDF5 result file name
-
write
(result: pypesto.result.Result, overwrite: bool = False)[source]¶ Write HDF5 sampling file from pyPESTO result object.
-
-
pypesto.store.
get_or_create_group
(f: Union[h5py._hl.files.File, h5py._hl.group.Group], group_path: str) → h5py._hl.group.Group[source]¶ Helper function that returns a group object for the group with group_path relative to f. Creates it if it doesn’t exist.
-
pypesto.store.
f
¶ should be checked
- Type
file or group where existence of a group with the path group_path
-
pypesto.store.
group_path
¶ - Type
the path or simply the name of the group that should exist in f
- Returns
hdf5 group object with specified path.
- Return type
grp
-
-
pypesto.store.
load_objective_config
(filename: str)[source]¶ Load the objective information stored in f
- Parameters
filename – The name of the file in which the information are stored.
Returns – A dictionary of the information, stored instead of the actual objective in problem.objective.
-
pypesto.store.
optimization_result_from_history
(filename: str)[source]¶ Converts a saved hdf5 History to an optimization result. Used for interrupted optimization runs.
- Parameters
filename – The name of the file in which the information are stored.
Returns – A result object in which the optimization result is constructed from history. But missing “Time, Message and Exitflag” keys.
-
pypesto.store.
read_result
(filename: str, problem: bool = True, optimize: bool = False, profile: bool = False, sample: bool = False) → pypesto.result.Result[source]¶ This is a function that saves the whole pypesto.Result object in an HDF5 file. With booleans one can choose more detailed what to save.
- Parameters
filename – The HDF5 filename.
problem – Read the problem.
optimize – Read the optimize result.
profile – Read the profile result.
sample – Read the sample result.
- Returns
Result object containing the results stored in HDF5 file.
- Return type
result
-
pypesto.store.
write_array
(f: h5py._hl.group.Group, path: str, values: Collection) → None[source]¶ Write array to hdf5
- Parameters
f – h5py.Group where dataset should be created
path – path of the dataset to create
values – array to write
-
pypesto.store.
write_result
(result: pypesto.result.Result, filename: str, overwrite: bool = False, problem: bool = True, optimize: bool = True, profile: bool = True, sample: bool = True)[source]¶ Save whole pypesto.Result to hdf5 file.
Boolean indicators allow specifying what to save.
- Parameters
result – The
pypesto.Result
object to be saved.filename – The HDF5 filename.
overwrite – Boolean, whether already existing results should be overwritten.
problem – Read the problem.
optimize – Read the optimize result.
profile – Read the profile result.
sample – Read the sample result.