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

storage_filename

HDF5 result file name

__init__(storage_filename: str)[source]

Initialize reader.

Parameters

storage_filename (str) – HDF5 result file name

read()pypesto.result.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

__init__(storage_filename: str)[source]

Initialize Writer.

Parameters

storage_filename (str) – HDF5 result file name

write(result: pypesto.result.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 ProblemHDF5Writer.

storage_filename

HDF5 problem file name

__init__(storage_filename: str)[source]

Initialize reader.

Parameters

storage_filename (str) – 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

__init__(storage_filename: str)[source]

Initialize writer.

Parameters

storage_filename (str) – HDF5 problem file name

write(problem, overwrite: bool = False)[source]

Write HDF5 problem file from pyPESTO problem object.

class pypesto.store.ProfileResultHDF5Reader(storage_filename: str)[source]

Bases: object

Reader of the HDF5 result files written by OptimizationResultHDF5Writer.

storage_filename

HDF5 result file name

__init__(storage_filename: str)[source]

Initialize reader.

Parameters

storage_filename – HDF5 result file name

read()pypesto.result.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

__init__(storage_filename: str)[source]

Initialize Writer.

Parameters

storage_filename (str) – HDF5 result file name

write(result: pypesto.result.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 SamplingResultHDF5Writer.

storage_filename

HDF5 result file name

__init__(storage_filename: str)[source]

Initialize reader.

Parameters

storage_filename (str) – HDF5 result file name

read()pypesto.result.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

__init__(storage_filename: str)[source]

Initialize Writer.

Parameters

storage_filename (str) – HDF5 result file name

write(result: pypesto.result.result.Result, overwrite: bool = False)[source]

Write HDF5 sampling file from pyPESTO result object.

pypesto.store.autosave(filename: Optional[Union[str, Callable]], result: pypesto.result.result.Result, store_type: str, overwrite: bool = False)[source]

Save the result of optimization, profiling or sampling automatically.

Parameters
  • filename – 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 – The result to be saved.

  • store_type – Either optimize, sample or profile. Depending on the method the function is called in.

  • overwrite – Whether to overwrite the currently existing results.

pypesto.store.get_or_create_group(f: Union[h5py._hl.files.File, h5py._hl.group.Group], group_path: str)h5py._hl.group.Group[source]

Return/create a group object for the group with group_path relative to f.

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 relative to f.

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.read_result(filename: str, problem: bool = True, optimize: bool = False, profile: bool = False, sample: bool = False)pypesto.result.result.Result[source]

Save the whole pypesto.Result object in an HDF5 file.

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.Result, filename: str, overwrite: bool = False, problem: bool = True, optimize: bool = False, profile: bool = False, sample: bool = False)[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.