Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix example's BasicUnit array conversion.#19535
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
QuLogic commentedFeb 18, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The remaining failure is:
I am using NumPy 1.18.1/1.18.5. It appears to have fixed itself in 1.19.0.@dstansby |
tacaswell commentedFeb 19, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It seems that our attempts to use a minimum version of numpy is getting foiled on cricle and we are running the minimum version docs build with np 1.20 🤦 . |
Good catch; hopefully this should work to fix that. |
A unit is a scalar, not a length-1 array. Though `BasicUnit` implements`__rmul__`, if multiplying by an array, the NumPy implementation willcall `__array__` instead. If the LHS is an array, everything is fine,but if the LHS is a scalar, the previous code would incorrectly cause itto be upcast to a 1D array. When `__getitem__` was added inmatplotlib#19415,`np.atleast_1d` started iterating each (now 1D, not scalar)`TaggedValue`, seeing it was length 1, and made the x/y arrays into(N, 1) instead of (N,).
On older versions (1.18), this breaks things, so must be skipped.
I looked to see what this example does, but it doesn't do anything except register itself? |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free tosuggest an improvement. |
It's imported by all the other examples in this directory. |
With other backports done, I hope this will work now. @meeseeksdev backport to v3.4.x |
…535-on-v3.4.xBackport PR#19535 on branch v3.4.x (Fix example's BasicUnit array conversion.)
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
The unit examples are broken in NumPy < 1.20. This fixes a bug that was exposed by#19415
, but does not fix the examples fully.radian_demo
is fixed by this change, butellipse_with_units
is still broken. I do not understand the NumPy subclassing methods enough to fix it short of reverting#19415..A unit is a scalar, not a length-1 array. Though
BasicUnit
implements__rmul__
, if multiplying by an array, the NumPy implementation will call__array__
instead. If the LHS is an array, everything is fine, but if the LHS is a scalar, the previous code would incorrectly cause it to be upcast to a 1D array. When__getitem__
was added in#19415,np.atleast_1d
started iterating each (now 1D, not scalar)TaggedValue
, seeing it was length 1, and made the x/y arrays into (N, 1) instead of (N,).PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).