@@ -421,6 +421,9 @@ def _encode(self, chunk_data: Buffer, prototype: BufferPrototype) -> Buffer:
421421 async def _encode_single (self , chunk_data : Buffer , chunk_spec : ArraySpec ) -> Buffer :
422422 return await asyncio .to_thread (self ._encode , chunk_data , chunk_spec .prototype )
423423
424+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
425+ raise NotImplementedError
426+
424427
425428class _NumcodecsArrayArrayCodec (_NumcodecsCodec , ArrayArrayCodec ):
426429 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
433436 out = await asyncio .to_thread (self ._codec .encode , chunk_ndarray )
434437 return chunk_spec .prototype .nd_buffer .from_ndarray_like (out )
435438
439+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
440+ raise NotImplementedError
441+
436442
437443class _NumcodecsArrayBytesCodec (_NumcodecsCodec , ArrayBytesCodec ):
438444 def __init__ (self , ** codec_config : JSON ) -> None :
@@ -448,6 +454,9 @@ async def _encode_single(self, chunk_data: NDBuffer, chunk_spec: ArraySpec) -> B
448454 out = await asyncio .to_thread (self ._codec .encode , chunk_ndarray )
449455 return chunk_spec .prototype .buffer .from_bytes (out )
450456
457+ def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
458+ raise NotImplementedError
459+
451460
452461# bytes-to-bytes codecs
453462class Blosc (_NumcodecsBytesBytesCodec ):
@@ -475,9 +484,6 @@ def to_json(self, zarr_format: ZarrFormat) -> LZ4JSON_V2 | LZ4JSON_V3:
475484 _warn_unstable_specification (self )
476485 return super ().to_json (zarr_format ) # type: ignore[return-value]
477486
478- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
479- raise NotImplementedError
480-
481487
482488class Zstd (_NumcodecsBytesBytesCodec ):
483489 codec_name = "numcodecs.zstd"
@@ -566,9 +572,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
566572 return type (self )(** {** self .codec_config , "elementsize" : dtype .itemsize })
567573 return self # pragma: no cover
568574
569- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
570- raise NotImplementedError
571-
572575
573576# array-to-array codecs ("filters")
574577class Delta (_NumcodecsArrayArrayCodec ):
@@ -595,9 +598,6 @@ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
595598 return replace (chunk_spec , dtype = dtype )
596599 return chunk_spec
597600
598- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
599- raise NotImplementedError
600-
601601
602602class BitRound (_NumcodecsArrayArrayCodec ):
603603 codec_name = "numcodecs.bitround"
@@ -612,9 +612,6 @@ def to_json(self, zarr_format: ZarrFormat) -> BitRoundJSON_V2 | BitRoundJSON_V3:
612612 _warn_unstable_specification (self )
613613 return super ().to_json (zarr_format ) # type: ignore[return-value]
614614
615- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
616- raise NotImplementedError
617-
618615
619616class FixedScaleOffset (_NumcodecsArrayArrayCodec ):
620617 codec_name = "numcodecs.fixedscaleoffset"
@@ -641,9 +638,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
641638 return type (self )(** {** self .codec_config , "dtype" : str (dtype )})
642639 return self
643640
644- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
645- raise NotImplementedError
646-
647641
648642class Quantize (_NumcodecsArrayArrayCodec ):
649643 codec_name = "numcodecs.quantize"
@@ -664,9 +658,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> Self:
664658 return type (self )(** {** self .codec_config , "dtype" : str (dtype )})
665659 return self
666660
667- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
668- raise NotImplementedError
669-
670661
671662class PackBits (_NumcodecsArrayArrayCodec ):
672663 codec_name = "numcodecs.packbits"
@@ -696,9 +687,6 @@ def validate(self, *, dtype: ZDType[Any, Any], **_kwargs: Any) -> None:
696687 if _dtype != np .dtype ("bool" ):
697688 raise ValueError (f"Packbits filter requires bool dtype. Got { dtype } ." )
698689
699- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
700- raise NotImplementedError
701-
702690
703691class AsType (_NumcodecsArrayArrayCodec ):
704692 codec_name = "numcodecs.astype"
@@ -724,9 +712,6 @@ def evolve_from_array_spec(self, array_spec: ArraySpec) -> AsType:
724712 return AsType (** {** self .codec_config , "decode_dtype" : str (dtype )}) # pragma: no cover
725713 return self
726714
727- def compute_encoded_size (self , input_byte_length : int , chunk_spec : ArraySpec ) -> int :
728- raise NotImplementedError
729-
730715
731716# bytes-to-bytes checksum codecs
732717class _NumcodecsChecksumCodec (_NumcodecsBytesBytesCodec ):
0 commit comments