modelrunner.storage.group module
- class StorageGroup(storage, loc=None)[source]
Bases:
object
refers to a group within a storage
- Parameters:
storage (
StorageBase
orStorageGroup
) – The storage where the group is defined. If this is aStorageGroup
itself, 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
recarray
attrs (dict, optional) – Attributes stored with the array
cls (type) – A class associated with this array
arr (np.ndarray | None) –
- extend_dynamic_array(loc, data)[source]
extend a dynamic array previously created
- Parameters:
loc (str or list of str) – The location where the dynamic array is located
arr (array) – The array that will be appended to the dynamic array
data (_SupportsArray[dtype] | _NestedSequence[_SupportsArray[dtype]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) –
- 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