@@ -421,6 +421,9 @@ def _encode(self, chunk_data: Buffer, prototype: BufferPrototype) -> Buffer:
421
421
async def _encode_single (self , chunk_data : Buffer , chunk_spec : ArraySpec ) -> Buffer :
422
422
return await asyncio .to_thread (self ._encode , chunk_data , chunk_spec .prototype )
423
423
424
+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
425
+ raise NotImplementedError
426
+
424
427
425
428
class _NumcodecsArrayArrayCodec (_NumcodecsCodec , ArrayArrayCodec ):
426
429
async def _decode_single (self , chunk_data : NDBuffer , chunk_spec : ArraySpec ) -> NDBuffer :
@@ -433,6 +436,9 @@ async def _encode_single(self, chunk_data: NDBuffer, chunk_spec: ArraySpec) -> N
433
436
out = await asyncio .to_thread (self ._codec .encode , chunk_ndarray )
434
437
return chunk_spec .prototype .nd_buffer .from_ndarray_like (out )
435
438
439
+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
440
+ raise NotImplementedError
441
+
436
442
437
443
class _NumcodecsArrayBytesCodec (_NumcodecsCodec , ArrayBytesCodec ):
438
444
def __init__ (self , ** codec_config : JSON ) -> None :
@@ -448,6 +454,9 @@ async def _encode_single(self, chunk_data: NDBuffer, chunk_spec: ArraySpec) -> B
448
454
out = await asyncio .to_thread (self ._codec .encode , chunk_ndarray )
449
455
return chunk_spec .prototype .buffer .from_bytes (out )
450
456
457
+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
458
+ raise NotImplementedError
459
+
451
460
452
461
# bytes-to-bytes codecs
453
462
class Blosc (_NumcodecsBytesBytesCodec ):
@@ -475,9 +484,6 @@ def to_json(self, zarr_format: ZarrFormat) -> LZ4JSON_V2 | LZ4JSON_V3:
475
484
_warn_unstable_specification (self )
476
485
return super ().to_json (zarr_format ) # type: ignore[return-value]
477
486
478
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
479
- raise NotImplementedError
480
-
481
487
482
488
class Zstd (_NumcodecsBytesBytesCodec ):
483
489
codec_name = "numcodecs.zstd"
@@ -566,9 +572,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
566
572
return type (self )(** {** self .codec_config , "elementsize" : dtype .itemsize })
567
573
return self # pragma: no cover
568
574
569
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
570
- raise NotImplementedError
571
-
572
575
573
576
# array-to-array codecs ("filters")
574
577
class Delta (_NumcodecsArrayArrayCodec ):
@@ -595,9 +598,6 @@ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
595
598
return replace (chunk_spec , dtype = dtype )
596
599
return chunk_spec
597
600
598
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
599
- raise NotImplementedError
600
-
601
601
602
602
class BitRound (_NumcodecsArrayArrayCodec ):
603
603
codec_name = "numcodecs.bitround"
@@ -612,9 +612,6 @@ def to_json(self, zarr_format: ZarrFormat) -> BitRoundJSON_V2 | BitRoundJSON_V3:
612
612
_warn_unstable_specification (self )
613
613
return super ().to_json (zarr_format ) # type: ignore[return-value]
614
614
615
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
616
- raise NotImplementedError
617
-
618
615
619
616
class FixedScaleOffset (_NumcodecsArrayArrayCodec ):
620
617
codec_name = "numcodecs.fixedscaleoffset"
@@ -641,9 +638,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
641
638
return type (self )(** {** self .codec_config , "dtype" : str (dtype )})
642
639
return self
643
640
644
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
645
- raise NotImplementedError
646
-
647
641
648
642
class Quantize (_NumcodecsArrayArrayCodec ):
649
643
codec_name = "numcodecs.quantize"
@@ -664,9 +658,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
664
658
return type (self )(** {** self .codec_config , "dtype" : str (dtype )})
665
659
return self
666
660
667
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
668
- raise NotImplementedError
669
-
670
661
671
662
class PackBits (_NumcodecsArrayArrayCodec ):
672
663
codec_name = "numcodecs.packbits"
@@ -696,9 +687,6 @@ def validate(self, *, dtype: ZDType[Any, Any], **_kwargs: Any) -> None:
696
687
if _dtype != np .dtype ("bool" ):
697
688
raise ValueError (f"Packbits filter requires bool dtype. Got { dtype } ." )
698
689
699
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
700
- raise NotImplementedError
701
-
702
690
703
691
class AsType (_NumcodecsArrayArrayCodec ):
704
692
codec_name = "numcodecs.astype"
@@ -724,9 +712,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
724
712
return AsType (** {** self .codec_config , "decode_dtype" : str (dtype )}) # pragma: no cover
725
713
return self
726
714
727
- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
728
- raise NotImplementedError
729
-
730
715
731
716
# bytes-to-bytes checksum codecs
732
717
class _NumcodecsChecksumCodec (_NumcodecsBytesBytesCodec ):
0 commit comments