Skip to content

Commit 15b9374

Browse files
authored
Don't assume float32 input for JPEG2000 (#58)
* Don't assume float32 input for JPEG2000 * Cleaner way to get dtype name
1 parent 7f33a2a commit 15b9374

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/climatebenchpress/compressor/compressors

src/climatebenchpress/compressor/compressors/jpeg2000.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ def abs_bound_codec(
3636
*,
3737
data_min=None,
3838
data_max=None,
39+
dtype=None,
3940
**kwargs,
4041
):
4142
assert data_min is not None, "data_min must be provided"
4243
assert data_max is not None, "data_max must be provided"
44+
assert dtype is not None, "dtype must be provided"
4345

4446
max_pixel_val = 2**25 - 1 # maximum pixel value for our integer encoding.
4547

@@ -56,7 +58,7 @@ def abs_bound_codec(
5658
# increase precision for better rounding during linear quantization
5759
numcodecs.astype.AsType(
5860
encode_dtype="float64",
59-
decode_dtype="float32",
61+
decode_dtype=dtype.name,
6062
),
6163
# remap from [min, max] to [0, max_pixel_val]
6264
numcodecs_wasm_fixed_offset_scale.FixedOffsetScale(

0 commit comments

Comments
 (0)