8000 Merge pull request #10289 from ngoldbaum/imshow-unit-array · matplotlib/matplotlib@c281ccf · GitHub
[go: up one dir, main page]

Skip to content

Commit c281ccf

Browse files
authored
Merge pull request #10289 from ngoldbaum/imshow-unit-array
Ensure image scale factors are scalars
2 parents 19c2e78 + 5d15e7c commit c281ccf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,10 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
394394
A_scaled = np.empty(A.shape, dtype=scaled_dtype)
395395
A_scaled[:] = A
396396
A_scaled -= a_min
397-
a_min = a_min.astype(scaled_dtype)
398-
a_max = a_max.astype(scaled_dtype)
397+
# a_min and a_max might be ndarray subclasses so use
398+
# asscalar to ensure they are scalars to avoid errors
399+
a_min = np.asscalar(a_min.astype(scaled_dtype))
400+
a_max = np.asscalar(a_max.astype(scaled_dtype))
399401

400402
if a_min != a_max:
401403
A_scaled /= ((a_max - a_min) / 0.8)

0 commit comments

Comments
 (0)
0