qml.data.DatasetSparseArray¶
- class DatasetSparseArray(value=UnsetType.UNSET, info=None, *, bind=None, parent_and_key=None)[source]¶
Bases:
Generic
[SparseT
],DatasetAttribute
[MutableMapping
,SparseT
,SparseT
]Attribute type for Scipy sparse arrays. Can accept values of any type in
scipy.sparse
. Arrays are serialized using the CSR format.Attributes
Returns the HDF5 object that contains this attribute's data.
Returns the
AttributeInfo
for this attribute.Maps type_ids to their DatasetAttribute classes.
Returns the class of sparse array that will be returned by the
get_value()
method.Maps types to their default DatasetAttribute
Unique identifier for this DatasetAttribute class.
- bind¶
Returns the HDF5 object that contains this attribute’s data.
- info¶
Returns the
AttributeInfo
for this attribute.
- registry = 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'>, 'pytree': <class 'pennylane.data.attributes.pytree.DatasetPyTree'>, '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'>})¶
Maps type_ids to their DatasetAttribute classes.
- sparse_array_class¶
Returns the class of sparse array that will be returned by the
get_value()
method.
- type_consumer_registry = 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 = 'sparse_array'¶
Unique identifier for this DatasetAttribute class. Must be declared in subclasses.
Methods
Returns an iterable of types for which this should be the default codec.
Deserializes the mapped value from
bind
, and also perform a 'deep-copy' of any nested values contained inbind
.Returns a valid default value for this type, or
UNSET
if this type must be initialized with a value.Deserializes the mapped value from
bind
.hdf5_to_value
(bind)Parses bind into Python object.
py_type
(value_type)The module path of sparse array types is private, e.g
scipy.sparse._csr.csr_array
.value_to_hdf5
(bind_parent, key, value)Converts value into a HDF5 Array or Group under bind_parent[key].
- classmethod consumes_types()[source]¶
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_value()¶
Deserializes the mapped value from
bind
, and also perform a ‘deep-copy’ of any nested values contained inbind
.
- classmethod default_value()¶
Returns a valid default value for this type, or
UNSET
if this type must be initialized with a value.
- get_value()¶
Deserializes the mapped value from
bind
.