modelrunner.storage.group module
- class StorageGroup(storage, loc=None)[source]
Bases:
objectRefers to a group within a storage.
- Parameters:
storage (
StorageBaseorStorageGroup) – The storage where the group is defined. If this is aStorageGroupitself, loc is interpreted relative to that grouploc (str or list of str) – Denotes the location (path) of the group within the storage
- create_dynamic_array(loc, *, arr=None, shape=None, dtype=<class 'float'>, record_array=False, attrs=None, cls=None)[source]
Creates a dynamic array of flexible size.
- Parameters:
loc (str or list of str) – The location where the dynamic array is created
shape (tuple of int) – The shape of the individual arrays. A singular axis is prepended to the shape, which can then be extended subsequently.
dtype (DTypeLike) – The data type of the array to be written
record_array (bool) – Flag indicating whether the array is of type
recarrayattrs (dict, optional) – Attributes stored with the array
cls (type) – A class associated with this array
arr (ndarray | None)
- get_class(loc=None)[source]
Get the class associated with a particular location.
Class information can be written using the cls attribute of write_array, write_object, and similar functions.
- Parameters:
loc (str or list of str) – The location where the class information is read from
- Return type:
type | None
Retruns: the class associated with the lcoation
- open_group(loc)[source]
Open an existing group at a particular location.
- property parent: StorageGroup
Parent group.
- Raises:
RuntimeError – If current group is root group
- Type:
- read_array(loc, *, out=None, index=None)[source]
Read an array from a particular location.
- Parameters:
- Returns:
An array containing the data. Identical to out if specified.
- Return type:
- read_item(loc, *, use_class=True)[source]
Read an item from a particular location.
- Parameters:
- Returns:
The reconstructed python object
- Return type:
- write_item(loc, item, *, attrs=None, use_class=True)[source]
Write an item to a particular location.
- Parameters:
loc (sequence of str) – The location where the item is written to
item (Any) – The item that will be written
attrs (dict, optional) – Attributes stored with the object
use_class (bool) – If True, looks for class information in the attributes and evokes a potentially registered hook to instantiate the associated object. If False, only the current data or object is returned.
- Return type:
None