msl.io.dataset module

A Dataset is essentially a numpy.ndarray with Metadata.

class msl.io.dataset.Dataset(name, parent, read_only, shape=(0, ), dtype=<class 'float'>, buffer=None, offset=0, strides=None, order=None, data=None, **metadata)[source]

Bases: Vertex

A Dataset is essentially a numpy.ndarray with Metadata.

Do not instantiate directly. Create a new Dataset using create_dataset().

Parameters:
copy(read_only=None)[source]

Create a copy of this Dataset.

Parameters:

read_only (bool, optional) – Whether the copy should be created in read-only mode. If None then creates a copy using the mode for the Dataset that is being copied.

Returns:

Dataset – A copy of this Dataset.

property data

The data of the Dataset.

Note

You do not have to call this attribute to get access to the numpy.ndarray. You can directly call the numpy.ndarray attribute from the Dataset object.

For example,

>>> dset
<Dataset '/my_data' shape=(4, 3) dtype='<f8' (0 metadata)>
>>> dset.data
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7.,  8.],
       [ 9., 10., 11.]])
>>> dset.size
12
>>> dset.tolist()
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0], [9.0, 10.0, 11.0]]
>>> dset.mean(axis=0)
array([4.5, 5.5, 6.5])
>>> dset[::2]
array([[0., 1., 2.],
       [6., 7., 8.]])
Type:

numpy.ndarray

property read_only

Whether this Dataset is in read-only mode.

This is equivalent to setting the WRITEABLE property in numpy.ndarray.setflags().

Type:

bool