Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 360b2f7

Browse filesBrowse files
committed
Merge remote-tracking branch 'matplotlib/v1.5.x' into v2.x
2 parents ad81e3f + 7cb9d1f commit 360b2f7
Copy full SHA for 360b2f7

File tree

Expand file treeCollapse file tree

13 files changed

+53
-29
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+53
-29
lines changed

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,8 @@ class FuncAnimation(TimedAnimation):
11141114
results of drawing from the first item in the frames sequence will be
11151115
used. This function will be called once before the first frame.
11161116
1117-
If blit=True, *func* and *init_func* should return an iterable of
1118-
drawables to clear.
1117+
If blit=True, *func* and *init_func* must return an iterable of
1118+
artists to be re-drawn.
11191119
11201120
*kwargs* include *repeat*, *repeat_delay*, and *interval*:
11211121
*interval* draws a new frame every *interval* milliseconds.
@@ -1196,6 +1196,9 @@ def _init_draw(self):
11961196
else:
11971197
self._drawn_artists = self._init_func()
11981198
if self._blit:
1199+
if self._drawn_artists is None:
1200+
raise RuntimeError('The init_func must return a '
1201+
'sequence of Artist objects.')
11991202
for a in self._drawn_artists:
12001203
a.set_animated(self._blit)
12011204
self._save_seq = []
@@ -1212,5 +1215,8 @@ def _draw_frame(self, framedata):
12121215
# func needs to return a sequence of any artists that were modified.
12131216
self._drawn_artists = self._func(framedata, *self._args)
12141217
if self._blit:
1218+
if self._drawn_artists is None:
1219+
raise RuntimeError('The animation function must return a '
1220+
'sequence of Artist objects.')
12151221
for a in self._drawn_artists:
12161222
a.set_animated(self._blit)

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,19 +3830,20 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
38303830
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
38313831

38323832
facecolors = None
3833-
ec = kwargs.pop('edgecolor', None)
3834-
if ec is not None:
3835-
edgecolors = ec
3836-
fc = kwargs.pop('facecolor', None)
3837-
if fc is not None:
3838-
facecolors = fc
3833+
edgecolors = kwargs.pop('edgecolor', edgecolors)
38393834
fc = kwargs.pop('facecolors', None)
3835+
fc = kwargs.pop('facecolor', fc)
38403836
if fc is not None:
38413837
facecolors = fc
3842-
# 'color' should be deprecated in scatter, or clearly defined;
3843-
# since it isn't, I am giving it low priority.
38443838
co = kwargs.pop('color', None)
38453839
if co is not None:
3840+
try:
3841+
mcolors.colorConverter.to_rgba_array(co)
3842+
except ValueError:
3843+
raise ValueError("'color' kwarg must be an mpl color"
3844+
" spec or sequence of color specs.\n"
3845+
"For a sequence of values to be"
3846+
" color-mapped, use the 'c' kwarg instead.")
38463847
if edgecolors is None:
38473848
edgecolors = co
38483849
if facecolors is None:

‎lib/matplotlib/backends/backend_ps.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_ps.py
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,16 @@ def _num_to_str(val):
165165
def _nums_to_str(*args):
166166
return ' '.join(map(_num_to_str,args))
167167

168+
168169
def quote_ps_string(s):
169170
"Quote dangerous characters of S for use in a PostScript string constant."
170-
s=s.replace("\\", "\\\\")
171-
s=s.replace("(", "\\(")
172-
s=s.replace(")", "\\)")
173-
s=s.replace("'", "\\251")
174-
s=s.replace("`", "\\301")
175-
s=re.sub(r"[^ -~\n]", lambda x: r"\%03o"%ord(x.group()), s)
176-
return s
171+
s = s.replace(b"\\", b"\\\\")
172+
s = s.replace(b"(", b"\\(")
173+
s = s.replace(b")", b"\\)")
174+
s = s.replace(b"'", b"\\251")
175+
s = s.replace(b"`", b"\\301")
176+
s = re.sub(br"[^ -~\n]", lambda x: br"\%03o" % ord(x.group()), s)
177+
return s.decode('ascii')
177178

178179

179180
def seq_allequal(seq1, seq2):

‎lib/matplotlib/backends/qt_editor/formlayout.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_editor/formlayout.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ def setup(self):
298298
field = QtWidgets.QLineEdit(repr(value), self)
299299
field.setCursorPosition(0)
300300
field.setValidator(QtGui.QDoubleValidator(field))
301+
field.validator().setLocale(QtCore.QLocale("C"))
301302
dialog = self.get_dialog()
302303
dialog.register_float_field(field)
303304
field.textChanged.connect(lambda text: dialog.update_buttons())

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def draw(self, renderer):
781781
drawFunc(renderer, gc, tpath, affine.frozen())
782782
gc.restore()
783783

