Skip to content

Commit 45aab29

Browse files
committed
harmonize docstrings
1 parent 620749b commit 45aab29

File tree

4 files changed

+35
-86
lines changed

4 files changed

+35
-86
lines changed

src/zarr/core/dtype/npy/bool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
@dataclass(frozen=True, kw_only=True, slots=True)
2222
class Bool(ZDType[np.dtypes.BoolDType, np.bool_], HasItemSize):
2323
"""
24-
A Zarr data type for arrays containing booleans. Wraps the NumPy
25-
``np.dtypes.BoolDType`` data type. Scalars for this data type are instances of ``np.bool_``.
24+
A Zarr data type for arrays containing booleans.
25+
26+
Wraps the NumPy ``np.dtypes.BoolDType`` data type. Scalars for this data type are instances of
27+
``np.bool_``.
2628
2729
Attributes
2830
----------

src/zarr/core/dtype/npy/bytes.py

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ class FixedLengthBytesConfig(TypedDict):
3535
@dataclass(frozen=True, kw_only=True)
3636
class NullTerminatedBytes(ZDType[np.dtypes.BytesDType[int], np.bytes_], HasLength, HasItemSize):
3737
"""
38-
A Zarr data type for arrays containing null-terminated bytes. Wraps the NumPy
39-
``np.dtypes.BytesDType`` data type. Scalars for this data type are instances of ``np.bytes_``.
38+
A Zarr data type for arrays containing fixed-length null-terminated byte sequences.
39+
40+
Wraps the NumPy ``np.dtypes.BytesDType`` data type. Scalars for this data type are instances of
41+
``np.bytes_``.
4042
4143
This data type is parametrized by an integral length which specifies size in bytes of each
4244
scalar. Because this data type uses null-terminated semantics, indexing into
@@ -158,15 +160,6 @@ def _check_json_v3(cls, data: DTypeJSON) -> TypeGuard[NullTerminatedBytesJSONV3]
158160
"""
159161
Check that the input is a valid representation of NullTerminatedBytes in Zarr V3.
160162
161-
The input must be a mapping with the following structure:
162-
163-
{
164-
"name": "null_terminated_bytes",
165-
"configuration": {
166-
"length_bytes": <int>
167-
}
168-
}
169-
170163
Parameters
171164
----------
172165
data : DTypeJSON
@@ -256,19 +249,7 @@ def to_json(
256249
self, zarr_format: ZarrFormat
257250
) -> DTypeConfig_V2[str, None] | NullTerminatedBytesJSONV3:
258251
"""
259-
Generate a JSON representation of NullTerminatedBytes.
260-
261-
If zarr_format is 2, the return value will be a dictionary with the form
262-
{
263-
"name": "|S<self.length>",
264-
"object_codec_id": None
265-
}
266-
267-
If zarr_format is 3, the resulting JSON will be a dictionary with the form
268-
{
269-
"name": "null_terminated_bytes",
270-
"configuration": {"length_bytes": self.length}
271-
}
252+
Generate a JSON representation of this data type.
272253
273254
Parameters
274255
----------
@@ -440,13 +421,10 @@ def item_size(self) -> int:
440421

441422
@dataclass(frozen=True, kw_only=True)
442423
class RawBytes(ZDType[np.dtypes.VoidDType[int], np.void], HasLength, HasItemSize):
443-
# np.dtypes.VoidDType is specified in an odd way in NumPy
444-
# it cannot be used to create instances of the dtype
445-
# so we have to tell mypy to ignore this here
446-
447424
"""
448-
A Zarr data type for arrays containing raw bytes. Wraps the NumPy ``void`` data type.
449-
Scalars for this data type are instances of ``np.void``.
425+
A Zarr data type for arrays containing fixed-length sequences of raw bytes.
426+
427+
Wraps the NumPy ``void`` data type. Scalars for this data type are instances of ``np.void``.
450428
451429
This data type is parametrized by an integral length which specifies size in bytes of each
452430
scalar belonging to this data type.
@@ -491,6 +469,9 @@ class does not support structured data types.
491469
492470
"""
493471

472+
# np.dtypes.VoidDType is specified in an odd way in NumPy
473+
# it cannot be used to create instances of the dtype
474+
# so we have to tell mypy to ignore this here
494475
dtype_cls = np.dtypes.VoidDType # type: ignore[assignment]
495476
_zarr_v3_name: ClassVar[Literal["raw_bytes"]] = "raw_bytes"
496477

@@ -694,19 +675,7 @@ def to_json(self, zarr_format: Literal[3]) -> RawBytesJSONV3: ...
694675

695676
def to_json(self, zarr_format: ZarrFormat) -> DTypeConfig_V2[str, None] | RawBytesJSONV3:
696677
"""
697-
Generate a JSON representation of RawBytes.
698-
699-
If zarr_format is 2, the return value will be a dictionary with the form
700-
{
701-
"name": "|V<self.length>",
702-
"object_codec_id": None
703-
}
704-
705-
If zarr_format is 3, the resulting JSON will be a dictionary with the form
706-
{
707-
"name": "raw_bytes",
708-
"configuration": {"length_bytes": self.length}
709-
}
678+
Generate a JSON representation of this data type.
710679
711680
Parameters
712681
----------
@@ -874,8 +843,9 @@ def item_size(self) -> int:
874843
@dataclass(frozen=True, kw_only=True)
875844
class VariableLengthBytes(ZDType[np.dtypes.ObjectDType, bytes], HasObjectCodec):
876845
"""
877-
A Zarr data type for arrays containing variable-length bytes. Wraps the NumPy
878-
"object" data type. Scalars for this data type are instances of plain python bytes.
846+
A Zarr data type for arrays containing variable-length sequences of bytes.
847+
848+
Wraps the NumPy "object" data type. Scalars for this data type are instances of ``bytes``.
879849
880850
Attributes
881851
----------

