-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: be more careful about coercing unit-full containers to ndarray #21884
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
Conversation
783c822
to
2024498
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that this patch
- fixes the addressed issue
- fixes unyt's failing test
- doesn't cause new test failures in unyt
thank you very much for this patch !
Ooops, I guess this is broken somewhere...
075223d
to
bd9af84
Compare
bd9af84
to
d52c2e8
Compare
@efiring @dopplershift can you review this (pinging you based on timezone ;) ) so @QuLogic can get 3.5.1 out tonight? I would also leave this to @QuLogic 's discretion to merge on one (his) review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable. I think it would work for Pint, but honestly I haven't had need for errorbars, so I've never tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested clarification of docstring and comments need not delay merging.
|
||
If the units are carried on the values then casting to object | ||
arrays preserves the units, but if the units are on the containers | ||
this will not work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the docstring confusing, mixing the what and the why in a way that I can't sort out.
I suggest simply stating what it does under each case it handles.
""" | ||
|
||
# we are here because we the container is not a numpy array, but it | ||
# _is_ iterable (likely a list or a tuple but maybe something more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But at this point you don't know it is iterable--you check it. If it is not iterable, you still wrap it in an object array.
# you can not directly pass data to the init of `np.ndarray` | ||
if atype is np.ndarray: | ||
return np.asarray(err, dtype=object) | ||
# but you can for unyt and astropy uints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astropy "units", I presume
…t-full containers to ndarray
…884-on-v3.5.x Backport PR #21884 on branch v3.5.x (FIX: be more careful about coercing unit-full containers to ndarray)
PR Summary
closes #21669
Tested manually locally via:
We do not currently have any tests of errorbar + units, in interest of getting 3.5.1 out with this fix and the colorbar fixes I move we merge this without a test and kick this particular technical debt can down the road as making sure we have good test coverage is in-scope for the NASA grant.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).