784-
if self._marker:
784+
if self._marker and self._markersize > 0:
785785
gc = renderer.new_gc()
786786
self._set_gc_clip(gc)
787787
rgbaFace = self._get_rgba_face()
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn bright palette
22
axes.prop_cycle: cycler('color', ['003FFF', '03ED3A', 'E8000B', '8A2BE2', 'FFC400', '00D7FF'])
3+
patch.facecolor: 003FFF
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn colorblind palette
22
axes.prop_cycle: cycler('color', ['0072B2', '009E73', 'D55E00', 'CC79A7', 'F0E442', '56B4E9'])
3+
patch.facecolor: 0072B2
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn dark palette
22
axes.prop_cycle: cycler('color', ['001C7F', '017517', '8C0900', '7600A1', 'B8860B', '006374'])
3+
patch.facecolor: 001C7F
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn deep palette
22
axes.prop_cycle: cycler('color', ['4C72B0', '55A868', 'C44E52', '8172B2', 'CCB974', '64B5CD'])
3+
patch.facecolor: 4C72B0
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn muted palette
22
axes.prop_cycle: cycler('color', ['4878CF', '6ACC65', 'D65F5F', 'B47CC7', 'C4AD66', '77BEDB'])
3+
patch.facecolor: 4878CF
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Seaborn pastel palette
22
axes.prop_cycle: cycler('color', ['92C6FF', '97F0AA', 'FF9F9A', 'D0BBFF', 'FFFEA3', 'B0E0E6'])
3+
patch.facecolor: 92C6FF

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+10-11Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -760,17 +760,16 @@ def validate_cycler(s):
760760
# might come from the internet (future plans), this
761761
# could be downright dangerous.
762762
# I locked it down by only having the 'cycler()' function
763-
# available. Imports and defs should not
764-
# be possible. However, it is entirely possible that
765-
# a security hole could open up via attributes to the
766-
# function (this is why I decided against allowing the
767-
# Cycler class object just to reduce the number of
768-
# degrees of freedom (but maybe it is safer to use?).
769-
# One possible hole I can think of (in theory) is if
770-
# someone managed to hack the cycler module. But, if
771-
# someone does that, this wouldn't make anything
772-
# worse because we have to import the module anyway.
773-
s = eval(s, {'cycler': cycler})
763+
# available.
764+
# UPDATE: Partly plugging a security hole.
765+
# I really should have read this:
766+
# http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
767+
# We should replace this eval with a combo of PyParsing and
768+
# ast.literal_eval()
769+
if '.__' in s.replace(' ', ''):
770+
raise ValueError("'%s' seems to have dunder methods. Raising"
771+
" an exception for your safety")
772+
s = eval(s, {'cycler': cycler, '__builtins__': {}})
774773
except BaseException as e:
775774
raise ValueError("'%s' is not a valid cycler construction: %s" %
776775
(s, e))

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import matplotlib
2424
from matplotlib.testing.decorators import image_comparison, cleanup
25+
from matplotlib.testing.noseclasses import KnownFailureTest
2526
import matplotlib.pyplot as plt
2627
import matplotlib.markers as mmarkers
2728
from numpy.testing import assert_allclose, assert_array_equal
@@ -86,6 +87,8 @@ def test_formatter_ticker():
8687

8788
@image_comparison(baseline_images=["formatter_large_small"])
8889
def test_formatter_large_small():
90+
if tuple(map(int, np.__version__.split('.'))) >= (1, 11, 0):
91+
raise KnownFailureTest("Fall out from a fixed numpy bug")
8992
# github issue #617, pull #619
9093
fig, ax = plt.subplots(1)
9194
x = [0.500000001, 0.500000002]
@@ -1280,6 +1283,13 @@ def test_scatter_2D():
12801283
fig, ax = plt.subplots()
12811284
ax.scatter(x, y, c=z, s=200, edgecolors='face')
12821285

1286+
@cleanup
1287+
def test_scatter_color():
1288+
# Try to catch cases where 'c' kwarg should have been used.
1289+
assert_raises(ValueError, plt.scatter, [1, 2], [1, 2],
1290+
color=[0.1, 0.2])
1291+
assert_raises(ValueError, plt.scatter, [1, 2, 3], [1, 2, 3],
1292+
color=[1, 2, 3])
12831293

12841294
@cleanup
12851295
def test_as_mpl_axes_api():

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.