opinf.utils#

Miscellaneous utility functions.

Timing Code#

Model reduction is all about speeding up computational tasks. The following class defines a context manager for timing blocks of code and logging errors.

TimedBlock

Context manager for timing a block of code and reporting the timing.

Load/Save HDF5 Utilities#

Many opinf classes have save() methods that export the object to an HDF5 file and a load() class method for importing an object from an HDF5 file. The following functions facilitate that data transfer.

hdf5_loadhandle

Get a handle to an open HDF5 file to read from.

hdf5_savehandle

Get a handle to an open HDF5 file to write to.

Helper Routines#

The following functions perform miscellaneous tasks within the rest of the code base.

requires

Wrapper for methods that require an attribute to be initialized.

requires2

Wrapper for methods that require an attribute to be initialized.

str2repr

Canonical string representation for objects with a __str__() method.

Regularization Selection#

These helper routines support automatic regularization selection.

gridsearch

Minimize a function by first checking a collection of candidates, then following up with a derivative-free optimization routine.

DiscreteRegTest

Test case for regularization selection with fully discrete models.

ContinuousRegTest

Test case for regularization selection with time-continuous models.

Documentation#

The following function initializes the Matplotlib defaults used in the documentation notebooks.

mpl_config

Set matplotlib and pandas configuration defaults for the documentation notebooks.