You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But Zarr data types and Numpy data types are also very different:
17
17
Unlike Numpy arrays, Zarr arrays are designed to be persisted to storage and read by Zarr implementations in different programming languages.
@@ -36,8 +36,8 @@ Thus the JSON identifier for a Numpy-compatible data type is just the Numpy ``st
36
36
<i8
37
37
38
38
.. note::
39
-
The ``<`` character in the data type metadata encodes the `endianness https://numpy.org/doc/2.2/reference/generated/numpy.dtype.byteorder.html`_, or "byte order", of the data type. Following Numpy's example,
40
-
Zarr version 2 data types associate each data type with an endianness where applicable. Zarr version 3 data types do not store endianness information.
39
+
The ``<`` character in the data type metadata encodes the `endianness <https://numpy.org/doc/2.2/reference/generated/numpy.dtype.byteorder.html>`_, or "byte order", of the data type. Following Numpy's example,
40
+
Zarr version 2 data types associate each data type with an endianness where applicable. Zarr version 3 data types do not store endianness information.
41
41
42
42
In addition to defining a representation of the data type itself (which in the example above was just a simple string ``"<i8"``, Zarr also
43
43
defines a metadata representation of scalars associated with that data type. Integers are stored as ``JSON`` numbers,
@@ -83,7 +83,7 @@ To achieve these goals, Zarr Python uses a class called :class:`zarr.core.dtype.
83
83
supported by Zarr Python is modeled by a subclass of `DTypeWrapper`, which has the following structure:
84
84
85
85
(attribute) ``dtype_cls``
86
-
^^^^^^^^^^^^^
86
+
^^^^^^^^^^^^^^^^^^^^^^^^^
87
87
The ``dtype_cls`` attribute is a **class variable** that is bound to a class that can produce
88
88
an instance of a native data type. For example, on the ``DTypeWrapper`` used to model the boolean
89
89
data type, the ``dtype_cls`` attribute is bound to the numpy bool data type class: ``np.dtypes.BoolDType``.
@@ -99,40 +99,40 @@ byte order semantics thus have ``endianness`` as an instance variable, and this
99
99
100
100
101
101
(attribute) ``_zarr_v3_name``
102
-
^^^^^^^^^^^^^
102
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
103
The ``_zarr_v3_name`` attribute encodes the canonical name for a data type for Zarr V3. For many data types these names
104
-
are defined in the `Zarr V3 specification https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html#data-types`_ For nearly all of the
104
+
are defined in the `Zarr V3 specification <https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html#data-types>`_ For nearly all of the
105
105
data types defined in Zarr V3, this name can be used to uniquely specify a data type. The one exception is the ``r*`` data type,
106
106
which is parametrized by a number of bits, and so may take the form ``r8``, ``r16``, ... etc.
107
107
108
108
(class method) ``from_dtype(cls, dtype) -> Self``
109
-
^^^^^^^^^
109
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110
110
This method defines a procedure for safely converting a native dtype instance into an instance of ``DTypeWrapper``. It should perform
111
111
validation of its input to ensure that the native dtype is an instance of the ``dtype_cls`` class attribute, for example. For some
112
112
data types, additional checks are needed -- in Numpy "structured" data types and "void" data types use the same class, with different properties.
113
113
A ``DTypeWrapper`` that wraps Numpy structured data types must do additional checks to ensure that the input ``dtype`` is actually a structured data type.
114
114
If input validation succeeds, this method will call ``_from_dtype_unsafe``.
115
115
116
116
(method) ``to_dtype(self) -> dtype``
117
-
^^^^^^^
117
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118
118
This method produces a native data type consistent with the properties of the ``DTypeWrapper``. Together
119
119
with ``from_dtype``, this method allows round-trip conversion of a native data type in to a wrapper class and then out again.
120
120
121
121
That is, for some ``DTypeWrapper`` class ``FooWrapper`` that wraps a native data type called ``foo``, ``FooWrapper.from_dtype(instance_of_foo).to_dtype() == instance_of_foo`` should be true.
122
122
123
123
(method) ``to_dict(self) -> dict``
124
-
^^^^^
124
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125
125
This method generates a JSON-serialiazable representation of the wrapped data type which can be stored in
0 commit comments