pypesto.store

Storage

Saving and loading traces and results objects.

class pypesto.store.OptimizationResultHDF5Reader[source]

Bases: object

Reader of the HDF5 result files written by OptimizationResultHDF5Writer.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize reader.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

read()[source]

Read HDF5 result file and return pyPESTO result object.

Return type:

Result

class pypesto.store.OptimizationResultHDF5Writer[source]

Bases: object

Writer of the HDF5 result files.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize Writer.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

write(result, overwrite=False)[source]

Write HDF5 result file from pyPESTO result object.

Parameters:

result (Result) –

class pypesto.store.ProblemHDF5Reader[source]

Bases: object

Reader of the HDF5 problem files written by ProblemHDF5Writer.

storage_filename

HDF5 problem file name

__init__(storage_filename)[source]

Initialize reader.

Parameters:

storage_filename (Union[str, Path]) – 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:

Problem

Returns:

problem – A problem instance with all attributes read in.

class pypesto.store.ProblemHDF5Writer[source]

Bases: object

Writer of the HDF5 problem files.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize writer.

Parameters:

storage_filename (Union[str, Path]) – HDF5 problem file name

write(problem, overwrite=False)[source]

Write HDF5 problem file from pyPESTO problem object.

Parameters:

overwrite (bool) –

class pypesto.store.ProfileResultHDF5Reader[source]

Bases: object

Reader of the HDF5 result files written by OptimizationResultHDF5Writer.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize reader.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

read()[source]

Read HDF5 result file and return pyPESTO result object.

Return type:

Result

class pypesto.store.ProfileResultHDF5Writer[source]

Bases: object

Writer of the HDF5 result files.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize Writer.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

write(result, overwrite=False)[source]

Write HDF5 result file from pyPESTO result object.

Parameters:
class pypesto.store.SamplingResultHDF5Reader[source]

Bases: object

Reader of the HDF5 result files written by SamplingResultHDF5Writer.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize reader.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

read()[source]

Read HDF5 result file and return pyPESTO result object.

Return type:

Result

class pypesto.store.SamplingResultHDF5Writer[source]

Bases: object

Writer of the HDF5 sampling files.

storage_filename

HDF5 result file name

__init__(storage_filename)[source]

Initialize Writer.

Parameters:

storage_filename (Union[str, Path]) – HDF5 result file name

write(result, overwrite=False)[source]

Write HDF5 sampling file from pyPESTO result object.

Parameters:
pypesto.store.autosave(filename, result, store_type, overwrite=False)[source]

Save the result of optimization, profiling or sampling automatically.

Parameters:
  • filename (Union[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.load_objective_config(filename)[source]

Load the objective information stored in f.

Parameters:

filename (Union[str, Path]) – 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.read_result(filename, problem=True, optimize=False, profile=False, sample=False)[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:
  • filename (Union[Path, str]) – The HDF5 filename.

  • problem (bool) – Read the problem.

  • optimize (bool) – Read the optimize result.

  • profile (bool) – Read the profile result.

  • sample (bool) – Read the sample result.

Return type:

Result

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 created

  • path (str) – path of the dataset to create

  • values (Collection) – array to write

Return type:

None

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) – The pypesto.Result object to be saved.

  • filename (Union[str, Path]) – The HDF5 filename.

  • 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.