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 anumpy.ndarray
withMetadata
.Do not instantiate directly. Create a new
Dataset
usingcreate_dataset()
.- Parameters:
read_only (
bool
) – Whether theDataset
is to be accessed in read-only mode.shape – See
numpy.ndarray
dtype – See
numpy.ndarray
buffer – See
numpy.ndarray
offset – See
numpy.ndarray
strides – See
numpy.ndarray
order – See
numpy.ndarray
data – If not
None
then it must be either anumpy.ndarray
or an array-like object which will be passed tonumpy.asarray()
, as well as dtype and order, to be used as the underlying data.**metadata – All other key-value pairs will be used as
Metadata
for thisDataset
.
- 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 thenumpy.ndarray
attribute from theDataset
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:
- property read_only
Whether this
Dataset
is in read-only mode.This is equivalent to setting the
WRITEABLE
property innumpy.ndarray.setflags()
.- Type: