Skip to content

Commit 7dfcd0f

Browse files
committed
fix sphinx warnings
1 parent b7a231e commit 7dfcd0f

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

docs/user-guide/data_types.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Zarr's data type model
77
Every Zarr array has a "data type", which defines the meaning and physical layout of the
88
array's elements. Zarr is heavily influenced by `NumPy <https://numpy.org/doc/stable/>`_, and
99
Zarr-Python supports creating arrays with Numpy data types::
10-
>>> import zarr
11-
>>> import numpy as np
12-
>>> zarr.create_array(store={}, shape=(10,), dtype=np.dtype('uint8'))
13-
>>> z
14-
<Array memory://126225407345920 shape=(10,) dtype=uint8>
10+
>>> import zarr
11+
>>> import numpy as np
12+
>>> zarr.create_array(store={}, shape=(10,), dtype=np.dtype('uint8'))
13+
>>> z
14+
<Array memory://126225407345920 shape=(10,) dtype=uint8>
1515

1616
But Zarr data types and Numpy data types are also very different:
1717
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
3636
<i8
3737

3838
.. 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.
4141

4242
In addition to defining a representation of the data type itself (which in the example above was just a simple string ``"<i8"``, Zarr also
4343
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.
8383
supported by Zarr Python is modeled by a subclass of `DTypeWrapper`, which has the following structure:
8484

8585
(attribute) ``dtype_cls``
86-
^^^^^^^^^^^^^
86+
^^^^^^^^^^^^^^^^^^^^^^^^^
8787
The ``dtype_cls`` attribute is a **class variable** that is bound to a class that can produce
8888
an instance of a native data type. For example, on the ``DTypeWrapper`` used to model the boolean
8989
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
9999

100100

101101
(attribute) ``_zarr_v3_name``
102-
^^^^^^^^^^^^^
102+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103103
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
105105
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,
106106
which is parametrized by a number of bits, and so may take the form ``r8``, ``r16``, ... etc.
107107

108108
(class method) ``from_dtype(cls, dtype) -> Self``
109-
^^^^^^^^^
109+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110110
This method defines a procedure for safely converting a native dtype instance into an instance of ``DTypeWrapper``. It should perform
111111
validation of its input to ensure that the native dtype is an instance of the ``dtype_cls`` class attribute, for example. For some
112112
data types, additional checks are needed -- in Numpy "structured" data types and "void" data types use the same class, with different properties.
113113
A ``DTypeWrapper`` that wraps Numpy structured data types must do additional checks to ensure that the input ``dtype`` is actually a structured data type.
114114
If input validation succeeds, this method will call ``_from_dtype_unsafe``.
115115

116116
(method) ``to_dtype(self) -> dtype``
117-
^^^^^^^
117+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
118118
This method produces a native data type consistent with the properties of the ``DTypeWrapper``. Together
119119
with ``from_dtype``, this method allows round-trip conversion of a native data type in to a wrapper class and then out again.
120120

121121
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.
122122

123123
(method) ``to_dict(self) -> dict``
124-
^^^^^
124+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125125
This method generates a JSON-serialiazable representation of the wrapped data type which can be stored in
126126
Zarr metadata.
127127

128128
(method) ``cast_value(self, value: object) -> scalar``
129-
^^^^^
129+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
130130
This method converts a python object to an instance of the wrapped data type. It is used for generating the default
131131
value associated with this data type.
132132

133133

134134
(method) ``default_value(self) -> scalar``
135-
^^^^
135+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136136
This method returns the default value for the wrapped data type. Zarr-Python uses this method to generate a default fill value
137137
for an array when a user has not requested one.
138138

@@ -141,7 +141,7 @@ can have a static default value, parametrized data types like fixed-length strin
141141
a default value must be calculated based on the attributes of the wrapped data type.
142142

143143
(class method) ``check_dtype(cls, dtype) -> bool``
144-
^^^^^
144+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
145145
This class method checks if a native dtype is compatible with the ``DTypeWrapper`` class. It returns ``True``
146146
if ``dtype`` is compatible with the wrapper class, and ``False`` otherwise. For many data types, this check is as simple
147147
as checking that ``cls.dtype_cls`` matches ``type(dtype)``, i.e. checking that the data type class wrapped
@@ -150,17 +150,17 @@ in which case this method is overridden so that additional properties of ``dtype
150150
the expectations of ``cls``.
151151

152152
(class method) ``from_dict(cls, dtype) -> Self``
153-
^^^^
153+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154154
This class method creates a ``DTypeWrapper`` from an appropriately structured dictionary. The default
155155
implementation first checks that the dictionary has the correct structure, and then uses its data
156156
to instantiate the ``DTypeWrapper`` instance.
157157

158158
(method) ``to_dict(self) -> dict[str, JSON]``
159-
^^^
159+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160160
Returns a dictionary form of the wrapped data type. This is used prior to writing array metadata.
161161

162162
(class method) ``get_name(self, zarr_format: Literal[2, 3]) -> str``
163-
^^^^
163+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
164164
This method generates a name for the wrapped data type, depending on the Zarr format. If ``zarr_format`` is
165165
2 and the wrapped data type is a Numpy data type, then the Numpy string representation of that data type is returned.
166166
If ``zarr_format`` is 3, then the Zarr V3 name for the wrapped data type is returned. For most data types
@@ -169,14 +169,14 @@ name must be computed at runtime based on the parameters of the data type.
169169

170170

171171
(method) ``to_json_value(self, data: scalar, zarr_format: Literal[2, 3]) -> JSON``
172-
^^^
172+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
173173
This method converts a scalar instance of the data type into a JSON-serialiazable value.
174174
For some data types like bool and integers this conversion is simple -- just return a JSON boolean
175175
or number -- but other data types define a JSON serialization for scalars that is a bit more involved.
176176
And this JSON serialization depends on the Zarr format.
177177

178178
(method) ``from_json_value(self, data: JSON, zarr_format: Literal[2, 3]) -> scalar``
179-
^^^
179+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
180180
Convert a JSON-serialiazed scalar to a native scalar. This inverts the operation of ``to_json_value``.
181181

182182

0 commit comments

Comments
 (0)