@@ -319,7 +319,7 @@ def _choose_float_dtype(dtype: np.dtype, has_offset: bool) -> type[np.floating[A
319
319
320
320
321
321
def _ensure_scale_offset_conformance (
322
- mapping : MutableMapping , strict : bool = False
322
+ mapping : MutableMapping [ str , Any ] , strict : bool = False
323
323
) -> bool | None :
324
324
"""Check conformance of scale_factor and add_offset for cf encoding/decoding.
325
325
@@ -365,12 +365,10 @@ def _ensure_scale_offset_conformance(
365
365
if len (scale_offset_dtype ) == 1 :
366
366
# OK, we have at least one of scale_factor or add_offset
367
367
# and if both are given, they are of the same dtype
368
- scale_offset_dtype = scale_offset_dtype [0 ]
369
-
370
- if scale_offset_dtype != ptype :
371
- if scale_offset_dtype not in [np .float32 , np .float64 ]:
368
+ if scale_offset_dtype [0 ] != ptype :
369
+ if scale_offset_dtype [0 ] not in [np .float32 , np .float64 ]:
372
370
msg = (
373
- f"scale_factor and/or add_offset dtype { scale_offset_dtype } "
371
+ f"scale_factor and/or add_offset dtype { scale_offset_dtype [ 0 ] } "
374
372
"mismatch. Must be either float32 or float64 dtype."
375
373
)
376
374
if strict :
@@ -389,7 +387,7 @@ def _ensure_scale_offset_conformance(
389
387
else :
390
388
warnings .warn (msg , SerializationWarning , stacklevel = 3 )
391
389
conforms = False
392
- if ptype == np .int32 and scale_offset_dtype == np .float32 :
390
+ if ptype == np .int32 and scale_offset_dtype [ 0 ] == np .float32 :
393
391
warnings .warn (
394
392
"Trying to pack float32 into int32. This is not advised per CF Convention "
395
393
"because of potential precision loss!" ,
0 commit comments