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 b722810

Browse filesBrowse files
authored
Merge pull request matplotlib#9146 from tacaswell/fix_bool_imshow
FIX: cast max/min to scaled dtype
2 parents 731909b + c06610a commit b722810
Copy full SHA for b722810

File tree

Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ def _make_image(self, A, in_bbox, out_bbox, clip_bbox, magnification=1.0,
367367
scaled_dtype = np.float32
368368
# old versions of numpy do not work with `np.nammin`
369369
# and `np.nanmax` as inputs
370-
a_min = np.ma.min(A)
371-
a_max = np.ma.max(A)
370+
a_min = np.ma.min(A).astype(scaled_dtype)
371+
a_max = np.ma.max(A).astype(scaled_dtype)
372372
# scale the input data to [.1, .9]. The Agg
373373
# interpolators clip to [0, 1] internally, use a
374374
# smaller input scale to identify which of the

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,3 +802,8 @@ def test_empty_imshow():
802802
def test_imshow_float128():
803803
fig, ax = plt.subplots()
804804
ax.imshow(np.zeros((3, 3), dtype=np.longdouble))
805+
806+
807+
def test_imshow_bool():
808+
fig, ax = plt.subplots()
809+
ax.imshow(np.array([[True, False], [False, True]], dtype=bool))

0 commit comments

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