61
61
_check_codecjson_v2 ,
62
62
product ,
63
63
)
64
- from zarr .dtype import UInt8 , ZDType , parse_dtype
64
+ from zarr .dtype import UInt8 , ZDType
65
65
from zarr .errors import ZarrUserWarning
66
66
from zarr .registry import get_numcodec
67
67
75
75
from zarr .codecs .zstd import ZstdConfig_V3 , ZstdJSON_V2 , ZstdJSON_V3
76
76
from zarr .core .array_spec import ArraySpec
77
77
from zarr .core .buffer import Buffer , BufferPrototype , NDBuffer
78
- from zarr .core .dtype .common import DTypeSpec_V2 , DTypeSpec_V3
79
78
80
79
81
80
# TypedDict definitions for V2 and V3 JSON representations
@@ -159,20 +158,6 @@ class BitRoundConfig(TypedDict):
159
158
keepbits : int
160
159
161
160
162
- class FixedScaleOffsetConfig_V2 (TypedDict ):
163
- dtype : NotRequired [DTypeSpec_V2 ]
164
- astype : NotRequired [DTypeSpec_V2 ]
165
- scale : NotRequired [float ]
166
- offset : NotRequired [float ]
167
-
168
-
169
- class FixedScaleOffsetConfig_V3 (TypedDict ):
170
- dtype : NotRequired [DTypeSpec_V3 ]
171
- astype : NotRequired [DTypeSpec_V2 ]
172
- scale : NotRequired [float ]
173
- offset : NotRequired [float ]
174
-
175
-
176
161
class QuantizeConfig (TypedDict ):
177
162
digits : int
178
163
dtype : NotRequired [str ]
@@ -182,11 +167,6 @@ class PackBitsConfig(TypedDict):
182
167
pass # PackBits has no configuration parameters
183
168
184
169
185
- class AsTypeConfig (TypedDict ):
186
- encode_dtype : str
187
- decode_dtype : str
188
-
189
-
190
170
class BitRoundJSON_V2 (BitRoundConfig ):
191
171
"""JSON representation of BitRound codec for Zarr V2."""
192
172
@@ -197,18 +177,6 @@ class BitRoundJSON_V3(NamedRequiredConfig[Literal["bitround"], BitRoundConfig]):
197
177
"""JSON representation of BitRound codec for Zarr V3."""
198
178
199
179
200
- class FixedScaleOffsetJSON_V2 (FixedScaleOffsetConfig_V2 ):
201
- """JSON representation of FixedScaleOffset codec for Zarr V2."""
202
-
203
- id : ReadOnly [Literal ["fixedscaleoffset" ]]
204
-
205
-
206
- class FixedScaleOffsetJSON_V3 (
207
- NamedRequiredConfig [Literal ["fixedscaleoffset" ], FixedScaleOffsetConfig_V3 ]
208
- ):
209
- """JSON representation of FixedScaleOffset codec for Zarr V3."""
210
-
211
-
212
180
class QuantizeJSON_V2 (QuantizeConfig ):
213
181
"""JSON representation of Quantize codec for Zarr V2."""
214
182
@@ -229,16 +197,6 @@ class PackBitsJSON_V3(NamedRequiredConfig[Literal["packbits"], PackBitsConfig]):
229
197
"""JSON representation of PackBits codec for Zarr V3."""
230
198
231
199
232
- class AsTypeJSON_V2 (AsTypeConfig ):
233
- """JSON representation of AsType codec for Zarr V2."""
234
-
235
- id : ReadOnly [Literal ["astype" ]]
236
-
237
-
238
- class AsTypeJSON_V3 (NamedRequiredConfig [Literal ["astype" ], AsTypeConfig ]):
239
- """JSON representation of AsType codec for Zarr V3."""
240
-
241
-
242
200
# Checksum codec JSON representations
243
201
class Crc32Config (TypedDict ):
244
202
"""Configuration parameters for CRC32 codec."""
@@ -601,32 +559,6 @@ def to_json(self, zarr_format: ZarrFormat) -> BitRoundJSON_V2 | BitRoundJSON_V3:
601
559
return super ().to_json (zarr_format ) # type: ignore[return-value]
602
560
603
561
604
- class FixedScaleOffset (_NumcodecsArrayArrayCodec ):
605
- codec_name = "numcodecs.fixedscaleoffset"
606
- _codec_id = "fixedscaleoffset"
607
- codec_config : FixedScaleOffsetConfig_V2
608
-
609
- @overload
610
- def to_json (self , zarr_format : Literal [2 ]) -> FixedScaleOffsetJSON_V2 : ...
611
- @overload
612
- def to_json (self , zarr_format : Literal [3 ]) -> FixedScaleOffsetJSON_V3 : ...
613
- def to_json (self , zarr_format : ZarrFormat ) -> FixedScaleOffsetJSON_V2 | FixedScaleOffsetJSON_V3 :
614
- _warn_unstable_specification (self )
615
- return super ().to_json (zarr_format ) # type: ignore[return-value]
616
-
617
- def resolve_metadata (self , chunk_spec : ArraySpec ) -> ArraySpec :
618
- if astype := self .codec_config .get ("astype" ):
619
- dtype = parse_dtype (np .dtype (astype ), zarr_format = 3 ) # type: ignore[arg-type]
620
- return replace (chunk_spec , dtype = dtype )
621
- return chunk_spec
622
-
623
- def evolve_from_array_spec (self , array_spec : ArraySpec ) -> Self :
624
- if self .codec_config .get ("dtype" ) is None :
625
- dtype = array_spec .dtype .to_native_dtype ()
626
- return type (self )(** {** self .codec_config , "dtype" : str (dtype )})
627
- return self
628
-
629
-
630
562
class Quantize (_NumcodecsArrayArrayCodec ):
631
563
codec_name = "numcodecs.quantize"
632
564
_codec_id = "quantize"
@@ -676,31 +608,6 @@ def validate(self, *, dtype: ZDType[Any, Any], **_kwargs: Any) -> None:
676
608
raise ValueError (f"Packbits filter requires bool dtype. Got { dtype } ." )
677
609
678
610
679
- class AsType (_NumcodecsArrayArrayCodec ):
680
- codec_name = "numcodecs.astype"
681
- _codec_id = "astype"
682
- codec_config : AsTypeConfig
683
-
684
- @overload
685
- def to_json (self , zarr_format : Literal [2 ]) -> AsTypeJSON_V2 : ...
686
- @overload
687
- def to_json (self , zarr_format : Literal [3 ]) -> AsTypeJSON_V3 : ...
688
- def to_json (self , zarr_format : ZarrFormat ) -> AsTypeJSON_V2 | AsTypeJSON_V3 :
689
- _warn_unstable_specification (self )
690
- return super ().to_json (zarr_format ) # type: ignore[return-value]
691
-
692
- def resolve_metadata (self , chunk_spec : ArraySpec ) -> ArraySpec :
693
- dtype = parse_dtype (np .dtype (self .codec_config ["encode_dtype" ]), zarr_format = 3 )
694
- return replace (chunk_spec , dtype = dtype )
695
-
696
- def evolve_from_array_spec (self , array_spec : ArraySpec ) -> AsType :
697
- if self .codec_config .get ("decode_dtype" ) is None :
698
- # TODO: remove these coverage exemptions the correct way, i.e. with tests
699
- dtype = array_spec .dtype .to_native_dtype () # pragma: no cover
700
- return AsType (** {** self .codec_config , "decode_dtype" : str (dtype )}) # pragma: no cover
701
- return self
702
-
703
-
704
611
# bytes-to-bytes checksum codecs
705
612
class _NumcodecsChecksumCodec (_NumcodecsBytesBytesCodec ):
706
613
def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
0 commit comments