pypesto.store
Storage
Saving and loading traces and results objects.
- class pypesto.store.OptimizationResultHDF5Reader[source]
Bases:
objectReader of the HDF5 result files written by OptimizationResultHDF5Writer.
- storage_filename
HDF5 result file name
- lazy
Whether to use lazy loading for optimizer results
- with_history
Whether to load the optimization history
- __init__(storage_filename, lazy=False, with_history=True)[source]
Initialize reader.
- Parameters:
- class pypesto.store.OptimizationResultHDF5Writer[source]
Bases:
objectWriter of the HDF5 result files.
- storage_filename
HDF5 result file name
- write(result, overwrite=False)[source]
Write HDF5 result file from pyPESTO result object.
- Parameters:
result (Result to be saved.)
overwrite (Boolean, whether already existing results should be) – overwritten. This applies to the whole list of results, not only to individual results. See
write_optimizer_result()for incrementally writing a sequence of OptimizerResult.
- class pypesto.store.ProblemHDF5Reader[source]
Bases:
objectReader of the HDF5 problem files written by ProblemHDF5Writer.
- storage_filename
HDF5 problem file name
- read(objective=None)[source]
Read HDF5 problem file and return pyPESTO problem object.
- Parameters:
objective (
ObjectiveBase) – Objective function which is currently not saved to storage.- Return type:
- Returns:
problem – A problem instance with all attributes read in.
- class pypesto.store.ProblemHDF5Writer[source]
Bases:
objectWriter of the HDF5 problem files.
- storage_filename
HDF5 result file name
- class pypesto.store.ProfileResultHDF5Reader[source]
Bases:
objectReader of the HDF5 result files written by OptimizationResultHDF5Writer.
- storage_filename
HDF5 result file name
- class pypesto.store.ProfileResultHDF5Writer[source]
Bases:
objectWriter of the HDF5 result files.
- storage_filename
HDF5 result file name
- class pypesto.store.SamplingResultHDF5Reader[source]
Bases:
objectReader of the HDF5 result files written by SamplingResultHDF5Writer.
- storage_filename
HDF5 result file name
- class pypesto.store.SamplingResultHDF5Writer[source]
Bases:
objectWriter of the HDF5 sampling files.
- storage_filename
HDF5 result file name
- pypesto.store.autosave(filename, result, store_type, overwrite=False)[source]
Save the result of optimization, profiling or sampling automatically.
- Parameters:
filename (
Path|str|Callable|None) – Either the filename to save to or “Auto”, in which case it will automatically generate a file named year_month_day_{type}_result.hdf5. A method can also be provided. All input to the autosave method will be passed to the filename method. The output should be the filename (str).result (
Result) – The result to be saved.store_type (
str) – Either optimize, sample or profile. Depending on the method the function is called in.overwrite (
bool) – Whether to overwrite the currently existing results.
- pypesto.store.read_result(filename, problem=True, optimize=False, profile=False, sample=False, lazy=False, with_history=True)[source]
Save the whole pypesto.Result object in an HDF5 file.
By default, loads everything. If any of optimize, profile, sample is explicitly set to true, loads only this one.
- Parameters:
problem (
bool) – Read the problem.optimize (
bool) – Read the optimize result.profile (
bool) – Read the profile result.sample (
bool) – Read the sample result.lazy (
bool) – Whether to use lazy loading for optimizer resultswith_history (
bool) – Whether to load the optimization history. When lazy=False, setting with_history=False prevents loading history objects, which can save memory and time. When lazy=True, this parameter has no practical effect since history is only loaded when explicitly accessed anyway.
- Return type:
- Returns:
result – Result object containing the results stored in HDF5 file.
- pypesto.store.write_array(f, path, values)[source]
Write array to hdf5.
- Parameters:
f (
Group) – h5py.Group where dataset should be createdpath (
str) – path of the dataset to createvalues (
Collection) – array to write
- Return type:
- pypesto.store.write_result(result, filename, overwrite=False, problem=True, optimize=False, profile=False, sample=False)[source]
Save whole pypesto.Result to hdf5 file.
Boolean indicators allow specifying what to save.
- Parameters:
result (
Result) – Thepypesto.Resultobject to be saved.overwrite (
bool) – Boolean, whether already existing results should be overwritten.problem (
bool) – Read the problem.optimize (
bool) – Read the optimize result.profile (
bool) – Read the profile result.sample (
bool) – Read the sample result.