qml.data.DatasetDict

class DatasetDict(value=<UnsetType.UNSET: 'UNSET'>, info=None, *, bind=None, parent_and_key=None)[source]

Bases: Generic[pennylane.data.base.typing_util.T], pennylane.data.base.attribute.DatasetAttribute[collections.abc.MutableMapping, Mapping[str, pennylane.data.base.typing_util.T], Mapping[str, pennylane.data.base.typing_util.T]], MutableMapping[str, pennylane.data.base.typing_util.T], pennylane.data.base.mapper.MapperMixin

Provides a dict-like collection for Dataset attribute types. Keys must be strings.

bind

Returns the HDF5 object that contains this attribute’s data.

info

Returns the AttributeInfo for this attribute.

registry

Maps type_ids to their DatasetAttribute classes.

type_consumer_registry

Maps types to their default DatasetAttribute

type_id

bind: HDF5Group

Returns the HDF5 object that contains this attribute’s data.

info

Returns the AttributeInfo for this attribute.

registry: Mapping[str, Type[DatasetAttribute]] = mappingproxy({'dataset': <class 'pennylane.data.base.dataset._DatasetAttributeType'>, 'array': <class 'pennylane.data.attributes.array.DatasetArray'>, 'dict': <class 'pennylane.data.attributes.dictionary.DatasetDict'>, 'json': <class 'pennylane.data.attributes.json.DatasetJSON'>, 'list': <class 'pennylane.data.attributes.list.DatasetList'>, 'molecule': <class 'pennylane.data.attributes.molecule.DatasetMolecule'>, 'none': <class 'pennylane.data.attributes.none.DatasetNone'>, 'operator': <class 'pennylane.data.attributes.operator.operator.DatasetOperator'>, 'scalar': <class 'pennylane.data.attributes.scalar.DatasetScalar'>, 'sparse_array': <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, 'string': <class 'pennylane.data.attributes.string.DatasetString'>, 'tuple': <class 'pennylane.data.attributes.tuple.DatasetTuple'>, 'pytree': <class 'pennylane.data.attributes.pytree.DatasetPyTree'>})

Maps type_ids to their DatasetAttribute classes.

type_consumer_registry: Mapping[type, Type[DatasetAttribute]] = mappingproxy({<class 'pennylane.qchem.molecule.Molecule'>: <class 'pennylane.data.attributes.molecule.DatasetMolecule'>, <class 'NoneType'>: <class 'pennylane.data.attributes.none.DatasetNone'>, <class 'scipy.sparse._bsr.bsr_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._coo.coo_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._csc.csc_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._csr.csr_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._dia.dia_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._dok.dok_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._lil.lil_array'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._csc.csc_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._csr.csr_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._bsr.bsr_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._coo.coo_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._dia.dia_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._dok.dok_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'scipy.sparse._lil.lil_matrix'>: <class 'pennylane.data.attributes.sparse_array.DatasetSparseArray'>, <class 'str'>: <class 'pennylane.data.attributes.string.DatasetString'>, <class 'tuple'>: <class 'pennylane.data.attributes.tuple.DatasetTuple'>})

Maps types to their default DatasetAttribute

type_id: ClassVar[str] = 'dict'

clear()

consumes_types()

Returns an iterable of types for which this should be the default codec.

copy()

Returns a copy of this mapping as a builtin dict, with all elements copied.

copy_value()

Deserializes the mapped value from bind, and also perform a ‘deep-copy’ of any nested values contained in bind.

default_value()

Returns a valid default value for this type, or UNSET if this type must be initialized with a value.

get(key[, default])

Retrieve the corresponding layout by the string key.

get_value()

Deserializes the mapped value from bind.

hdf5_to_value(bind)

Parses bind into Python object.

items()

keys()

pop(k[,d])

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()

as a 2-tuple; but raise KeyError if D is empty.

py_type(value_type)

Determines the py_type of an attribute during value initialization, if it was not provided in the info argument.

setdefault(k[,d])

update([E, ]**F)

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

value_to_hdf5(bind_parent, key, value)

Converts value into a HDF5 Array or Group under bind_parent[key].

values()

clear()None.  Remove all items from D.
classmethod consumes_types()

Returns an iterable of types for which this should be the default codec. If a value of one of these types is assigned to a Dataset without specifying a type_id, this type will be used.

copy()[source]

Returns a copy of this mapping as a builtin dict, with all elements copied.

copy_value()[source]

Deserializes the mapped value from bind, and also perform a ‘deep-copy’ of any nested values contained in bind.

classmethod default_value()[source]

Returns a valid default value for this type, or UNSET if this type must be initialized with a value.

get(key, default=None)

Retrieve the corresponding layout by the string key.

When there isn’t an exact match, all the existing keys in the layout map will be treated as a regex and map against the input key again. The first match will be returned, based on the key insertion order. Return None if there isn’t any match found.

Parameters

key – the string key as the query for the layout.

Returns

Corresponding layout based on the query.

get_value()

Deserializes the mapped value from bind.

hdf5_to_value(bind)[source]

Parses bind into Python object.

items()a set-like object providing a view on D’s items
keys()a set-like object providing a view on D’s keys
pop(k[, d])v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem()(k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

classmethod py_type(value_type)

Determines the py_type of an attribute during value initialization, if it was not provided in the info argument. This method returns f"{value_type.__module__}.{value_type.__name__}.

setdefault(k[, d])D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F)None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

value_to_hdf5(bind_parent, key, value)[source]

Converts value into a HDF5 Array or Group under bind_parent[key].

values()an object providing a view on D’s values