Skip to content

Commit af6eef9

Browse files
committed
fix json deserialization for fixed scale offset
1 parent 90666ea commit af6eef9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/zarr/codecs/numcodecs/fixed_scale_offset.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ def to_json(self, zarr_format: Literal[2]) -> FixedScaleOffsetJSON_V2: ...
101101
def to_json(self, zarr_format: Literal[3]) -> FixedScaleOffsetJSON_V3: ...
102102
def to_json(self, zarr_format: ZarrFormat) -> FixedScaleOffsetJSON_V2 | FixedScaleOffsetJSON_V3:
103103
_warn_unstable_specification(self)
104-
return super().to_json(zarr_format) # type: ignore[return-value]
104+
if zarr_format == 2:
105+
return super().to_json(zarr_format) # type: ignore[return-value]
106+
return {
107+
"name": "fixedscaleoffset",
108+
"configuration": {
109+
"astype": parse_dtype(self.codec_config["astype"], zarr_format=2).to_json(zarr_format=3),
110+
"dtype": parse_dtype(self.codec_config["dtype"], zarr_format=2).to_json(zarr_format=3),
111+
"scale": self.codec_config["scale"],
112+
"offset": self.codec_config["offset"]}}
105113

106114
@classmethod
107115
def _from_json_v2(cls, data: CodecJSON_V2) -> Self:

0 commit comments

Comments
 (0)