Repository navigation
FIX: be more careful about coercing unit-full containers to ndarray - #21884
Conversation
783c822 to
2024498
Compare
neutrinoceros
left a comment
There was a problem hiding this comment.
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. |
dopplershift
left a comment
There was a problem hiding this comment.
This seems reasonable. I think it would work for Pint, but honestly I haven't had need for errorbars, so I've never tested.
efiring
left a comment
There was a problem hiding this comment.
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.
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.
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 |
…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
pytestpasses).flake8-docstringsand 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).