murefi.datastructures

class murefi.datastructures.Dataset

Bases: OrderedDict

A dataset contains one or more Replicates.

Methods

clear()

copy()

fromkeys(/, iterable[, value])

Create a new ordered dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

load(filepath)

Load a Dataset from a HDF5 file.

make_template(tmin, tmax, independent_keys, rids)

Create a dense template Dataset for plotting-predictions.

make_template_like(dataset, independent_keys, *)

Create a dense template Dataset that has the same start and end times as another Dataset.

move_to_end(/, key[, last])

Move an existing element to the end (or beginning if last is false).

pop(/, key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/[, last])

Remove and return a (key, value) pair from the dictionary.

save(filepath)

Saves the Dataset to a HDF5 file.

setdefault(/, key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

static load(filepath: str)

Load a Dataset from a HDF5 file.

Args:

filepath (str): path to the file containing the data

Returns:

dataset (Dataset)

static make_template(tmin: float, tmax: float, independent_keys: list, rids: list, N: int = 100)

Create a dense template Dataset for plotting-predictions.

Args:

tmin (float): first timepoint tmax (float): last timepoint independent_keys (list): list of independent variable keys to include in the template rids (list): replicates ids that shall be present in the Dataset N (int): total number of timepoints (default: 100)

Returns:

dataset (Dataset): dataset object containing Replicates with dense timeseries of random y data

static make_template_like(dataset, independent_keys: Iterable[str], *, N: int = 200, tmin: float | None = None, tmax: float | None = None)

Create a dense template Dataset that has the same start and end times as another Dataset.

Args:

dataset (murefi.Dataset): a template dataset (typically with real observations) independent_keys (list): list of independent variable keys to include in the template N (int): total number of timepoints (default: 200) tmin (float, optional): override for the start time (when tmin=None, the first timepoint of the template replicate is used) tmax (float): override for the last timepoint

Returns:

dataset (Dataset): dataset object containing Replicates with dense timeseries of random y data

save(filepath: str)

Saves the Dataset to a HDF5 file.

Can be loaded with murefi.load_dataset.

Args:

filepath (str): file path or name to save

exception murefi.datastructures.DtypeError(message, actual=None, expected=None)

Bases: TypeError

Error that the dtype of a variable is incorrect.

class murefi.datastructures.Replicate(rid: str = None)

Bases: OrderedDict

A replicate contains one or more timeseries.

Attributes:
t_any

Array of time values at which any variable was observed.

t_max

The value of the last observation timepoint.

Methods

clear()

copy()

fromkeys(/, iterable[, value])

Create a new ordered dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

get_observation_booleans(keys_y)

Gets the Boolean masks for observations of each y in [keys_y], relative to [t_any] and ts.x

get_observation_indices(keys_y)

Gets the index masks for observations of each y in [keys_y], relative to [t_any] and ts.x

items()

keys()

make_template(tmin, tmax, independent_keys)

Create a dense template Replicate for plotting-predictions.

move_to_end(/, key[, last])

Move an existing element to the end (or beginning if last is false).

pop(/, key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/[, last])

Remove and return a (key, value) pair from the dictionary.

setdefault(/, key[, default])

Insert key with a value of default if key is not in the dictionary.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

get_observation_booleans(keys_y: list) dict

Gets the Boolean masks for observations of each y in [keys_y], relative to [t_any] and ts.x

Args:

keys_y (list): list of the timeseries keys for which indices are desired t_any (array): array of timepoints that the indices shall be relative to

Returns:

dict: maps each ykey in keys_y to t_bmask (boolean mask with same size as t_any)

get_observation_indices(keys_y: list) dict

Gets the index masks for observations of each y in [keys_y], relative to [t_any] and ts.x

Args:

keys_y (list): list of the timeseries keys for which indices are desired t_any (array): array of timepoints that the indices shall be relative to

Returns:

dict: maps each ykey in keys_y to x_imask (array of indices in t_any)

static make_template(tmin: float, tmax: float, independent_keys: list, rid: str = None, N: int = 100)

Create a dense template Replicate for plotting-predictions.

Args:

tmin (float): first timepoint tmax (float): last timepoint independent_keys (list): list of independent variable keys to include in the template rid (str): optional replicate id N (int): total number of timepoints (default: 100)

Returns:

replicate (Replicate): replicate object containing dense timeseries with random y data

property t_any: ndarray | None

Array of time values at which any variable was observed.

property t_max: float

The value of the last observation timepoint.

exception murefi.datastructures.ShapeError(message, actual=None, expected=None)

Bases: Exception

Error that the shape of a variable is incorrect.

class murefi.datastructures.Timeseries(t, y, *, independent_key: str, dependent_key: str)

Bases: Sized

A timeseries represents observations of one transient variable at certain time points.

Attributes:
is_distribution

Indicates if the observations are available as a distribution or not.

property is_distribution: bool

Indicates if the observations are available as a distribution or not.

murefi.datastructures.load_dataset(filepath: str) Dataset

Load a Dataset from a HDF5 file.

Args:

filepath (str): path to the file containing the data

Returns:

dataset (Dataset)

murefi.datastructures.save_dataset(dataset: Dataset, filepath: str)

Saves a Dataset to a HDF5 file.

Can be loaded with murefi.load_dataset.

Args:

filepath (str): file path or name to save