Skip to content

Commit

Permalink
Merge pull request #1396 from NelleV/pep8_colors
Browse files Browse the repository at this point in the history
PEP8 fixes on colors
  • Loading branch information
dmcdougall committed Nov 7, 2012
2 parents 5bcd2d2 + 78bde28 commit 819c2d8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/matplotlib/colors.py
Expand Up @@ -307,7 +307,7 @@ def to_rgb(self, arg):
raise ValueError(
'sequence length is %d; must be 3 or 4' % len(arg))
color = tuple(arg[:3])
if [x for x in color if (float(x) < 0) or (x > 1)]:
if [x for x in color if (float(x) < 0) or (x > 1)]:
# This will raise TypeError if x is not a number.
raise ValueError(
'number in rbg sequence outside 0-1 range')
Expand Down Expand Up @@ -344,7 +344,7 @@ def to_rgba(self, arg, alpha=None):
try:
if not cbook.is_string_like(arg) and cbook.iterable(arg):
if len(arg) == 4:
if [x for x in arg if (float(x) < 0) or (x > 1)]:
if [x for x in arg if (float(x) < 0) or (x > 1)]:
# This will raise TypeError if x is not a number.
raise ValueError(
'number in rbga sequence outside 0-1 range')
Expand All @@ -354,7 +354,7 @@ def to_rgba(self, arg, alpha=None):
raise ValueError("alpha must be in range 0-1")
return arg[0], arg[1], arg[2], alpha
r, g, b = arg[:3]
if [x for x in (r, g, b) if (float(x) < 0) or (x > 1)]:
if [x for x in (r, g, b) if (float(x) < 0) or (x > 1)]:
raise ValueError(
'number in rbg sequence outside 0-1 range')
else:
Expand Down Expand Up @@ -1254,23 +1254,23 @@ def shade_rgb(self, rgb, elevation, fraction=1.):
hsv[:, :, 1] = np.where(np.logical_and(
np.abs(hsv[:, :, 1]) > 1.e-10,
intensity > 0),
(1. - intensity) * hsv[:, :, 1] + \
(1. - intensity) * hsv[:, :, 1] +
intensity * self.hsv_max_sat,
hsv[:, :, 1])

hsv[:, :, 2] = np.where(intensity > 0,
(1. - intensity) * hsv[:, :, 2] + \
(1. - intensity) * hsv[:, :, 2] +
intensity * self.hsv_max_val,
hsv[:, :, 2])

hsv[:, :, 1] = np.where(np.logical_and(
np.abs(hsv[:, :, 1]) > 1.e-10,
intensity < 0),
(1. + intensity) * hsv[:, :, 1] - \
(1. + intensity) * hsv[:, :, 1] -
intensity * self.hsv_min_sat,
hsv[:, :, 1])
hsv[:, :, 2] = np.where(intensity < 0,
(1. + intensity) * hsv[:, :, 2] -\
(1. + intensity) * hsv[:, :, 2] -
intensity * self.hsv_min_val,
hsv[:, :, 2])
hsv[:, :, 1:] = np.where(hsv[:, :, 1:] < 0., 0, hsv[:, :, 1:])
Expand Down

0 comments on commit 819c2d8

Please sign in to comment.