src/zarr/core/dtype/npy/int.py

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def to_json_scalar(self, data: object, *, zarr_format: ZarrFormat) -> int:
256256
@dataclass(frozen=True, kw_only=True)
257257
class Int8(BaseInt[np.dtypes.Int8DType, np.int8]):
258258
"""
259-
A Zarr data type for 8-bit signed integers.
259+
A Zarr data type for arrays containing 8-bit signed integers.
260260
261261
Wraps the NumPy ``np.dtypes.Int8DType`` data type. Scalars for this data type are
262262
instances of ``np.int8``.
@@ -555,8 +555,10 @@ def item_size(self) -> int:
555555
@dataclass(frozen=True, kw_only=True)
556556
class Int16(BaseInt[np.dtypes.Int16DType, np.int16], HasEndianness):
557557
"""
558-
A Zarr data type for arrays containing 16-bit signed integers. Wraps the NumPy
559-
np.dtypes.Int16DType data type. Scalars for this data type are instances np.int16.
558+
A Zarr data type for arrays containing 16-bit signed integers.
559+
560+
Wraps the NumPy ``np.dtypes.Int16DType`` data type. Scalars for this data type are instances of
561+
``np.int16``.
560562
561563
Attributes
562564
----------
@@ -675,16 +677,6 @@ def to_json(
675677
"""
676678
Serialize this ZDType to v2- or v3-flavored JSON
677679
678-
If the zarr_format is 2, then return a dict like this:
679-
.. code-block:: json
680-
681-
{
682-
"name": ">i2" or "<i2",
683-
"object_codec_id": None
684-
}
685-
686-
If the zarr_format is 3, then return the string "int16"
687-
688680
Parameters
689681
----------
690682
zarr_format : ZarrFormat
@@ -845,16 +837,6 @@ def to_json(
845837
"""
846838
Serialize this ZDType to v2- or v3-flavored JSON
847839
848-
If the zarr_format is 2, then return a dict like this:
849-
.. code-block:: json
850-
851-
{
852-
"name": ">u2" or "<u2",
853-
"object_codec_id": None
854-
}
855-
856-
If the zarr_format is 3, then return the string "uint16"
857-
858840
Parameters
859841
----------
860842
zarr_format : ZarrFormat
@@ -1015,16 +997,6 @@ def to_json(
1015997
"""
1016998
Serialize this ZDType to v2- or v3-flavored JSON
1017999
1018-
If the zarr_format is 2, then return a dict like this:
1019-
.. code-block:: json
1020-
1021-
{
1022-
"name": ">i4" or "<i4",
1023-
"object_codec_id": None
1024-
}
1025-
1026-
If the zarr_format is 3, then return the string "int32"
1027-
10281000
Parameters
10291001
----------
10301002
zarr_format : ZarrFormat
@@ -1377,7 +1349,7 @@ class UInt64(BaseInt[np.dtypes.UInt64DType, np.uint64], HasEndianness):
13771349
"""
13781350
A Zarr data type for arrays containing 64-bit unsigned integers.
13791351
1380-
This data type wraps the NumPy ``np.dtypes.UInt64DType`` data type. Scalars for this data type
1352+
Wraps the NumPy ``np.dtypes.UInt64DType`` data type. Scalars for this data type
13811353
are instances of ``np.uint64``.
13821354
13831355
Attributes

src/zarr/core/dtype/npy/string.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class FixedLengthUTF32(
6262
"""
6363
A Zarr data type for arrays containing fixed-length UTF-32 strings.
6464
65-
Wraps the NumPy np.dtypes.StrDType data type. Scalars for this data type are instances of np.str_.
65+
Wraps the NumPy ``np.dtypes.StrDType`` data type. Scalars for this data type are instances of
66+
``np.str_``.
6667
6768
Attributes
6869
----------
@@ -640,8 +641,10 @@ def cast_scalar(self, data: object) -> str:
640641
@dataclass(frozen=True, kw_only=True)
641642
class VariableLengthUTF8(UTF8Base[np.dtypes.StringDType]): # type: ignore[type-var]
642643
"""
643-
A Zarr data type for arrays containing variable-length UTF-8 strings. Wraps the
644-
NumPy np.dtypes.StringDType data type. Scalars for this data type are Python strings.
644+
A Zarr data type for arrays containing variable-length UTF-8 strings.
645+
646+
Wraps the NumPy ``np.dtypes.StringDType`` data type. Scalars for this data type are instances
647+
of ``str``.
645648
646649
647650
Attributes
@@ -672,8 +675,10 @@ def to_native_dtype(self) -> np.dtypes.StringDType:
672675
@dataclass(frozen=True, kw_only=True)
673676
class VariableLengthUTF8(UTF8Base[np.dtypes.ObjectDType]): # type: ignore[no-redef]
674677
"""
675-
A Zarr data type for arrays containing variable-length UTF-8 strings. Wraps the
676-
NumPy np.dtypes.ObjectDType data type. Scalars for this data type are Python strings.
678+
A Zarr data type for arrays containing variable-length UTF-8 strings.
679+
680+
Wraps the NumPy ``np.dtypes.ObjectDType`` data type. Scalars for this data type are instances
681+
of ``str``.
677682
678683
679684
Attributes

0 commit comments

Comments
 (0)