8000 Improve test for correct clipping · matplotlib/matplotlib@e05a632 · GitHub
[go: up one dir, main page]

Skip to content

Commit e05a632

Browse files
committed
Improve test for correct clipping
1 parent 068fa28 commit e05a632

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,18 @@ def test_imshow_clips_rgb_to_valid_range(dtype):
801801
arr = np.arange(300, dtype=dtype).reshape((10, 10, 3))
802802
if dtype.kind != 'u':
803803
arr -= 10
804+
too_low = arr < 0
805+
too_high = arr > 255
804806
if dtype.kind == 'f':
805807
arr = arr / 255
806808
_, ax = plt.subplots()
807809
out = ax.imshow(arr).get_array()
808-
assert out.min() == 0
810+
assert (out[too_low] == 0).all()
809811
if dtype.kind == 'f':
810-
assert out.max() == 1
812+
assert (out[too_high] == 1).all()
811813
assert out.dtype.kind == 'f'
812814
else:
813-
assert out.max() == 255
815+
assert (out[too_high] == 255).all()
814816
assert out.dtype == np.uint8
815817

816818

0 commit comments

Comments
 (0)
0