With the release of numpy 2.0 adopting NEP 50 by default, type promotion has changed and any attempts to coerce python scalar values into data types that can't represent that value now raise an OverflowError.
Before, if you had a dtype of uint8 the fill value would wind up being 241 after overflowing.
I recommend creating a more sophisticated mapping of appropriate fill values based on dtypes:
uint8 - 255
int8 - -128
...
float32 - nan
float64 - nan
datetime64 - nan (depends on context... numpy supported contexts are NaT, float-only contexts would be NaN)
I'll try to take a look at a PR if I can find the time.
https://numpy.org/neps/nep-0050-scalar-promotion.html#nep50
https://github.com/pyoceans/pocean-core/blob/acd977bb3b513fd7338e33aefb7937c6ab47b653/pocean/utils.py#L305
https://github.com/pyoceans/pocean-core/blob/acd977bb3b513fd7338e33aefb7937c6ab47b653/pocean/cf.py#L14
With the release of numpy 2.0 adopting NEP 50 by default, type promotion has changed and any attempts to coerce python scalar values into data types that can't represent that value now raise an
OverflowError
.Before, if you had a dtype of
uint8
the fill value would wind up being241
after overflowing.I recommend creating a more sophisticated mapping of appropriate fill values based on dtypes:
uint8
-255
int8
--128
float32
-nan
float64
-nan
datetime64
-nan
(depends on context... numpy supported contexts are NaT, float-only contexts would be NaN)I'll try to take a look at a PR if I can find the time.