Make TaggedValue in basic_units a sequence#19415
Merged
tacaswell merged 1 commit intomatplotlib:masterfrom Feb 1, 2021
Merged
Conversation
1da66db to
3b3cd60
Compare
jklymak
approved these changes
Feb 1, 2021
Member
|
This fixed the example with NumPy 1.20, but broke it with older versions, specifically 1.18.1. |
QuLogic
added a commit
to QuLogic/matplotlib
that referenced
this pull request
Feb 18, 2021
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 matplotlib#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,).
3 tasks
tacaswell
pushed a commit
to QuLogic/matplotlib
that referenced
this pull request
Mar 24, 2021
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 matplotlib#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,).
QuLogic
added a commit
to QuLogic/matplotlib
that referenced
this pull request
Mar 25, 2021
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 matplotlib#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,).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is needed to avoid a deprecation warning with numpy 1.20, and fixes the doc build.
See https://numpy.org/doc/stable/release/1.20.0-notes.html#arraylike-objects-which-do-not-define-len-and-getitem for more information. Essentially,
__len__and__getitem__needed to be implemented for numpy to recognise the class as a sequence.