Skip to content

Commit 10e1158

Browse files
committed
Don't overwrite codec config values when set.
A codec doesn't know where it is in the codec pipeline, so it cannot know whether `array_spec.dtype` should match `codec.dtype` or not.
1 parent 8d15c02 commit 10e1158

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

numcodecs/zarr3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def __init__(self, **codec_config: JSON) -> None:
271271
super().__init__(**codec_config)
272272

273273
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Shuffle:
274-
if array_spec.dtype.itemsize != self.codec_config.get("elementsize"):
274+
if self.codec_config.get("elementsize", None) is None:
275275
return Shuffle(**{**self.codec_config, "elementsize": array_spec.dtype.itemsize})
276276
return self # pragma: no cover
277277

@@ -308,7 +308,7 @@ def resolve_metadata(self, chunk_spec: ArraySpec) -> ArraySpec:
308308
return chunk_spec
309309

310310
def evolve_from_array_spec(self, array_spec: ArraySpec) -> FixedScaleOffset:
311-
if str(array_spec.dtype) != self.codec_config.get("dtype"):
311+
if self.codec_config.get("dtype") is None:
312312
return FixedScaleOffset(**{**self.codec_config, "dtype": str(array_spec.dtype)})
313313
return self
314314

@@ -321,7 +321,7 @@ def __init__(self, **codec_config: JSON) -> None:
321321
super().__init__(**codec_config)
322322

323323
def evolve_from_array_spec(self, array_spec: ArraySpec) -> Quantize:
324-
if str(array_spec.dtype) != self.codec_config.get("dtype"):
324+
if self.codec_config.get("dtype") is None:
325325
return Quantize(**{**self.codec_config, "dtype": str(array_spec.dtype)})
326326
return self
327327

0 commit comments

Comments
 (0)