Skip to content

Commit fac9556

Browse files
committed
multivar imshow additional test
1 parent fdb3725 commit fac9556

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎lib/matplotlib/colorizer.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def get_clim(self):
280280
281281
This function always returns min and max as tuples to ensure type consistency
282282
when working with both scalar and multivariate color mapping.
283-
See also `.ColorizingArtist.get_clim()` which returns scalars but is unavailable
283+
See also `._ColorizerInterface.get_clim()` which returns scalars but is unavailable
284284
for multivariate color mapping.
285285
"""
286286
if self.norm.n_components == 1:

‎lib/matplotlib/tests/test_colors.py‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,30 @@ def test_colorizer_multinorm_explicit():
22132213
assert_array_almost_equal(ca.to_rgba(data), res)
22142214

22152215

2216+
def test_get_set_clim_raises():
2217+
fig, ax = plt.subplots(1, 1)
2218+
x_0 = np.arange(9, dtype='float32').reshape(3, 3)
2219+
x_1 = np.arange(9, dtype='float32').reshape(3, 3).T
2220+
colorizing_artist = ax.imshow((x_0, x_1), cmap='BiPeak', interpolation='nearest')
2221+
2222+
# test get_clim
2223+
with pytest.raises(AttributeError,
2224+
match=("cannot be used with a multi-component")):
2225+
colorizing_artist.get_clim()
2226+
2227+
res = [[0, 0], [8, 8]]
2228+
assert_array_almost_equal(colorizing_artist.colorizer.get_clim(), res)
2229+
2230+
# test set_clim
2231+
with pytest.raises(AttributeError,
2232+
match=("cannot be used with a multi-component")):
2233+
colorizing_artist.set_clim(vmin=(1, 1))
2234+
2235+
colorizing_artist.colorizer.set_clim(vmin=(2, 2), vmax=(5, 5))
2236+
res = [[2, 2], [5, 5]]
2237+
assert_array_almost_equal(colorizing_artist.colorizer.get_clim(), res)
2238+
2239+
22162240
def test_invalid_cmap_n_components_zero():
22172241
class CustomColormap(mcolors.Colormap):
22182242
def __init__(self):

0 commit comments

Comments
 (0)