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

Skip to content

Commit 9228480

Browse files
committed
Reflect on reviews
1 parent 2573610 commit 9228480

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,7 +4044,8 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
40444044

40454045
if colors is None:
40464046
if norm is not None and not isinstance(norm, mcolors.Normalize):
4047-
msg = "'norm' must be an instance of 'mcolors.Normalize'"
4047+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
4048+
"'mcolors.BivariateNorm'")
40484049
raise ValueError(msg)
40494050
collection.set_array(np.asarray(c))
40504051
collection.set_cmap(cmap)
@@ -4403,7 +4404,8 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
44034404
accum = bins.searchsorted(accum)
44044405

44054406
if norm is not None and not isinstance(norm, mcolors.Normalize):
4406-
msg = "'norm' must be an instance of 'mcolors.Normalize'"
4407+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
4408+
"'mcolors.BivariateNorm'")
44074409
raise ValueError(msg)
44084410
collection.set_array(accum)
44094411
collection.set_cmap(cmap)
@@ -5141,8 +5143,8 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
51415143
self.cla()
51425144

51435145
if norm is not None and not isinstance(norm, mcolors.Norms):
5144-
msg = "'norm' must be an instance of 'mcolors.Normalize' " \
5145-
"or 'mcolors.BivariateNorm'"
5146+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
5147+
"'mcolors.BivariateNorm'")
51465148
raise ValueError(msg)
51475149

51485150
if aspect is None:
@@ -5193,9 +5195,9 @@ def _pcolorargs(funcname, *args, **kw):
51935195

51945196
if len(args) == 1:
51955197
C = np.asanyarray(args[0])
5196-
isBivari = (isinstance(norm, mcolors.BivariateNorm)
5197-
or isinstance(cmap, mcolors.BivariateColormap))
5198-
if (C.ndim == 3 and isBivari):
5198+
is_bivari = (isinstance(norm, mcolors.BivariateNorm) or
5199+
isinstance(cmap, mcolors.BivariateColormap))
5200+
if (C.ndim == 3 and is_bivari):
51995201
if cmap is None:
52005202
cmap = mcolors.BivariateColormap()
52015203
if norm is None:
@@ -5213,9 +5215,9 @@ def _pcolorargs(funcname, *args, **kw):
52135215

52145216
if len(args) == 3:
52155217
X, Y, C = [np.asanyarray(a) for a in args]
5216-
isBivari = (isinstance(norm, mcolors.BivariateNorm)
5217-
or isinstance(cmap, mcolors.BivariateColormap))
5218-
if (C.ndim == 3 and isBivari):
5218+
is_bivari = (isinstance(norm, mcolors.BivariateNorm) or
5219+
isinstance(cmap, mcolors.BivariateColormap))
5220+
if (C.ndim == 3 and is_bivari):
52195221
if cmap is None:
52205222
cmap = mcolors.BivariateColormap()
52215223
if norm is None:
@@ -5486,8 +5488,8 @@ def pcolor(self, *args, **kwargs):
54865488
collection.set_array(C)
54875489

54885490
if norm is not None and not isinstance(norm, mcolors.Norms):
5489-
msg = "'norm' must be an instance of 'mcolors.Normalize' " \
5490-
"or 'mcolors.BivariateNorm'"
5491+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
5492+
"'mcolors.BivariateNorm'")
54915493
raise ValueError(msg)
54925494

54935495
collection.set_cmap(cmap)
@@ -5642,7 +5644,8 @@ def pcolormesh(self, *args, **kwargs):
56425644
collection.set_alpha(alpha)
56435645
collection.set_array(C)
56445646
if norm is not None and not isinstance(norm, mcolors.Norms):
5645-
msg = "'norm' must be an instance of 'mcolors.Normalize'"
5647+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
5648+
"'mcolors.BivariateNorm'")
56465649
raise ValueError(msg)
56475650
collection.set_cmap(cmap)
56485651
collection.set_norm(norm)
@@ -5767,15 +5770,15 @@ def pcolorfast(self, *args, **kwargs):
57675770
vmax = kwargs.pop('vmax', None)
57685771

57695772
if norm is not None and not isinstance(norm, mcolors.Norms):
5770-
msg = "'norm' must be an instance of 'mcolors.Normalize' " \
5771-
"or 'mcolors.BivariateNorm'"
5773+
msg = ("'norm' must be an instance of 'mcolors.Normalize' or "
5774+
"'mcolors.BivariateNorm'")
57725775
raise ValueError(msg)
57735776

57745777
C = np.asarray(args[-1])
57755778

5776-
isBivari = (isinstance(norm, mcolors.BivariateNorm)
5777-
or isinstance(cmap, mcolors.BivariateColormap))
5778-
if (C.ndim == 3 and isBivari):
5779+
is_bivari = (isinstance(norm, mcolors.BivariateNorm) or
5780+
isinstance(cmap, mcolors.BivariateColormap))
5781+
if (C.ndim == 3 and is_bivari):
57795782
nr, nc = C.shape[1:]
57805783
else:
57815784
nr, nc = C.shape

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,8 +1152,8 @@ def _edges(self, X, Y):
11521152
Return the separator line segments; helper for _add_solids.
11531153
'''
11541154
N = X.shape[0]
1155-
return [list(zip(X[i], Y[i])) for i in xrange(1, N - 1)]
1156-
+ [list(zip(Y[i], X[i])) for i in xrange(1, N - 1)]
1155+
return ([list(zip(X[i], Y[i])) for i in xrange(1, N - 1)] +
1156+
[list(zip(Y[i], X[i])) for i in xrange(1, N - 1)])
11571157

11581158
def _add_solids(self, X, Y, C):
11591159
"""

lib/matplotlib/colors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,14 +888,14 @@ def _resample(self, lutsize):
888888
return BivariateColormap(self.name, lutsize)
889889

890890
def reversed(self, name=None):
891-
raise NotImplementedError()
891+
raise NotImplementedError
892892

893893

894+
@six.add_metaclass(ABCMeta)
894895
class Norms:
895896
"""
896897
Abstract Base Class to group `Normalize` and `BivariateNorm`
897898
"""
898-
__metaclass__ = ABCMeta
899899
pass
900900

901901

lib/matplotlib/tests/test_colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,4 +718,4 @@ def test_abstract_base_class_norms(norm):
718718
Test that all types of normalizers subclasses Abstract Base class
719719
`colors.Norms`
720720
"""
721-
assert isinstance(norm, mcolors.Norms)
721+
assert isinstance(norm, mcolors.Norms)

0 commit comments

Comments
 (0)