-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add NetCDF3 dtype coercion for unsigned integer types #4018
Add NetCDF3 dtype coercion for unsigned integer types #4018
Conversation
This might be a bit too general for what is required at this point, though ... 🤔
Currently, the error that is raised by A test could look something like this: def test_dtype_coercion_error(self):
for dtype in _nc3_dtype_coercions:
if dtype == "bool":
continue
# Create some data that cannot be coerced (cause it's a downcast)
dtype = np.dtype(dtype)
maxval = np.iinfo(dtype).max
x = np.array([0, 1, 2, maxval], dtype=dtype)
test_data = Dataset({"x": ("t", x, {})})
# Make sure a roundtrip fails
with pytest.raises(ValueError, match="could not safely cast"):
self.roundtrip(test_data) ... but I'm not sure ...
|
@dcherian I think this would be ready for review now. I'd appreciate some guidance on the implementation of the tests; see above. |
If you are up for it, we'd love to add testing for that error in this PR. I think |
Also uses a class variable for definition of netcdf3 formats now.
Alright, I added the test. From my side, this would be ready. :) Let me know if further changes to the tests or What's New are necessary. |
LGTM. Thanks @blsqr |
Yay. Thanks @blsqr. I see this is your first PR. welcome! |
Thanks, @dcherian! I'm happy to contribute 😊 |
This PR addresses #4014.
int64
coercion played a roleisort -rc . && black . && mypy . && flake8
whats-new.rst
for all changesandapi.rst
for new API