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

Skip to content

Commit bd1a68a

Browse files
committed
Merge branch 'v1.4.x' into master
Conflicts: lib/matplotlib/tests/test_coding_standards.py lib/matplotlib/tests/test_text.py - PEP8 conflicts in test_text.py - conflicts in test_coding_standards due to removal of test_text.py from list of known bad files which was moved around in the file.
2 parents d4f8657 + 6963e0c commit bd1a68a

File tree

8 files changed

+287
-94
lines changed

8 files changed

+287
-94
lines changed

lib/matplotlib/colors.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,16 +1177,18 @@ def __call__(self, value, clip=None):
11771177
elif vmin == vmax:
11781178
result.fill(0)
11791179
else:
1180+
res_mask = result.data < 0
11801181
if clip:
11811182
mask = ma.getmask(result)
1182-
val = ma.array(np.clip(result.filled(vmax), vmin, vmax),
1183-
mask=mask)
1183+
result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
1184+
mask=mask)
11841185
resdat = result.data
11851186
resdat -= vmin
11861187
np.power(resdat, gamma, resdat)
11871188
resdat /= (vmax - vmin) ** gamma
1189+
11881190
result = np.ma.array(resdat, mask=result.mask, copy=False)
1189-
result[value < 0] = 0
1191+
result[res_mask] = 0
11901192
if is_scalar:
11911193
result = result[0]
11921194
return result

lib/matplotlib/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self, ax,
114114
def __getstate__(self):
115115
state = super(_AxesImageBase, self).__getstate__()
116116
# We can't pickle the C Image cached object.
117-
state.pop('_imcache', None)
117+
state['_imcache'] = None
118118
return state
119119

120120
def get_size(self):

lib/matplotlib/tests/test_coding_standards.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ def test_pep8_conformance_installed_files():
214214
'tests/test_spines.py',
215215
'tests/test_streamplot.py',
216216
'tests/test_subplots.py',
217-
'tests/test_text.py',
218217
'tests/test_tightlayout.py',
219218
'tests/test_transforms.py',
220219
'tests/test_triangulation.py',

lib/matplotlib/tests/test_colors.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import itertools
66
from distutils.version import LooseVersion as V
77

8-
from nose.tools import assert_raises
8+
from nose.tools import assert_raises, assert_equal
99

1010
import numpy as np
1111
from numpy.testing.utils import assert_array_equal, assert_array_almost_equal
@@ -66,11 +66,29 @@ def test_PowerNorm():
6666
assert_array_almost_equal(norm(a), pnorm(a))
6767

6868
a = np.array([-0.5, 0, 2, 4, 8], dtype=np.float)
69-
expected = [0, 0, 1./16, 1./4, 1]
69+
expected = [0, 0, 1/16, 1/4, 1]
7070
pnorm = mcolors.PowerNorm(2, vmin=0, vmax=8)
7171
assert_array_almost_equal(pnorm(a), expected)
72+
assert_equal(pnorm(a[0]), expected[0])
73+
assert_equal(pnorm(a[2]), expected[2])
7274
assert_array_almost_equal(a[1:], pnorm.inverse(pnorm(a))[1:])
7375

76+
# Clip = True
77+
a = np.array([-0.5, 0, 1, 8, 16], dtype=np.float)
78+
expected = [0, 0, 0, 1, 1]
79+
pnorm = mcolors.PowerNorm(2, vmin=2, vmax=8, clip=True)
80+
assert_array_almost_equal(pnorm(a), expected)
81+
assert_equal(pnorm(a[0]), expected[0])
82+
assert_equal(pnorm(a[-1]), expected[-1])
83+
84+
# Clip = True at call time
85+
a = np.array([-0.5, 0, 1, 8, 16], dtype=np.float)
86+
expected = [0, 0, 0, 1, 1]
87+
pnorm = mcolors.PowerNorm(2, vmin=2, vmax=8, clip=False)
88+
assert_array_almost_equal(pnorm(a, clip=True), expected)
89+
assert_equal(pnorm(a[0], clip=True), expected[0])
90+
assert_equal(pnorm(a[-1], clip=True), expected[-1])
91+
7492

7593
def test_Normalize():
7694
norm = mcolors.Normalize()

0 commit comments

Comments
 (0)