Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't hardcode fill_value #132

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

ocefpaf
Copy link
Member

@ocefpaf ocefpaf commented Feb 4, 2025

Instead of using a float value and relying on old numpy's behavior we will use netCDF4's default fill values:

{'S1': '\x00',
 'i1': -127,
 'u1': 255,
 'i2': -32767,
 'u2': 65535,
 'i4': -2147483647,
 'u4': 4294967295,
 'i8': -9223372036854775806,
 'u8': 18446744073709551614,
 'f4': 9.969209968386869e+36,
 'f8': 9.969209968386869e+36,
 'c8': 9.969209968386869e+36,
 'c16': 9.969209968386869e+36}

This will make pocean-core really numpy 2.0 compliant, even though we didn't catch this one in the tests, and make the data saved smaller and "more consistent" in same cases as the original dtype will be using for the fill value.

@ocefpaf
Copy link
Member Author

ocefpaf commented Feb 4, 2025

I don't see a reason to have a default value, maybe faster writes? If that is true we should check the dtype against netCDF4's defaults. IMO, this solution is "good enough" and will fix some errors we are seeing in ioos-qc when dealing with integers b/c numpy 2.0 won't upcast but will overflow instead.

@ocefpaf ocefpaf merged commit dc8883f into pyoceans:main Feb 4, 2025
18 checks passed
@ocefpaf ocefpaf deleted the do_not_hardcode_fillvalue branch February 4, 2025 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant