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

Skip to content

Commit 11dcf76

Browse files
authored
Merge pull request #9293 from anntzer/cleanup
minor (unrelated) cleanups
2 parents 5eb185f + e12071a commit 11dcf76

File tree

3 files changed

+30
-45
lines changed

3 files changed

+30
-45
lines changed

lib/matplotlib/colors.py

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,17 @@ def __delitem__(self, key):
9090

9191

9292
def get_named_colors_mapping():
93-
"""Return the global mapping of names to named colors.
94-
"""
93+
"""Return the global mapping of names to named colors."""
9594
return _colors_full_map
9695

9796

9897
def _is_nth_color(c):
99-
"""Return whether `c` can be interpreted as an item in the color cycle.
100-
"""
98+
"""Return whether *c* can be interpreted as an item in the color cycle."""
10199
return isinstance(c, six.string_types) and re.match(r"\AC[0-9]\Z", c)
102100

103101

104102
def is_color_like(c):
105-
"""Return whether `c` can be interpreted as an RGB(A) color.
106-
"""
103+
"""Return whether *c* can be interpreted as an RGB(A) color."""
107104
# Special-case nth color syntax because it cannot be parsed during
108105
# setup.
109106
if _is_nth_color(c):
@@ -117,10 +114,10 @@ def is_color_like(c):
117114

118115

119116
def to_rgba(c, alpha=None):
120-
"""Convert `c` to an RGBA color.
117+
"""Convert *c* to an RGBA color.
121118
122-
If `alpha` is not `None`, it forces the alpha value, except if `c` is
123-
"none" (case-insensitive), which always maps to `(0, 0, 0, 0)`.
119+
If *alpha* is not *None*, it forces the alpha value, except if *c* is
120+
``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
124121
"""
125122
# Special-case nth color syntax because it should not be cached.
126123
if _is_nth_color(c):
@@ -140,10 +137,10 @@ def to_rgba(c, alpha=None):
140137

141138

142139
def _to_rgba_no_colorcycle(c, alpha=None):
143-
"""Convert `c` to an RGBA color, with no support for color-cycle syntax.
140+
"""Convert *c* to an RGBA color, with no support for color-cycle syntax.
144141
145-
If `alpha` is not `None`, it forces the alpha value, except if `c` is
146-
"none" (case-insensitive), which always maps to `(0, 0, 0, 0)`.
142+
If *alpha* is not ``None``, it forces the alpha value, except if *c* is
143+
``"none"`` (case-insensitive), which always maps to ``(0, 0, 0, 0)``.
147144
"""
148145
orig_c = c
149146
if isinstance(c, six.string_types):
@@ -197,10 +194,10 @@ def _to_rgba_no_colorcycle(c, alpha=None):
197194

198195

199196
def to_rgba_array(c, alpha=None):
200-
"""Convert `c` to a (n, 4) array of RGBA colors.
197+
"""Convert *c* to a (n, 4) array of RGBA colors.
201198
202-
If `alpha` is not `None`, it forces the alpha value. If `c` is "none"
203-
(case-insensitive) or an empty list, an empty array is returned.
199+
If *alpha* is not ``None``, it forces the alpha value. If *c* is
200+
``"none"`` (case-insensitive) or an empty list, an empty array is returned.
204201
"""
205202
# Special-case inputs that are already arrays, for performance. (If the
206203
# array has the wrong kind or shape, raise the error during one-at-a-time
@@ -235,16 +232,15 @@ def to_rgba_array(c, alpha=None):
235232

236233

237234
def to_rgb(c):
238-
"""Convert `c` to an RGB color, silently dropping the alpha channel.
239-
"""
235+
"""Convert *c* to an RGB color, silently dropping the alpha channel."""
240236
return to_rgba(c)[:3]
241237

242238

243239
def to_hex(c, keep_alpha=False):
244-
"""Convert `c` to a hex color.
240+
"""Convert *c* to a hex color.
245241
246-
Uses the #rrggbb format if `keep_alpha` is False (the default), `#rrggbbaa`
247-
otherwise.
242+
Uses the ``#rrggbb`` format if *keep_alpha* is False (the default),
243+
``#rrggbbaa`` otherwise.
248244
"""
249245
c = to_rgba(c)
250246
if not keep_alpha:

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,33 +1783,24 @@ def test_stackplot_baseline():
17831783
np.random.seed(0)
17841784

17851785
def layers(n, m):
1786-
def bump(a):
1787-
x = 1 / (.1 + np.random.random())
1788-
y = 2 * np.random.random() - .5
1789-
z = 10 / (.1 + np.random.random())
1790-
a += x * np.exp(-((np.arange(m) / m - y) * z) ** 2)
17911786
a = np.zeros((m, n))
17921787
for i in range(n):
17931788
for j in range(5):
1794-
bump(a[:, i])
1789+
x = 1 / (.1 + np.random.random())
1790+
y = 2 * np.random.random() - .5
1791+
z = 10 / (.1 + np.random.random())
1792+
a[:, i] += x * np.exp(-((np.arange(m) / m - y) * z) ** 2)
17951793
return a
17961794

17971795
d = layers(3, 100)
17981796
d[50, :] = 0 # test for fixed weighted wiggle (issue #6313)
17991797

1800-
fig = plt.figure()
1801-
1802-
plt.subplot(2, 2, 1)
1803-
plt.stackplot(list(xrange(100)), d.T, baseline='zero')
1804-
1805-
plt.subplot(2, 2, 2)
1806-
plt.stackplot(list(xrange(100)), d.T, baseline='sym')
1807-
1808-
plt.subplot(2, 2, 3)
1809-
plt.stackplot(list(xrange(100)), d.T, baseline='wiggle')
1798+
fig, axs = plt.subplots(2, 2)
18101799

1811-
plt.subplot(2, 2, 4)
1812-
plt.stackplot(list(xrange(100)), d.T, baseline='weighted_wiggle')
1800+
axs[0, 0].stackplot(range(100), d.T, baseline='zero')
1801+
axs[0, 1].stackplot(range(100), d.T, baseline='sym')
1802+
axs[1, 0].stackplot(range(100), d.T, baseline='wiggle')
1803+
axs[1, 1].stackplot(range(100), d.T, baseline='weighted_wiggle')
18131804

18141805

18151806
@image_comparison(baseline_images=['bxp_baseline'],

setup.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,12 @@ def run(self):
206206
# Abort if any of the required packages can not be built.
207207
if required_failed:
208208
print_line()
209-
message = ("The following required packages can not "
210-
"be built: %s" %
211-
", ".join(x.name for x in required_failed))
209+
print_message("The following required packages can not be built: "
210+
"%s" % ", ".join(x.name for x in required_failed))
212211
for pkg in required_failed:
213-
pkg_help = pkg.install_help_msg()
214-
if pkg_help:
215-
message += "\n* " + pkg_help
216-
print_message(message)
212+
msg = pkg.install_get_help()
213+
if msg:
214+
print_message(msg)
217215
sys.exit(1)
218216

219217
# Now collect all of the information we need to build all of the

0 commit comments

Comments
 (0)