qml.data.Dataset¶
- class Dataset(bind=None, *, data_name=None, identifiers=None, **attrs)[source]¶
Bases:
pennylane.data.base.mapper.MapperMixin
,pennylane.data.base.dataset._DatasetTransform
Base class for Datasets.
Attributes
Returns a mapping of the
AttributeInfo
for each of this dataset's attributes.Returns all attributes of this Dataset.
Return the HDF5 group that contains this dataset.
Returns the data name (category) of this dataset.
A mapping of attribute names to their
Attribute
information.Returns this dataset's parameters.
Return metadata associated with this dataset.
Type identifier for this dataset.
- attr_info¶
Returns a mapping of the
AttributeInfo
for each of this dataset’s attributes.
- attrs¶
Returns all attributes of this Dataset.
- bind¶
Return the HDF5 group that contains this dataset.
- data_name¶
Returns the data name (category) of this dataset.
- fields = mappingproxy({})¶
A mapping of attribute names to their
Attribute
information. Note that this contains attributes declared on the class, not attributes added to an instance. Useattrs
to view all attributes on an instance.
- identifiers¶
Returns this dataset’s parameters.
- info¶
Return metadata associated with this dataset.
- type_id = 'dataset'¶
Type identifier for this dataset. Used internally to load datasets from other datasets.
Methods
close
()Close the underlying dataset file.
Returns a list of this dataset's attributes.
open
(filepath[, mode])Open existing dataset or create a new one at
filepath
.read
(source[, attributes, overwrite])Load dataset from HDF5 file at filepath.
write
(dest[, mode, attributes, overwrite])Write dataset to HDF5 file at filepath.
- classmethod open(filepath, mode='r')[source]¶
Open existing dataset or create a new one at
filepath
.- Parameters
filepath – Path to dataset file
mode – File handling mode. Possible values are “w-” (create, fail if file exists), “w” (create, overwrite existing), “a” (append existing, create if doesn’t exist), “r” (read existing, must exist), and “copy”, which loads the dataset into memory and detaches it from the underlying file. Default is “r”.
- Returns
Dataset object from file
- read(source, attributes=None, *, overwrite=False)[source]¶
Load dataset from HDF5 file at filepath.
- Parameters
source – Dataset, or path to HDF5 file containing dataset, from which to read attributes
attributes – Optional list of attributes to copy. If None, all attributes will be copied.
overwrite – Whether to overwrite attributes that already exist in this dataset.
- write(dest, mode='a', attributes=None, *, overwrite=False)[source]¶
Write dataset to HDF5 file at filepath.
- Parameters
dest – HDF5 file, or path to HDF5 file containing dataset, to write attributes to
mode – File handling mode, if
source
is a file system path. Possible values are “w-” (create, fail if file exists), “w” (create, overwrite existing), and “a” (append existing, create if doesn’t exist). Default is “w-“.attributes – Optional list of attributes to copy. If None, all attributes will be copied. Note that identifiers will always be copied.
overwrite – Whether to overwrite attributes that already exist in this dataset.