Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 68ad0c4

Browse files
committed
TST: minor tweaks to tests
- add a cleanup decorator out of paranoia - deepcopy rather than copy colormaps that we mutate
1 parent 80909e5 commit 68ad0c4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from numpy.testing import (
2525
assert_array_equal, assert_array_almost_equal, assert_allclose)
2626
from matplotlib.testing.noseclasses import KnownFailureTest
27-
from copy import copy
27+
from copy import deepcopy
2828
from numpy import ma
2929
import matplotlib.image as mimage
3030
import matplotlib.colors as colors
@@ -155,6 +155,7 @@ def test_imsave():
155155

156156
assert_array_equal(arr_dpi1, arr_dpi100)
157157

158+
@cleanup
158159
def test_imsave_color_alpha():
159160
# Test that imsave accept arrays with ndim=3 where the third dimension is
160161
# color and alpha without raising any exceptions, and that the data is
@@ -698,7 +699,7 @@ def test_mask_image_over_under():
698699
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
699700
Z = 10*(Z2 - Z1) # difference of Gaussians
700701

701-
palette = copy(plt.cm.gray)
702+
palette = deepcopy(plt.cm.gray)
702703
palette.set_over('r', 1.0)
703704
palette.set_under('g', 1.0)
704705
palette.set_bad('b', 1.0)
@@ -761,7 +762,7 @@ def test_imshow_endianess():
761762
remove_text=True, style='default')
762763
def test_imshow_masked_interpolation():
763764

764-
cm = copy(plt.get_cmap('viridis'))
765+
cm = deepcopy(plt.get_cmap('viridis'))
765766
cm.set_over('r')
766767
cm.set_under('b')
767768
cm.set_bad('k')

0 commit comments

Comments
 (0)