Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 60d902f

Browse filesBrowse files
QuLogictacaswell
authored andcommitted
Fix example's BasicUnit array conversion.
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,).
1 parent bfa31a4 commit 60d902f
Copy full SHA for 60d902f

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

‎examples/units/basic_units.py

Copy file name to clipboardExpand all lines: examples/units/basic_units.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def __array_wrap__(self, array, context):
218218
return TaggedValue(array, self)
219219

220220
def __array__(self, t=None, context=None):
221-
ret = np.array([1])
221+
ret = np.array(1)
222222
if t is not None:
223223
return ret.astype(t)
224224
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.