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 b0a0a8e

Browse filesBrowse files
committed
Merge remote-tracking branch 'matplotlib/v2.1.x'
Conflicts: examples/subplots_axes_and_figures/subplots_adjust.py - both adjusted docstring .appveyor.yml - application of python patch showed up twice, kept only one copy lib/matplotlib/pyplot.py - moved imports around
2 parents 8989a6f + e9fcb97 commit b0a0a8e
Copy full SHA for b0a0a8e

File tree

Expand file treeCollapse file tree

15 files changed

+93
-34
lines changed
Filter options
Expand file treeCollapse file tree

15 files changed

+93
-34
lines changed

‎doc/conf.py

Copy file name to clipboardExpand all lines: doc/conf.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ def _check_deps():
9292
autodoc_default_flags = ['members', 'undoc-members']
9393

9494
intersphinx_mapping = {
95-
'python': ('https://docs.python.org/', None),
96-
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
97-
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
98-
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None)
99-
}
95+
'python': ('https://docs.python.org/3', None),
96+
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
97+
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
98+
'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None)
99+
}
100100

101101
explicit_order_folders = [
102102
'../examples/api',

‎doc/users/event_handling.rst

Copy file name to clipboardExpand all lines: doc/users/event_handling.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ Here are the events that you can connect to, the class instances that
5757
are sent back to you when the event occurs, and the event descriptions
5858

5959

60-
======================= ======================================================================================
60+
======================= =============================================================================================
6161
Event name Class and description
62-
======================= ======================================================================================
62+
======================= =============================================================================================
6363
'button_press_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is pressed
6464
'button_release_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse button is released
65-
'draw_event' :class:`~matplotlib.backend_bases.DrawEvent` - canvas draw
65+
'draw_event' :class:`~matplotlib.backend_bases.DrawEvent` - canvas draw (but before screen update)
6666
'key_press_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is pressed
6767
'key_release_event' :class:`~matplotlib.backend_bases.KeyEvent` - key is released
6868
'motion_notify_event' :class:`~matplotlib.backend_bases.MouseEvent` - mouse motion
@@ -73,7 +73,7 @@ Event name Class and description
7373
'figure_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves a figure
7474
'axes_enter_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse enters a new axes
7575
'axes_leave_event' :class:`~matplotlib.backend_bases.LocationEvent` - mouse leaves an axes
76-
======================= ======================================================================================
76+
======================= =============================================================================================
7777

7878
.. _event-attributes:
7979

‎examples/subplots_axes_and_figures/subplots_adjust.py

Copy file name to clipboardExpand all lines: examples/subplots_axes_and_figures/subplots_adjust.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
===============
55
66
Adjusting the spacing of margins and subplots using
7-
`~matplotlib.pyplot.subplots_adjust`.
7+
:func:`~matplotlib.pyplot.subplots_adjust`.
88
"""
99
import matplotlib.pyplot as plt
1010
import numpy as np

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,16 @@ class DrawEvent(Event):
14251425
"""
14261426
An event triggered by a draw operation on the canvas
14271427
1428+
In most backends callbacks subscribed to this callback will be
1429+
fired after the rendering is complete but before the screen is
1430+
updated. Any extra artists drawn to the canvas's renderer will
1431+
be reflected without an explicit call to ``blit``.
1432+
1433+
.. warning ::
1434+
1435+
Calling ``canvas.draw`` and ``canvas.blit`` in these callbacks may
1436+
not be safe with all backends and may cause infinite recursion.
1437+
14281438
In addition to the :class:`Event` attributes, the following event
14291439
attributes are defined:
14301440

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,22 @@ def draw_idle(self):
140140
QtCore.QTimer.singleShot(0, self.__draw_idle_agg)
141141

142142
def __draw_idle_agg(self, *args):
143+
# if nothing to do, bail
143144
if not self._agg_draw_pending:
144145
return
146+
# we have now tried this function at least once, do not run
147+
# again until re-armed. Doing this here rather than after
148+
# protects against recursive calls triggered through self.draw
149+
self._agg_draw_pending = False
150+
# if negative size, bail
145151
if self.height() < 0 or self.width() < 0:
146-
self._agg_draw_pending = False
147152
return
148153
try:
154+
# actually do the drawing
149155
self.draw()
150156
except Exception:
151157
# Uncaught exceptions are fatal for PyQt5, so catch them instead.
152158
traceback.print_exc()
153-
finally:
154-
self._agg_draw_pending = False
155159

156160
def blit(self, bbox=None):
157161
"""Blit the region in bbox.

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,10 @@ def get_cursor_data(self, event):
829829
array_extent = Bbox([[0, 0], arr.shape[:2]])
830830
trans = BboxTransform(boxin=data_extent, boxout=array_extent)
831831
y, x = event.ydata, event.xdata
832-
i, j = trans.transform_point([y, x]).astype(int)
832+
point = trans.transform_point([y, x])
833+
if any(np.isnan(point)):
834+
return None
835+
i, j = point.astype(int)
833836
# Clip the coordinates at array bounds
834837
if not (0 <= i < arr.shape[0]) or not (0 <= j < arr.shape[1]):
835838
return None

‎lib/matplotlib/sphinxext/tests/test_tinypages.py

Copy file name to clipboardExpand all lines: lib/matplotlib/sphinxext/tests/test_tinypages.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def setup_module():
2222
ret = call([sys.executable, '-msphinx', '--help'],
2323
stdout=PIPE, stderr=PIPE)
2424
if ret != 0:
25-
raise RuntimeError(
26-
"'{} -msphinx' does not return 0".format(sys.executable))
25+
pytest.skip("'{} -msphinx' does not return 0".format(sys.executable))
2726

2827

2928
@cbook.deprecated("2.1", alternative="filecmp.cmp")

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+24-2Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,12 +1734,18 @@ def _as_mpl_axes(self):
17341734
ax_via_gca = plt.gca(projection=prj)
17351735
assert ax_via_gca is ax
17361736
# try getting the axes given a different polar projection
1737-
ax_via_gca = plt.gca(projection=prj2)
1737+
with pytest.warns(UserWarning) as rec:
1738+
ax_via_gca = plt.gca(projection=prj2)
1739+
assert len(rec) == 1
1740+
assert 'Requested projection is different' in str(rec[0].message)
17381741
assert ax_via_gca is not ax
17391742
assert ax.get_theta_offset() == 0
17401743
assert ax_via_gca.get_theta_offset() == np.pi
17411744
# try getting the axes given an == (not is) polar projection
1742-
ax_via_gca = plt.gca(projection=prj3)
1745+
with pytest.warns(UserWarning):
1746+
ax_via_gca = plt.gca(projection=prj3)
1747+
assert len(rec) == 1
1748+
assert 'Requested projection is different' in str(rec[0].message)
17431749
assert ax_via_gca is ax
17441750
plt.close()
17451751

@@ -5426,3 +5432,19 @@ def test_patch_deprecations():
54265432
assert fig.patch == fig.figurePatch
54275433

54285434
assert len(w) == 2
5435+
5436+
5437+
def test_polar_gridlines():
5438+
fig = plt.figure()
5439+
ax = fig.add_subplot(111, polar=True)
5440+
5441+
# make all major grid lines lighter, only x grid lines set in 2.1.0
5442+
ax.grid(alpha=0.2)
5443+
5444+
# hide y tick labels, no effect in 2.1.0
5445+
plt.setp(ax.yaxis.get_ticklabels(), visible=False)
5446+
5447+
fig.canvas.draw()
5448+
5449+
assert ax.xaxis.majorTicks[0].gridline.get_alpha() == .2
5450+
assert ax.yaxis.majorTicks[0].gridline.get_alpha() == .2

‎lib/matplotlib/tests/test_cbook.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_cbook.py
+12-10Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ def test_is_hashable():
2929

3030
def test_restrict_dict():
3131
d = {'foo': 'bar', 1: 2}
32-
d1 = cbook.restrict_dict(d, ['foo', 1])
33-
assert d1 == d
34-
d2 = cbook.restrict_dict(d, ['bar', 2])
35-
assert d2 == {}
36-
d3 = cbook.restrict_dict(d, {'foo': 1})
37-
assert d3 == {'foo': 'bar'}
38-
d4 = cbook.restrict_dict(d, {})
39-
assert d4 == {}
40-
d5 = cbook.restrict_dict(d, {'foo', 2})
41-
assert d5 == {'foo': 'bar'}
32+
with pytest.warns(cbook.deprecation.MatplotlibDeprecationWarning) as rec:
33+
d1 = cbook.restrict_dict(d, ['foo', 1])
34+
assert d1 == d
35+
d2 = cbook.restrict_dict(d, ['bar', 2])
36+
assert d2 == {}
37+
d3 = cbook.restrict_dict(d, {'foo': 1})
38+
assert d3 == {'foo': 'bar'}
39+
d4 = cbook.restrict_dict(d, {})
40+
assert d4 == {}
41+
d5 = cbook.restrict_dict(d, {'foo', 2})
42+
assert d5 == {'foo': 'bar'}
43+
assert len(rec) == 5
4244
# check that d was not modified
4345
assert d == {'foo': 'bar', 1: 2}
4446

‎lib/matplotlib/tests/test_colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colors.py
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def test_tableau_order():
690690
assert list(mcolors.TABLEAU_COLORS.values()) == dflt_cycle
691691

692692

693-
def test_ndarray_subclass_norm():
693+
def test_ndarray_subclass_norm(recwarn):
694694
# Emulate an ndarray subclass that handles units
695695
# which objects when adding or subtracting with other
696696
# arrays. See #6622 and #8696
@@ -707,3 +707,11 @@ def __add__(self, other):
707707
mcolors.SymLogNorm(3, vmax=5, linscale=1),
708708
mcolors.PowerNorm(1)]:
709709
assert_array_equal(norm(data.view(MyArray)), norm(data))
710+
if isinstance(norm, mcolors.PowerNorm):
711+
assert len(recwarn) == 1
712+
warn = recwarn.pop(UserWarning)
713+
assert ('Power-law scaling on negative values is ill-defined'
714+
in str(warn.message))
715+
else:
716+
assert len(recwarn) == 0
717+
recwarn.clear()

‎lib/matplotlib/tests/test_compare_images.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_compare_images.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ def addFailure(self, test, err):
203203
assert failures[self.failure_count][1] in str(err[1])
204204
self.failure_count += 1
205205

206+
# Make sure that multiple extensions work, but don't require LaTeX or
207+
# Inkscape to do so.
208+
kwargs.setdefault('extensions', ['png', 'png', 'png'])
209+
206210
func = image_comparison(**kwargs)(func)
207211
loader = nose.loader.TestLoader()
208212
suite = loader.loadTestsFromGenerator(

‎lib/matplotlib/tests/test_dates.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_dates.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ def test_too_many_date_ticks():
9696
tf = datetime.datetime(2000, 1, 20)
9797
fig = plt.figure()
9898
ax = fig.add_subplot(1, 1, 1)
99-
ax.set_xlim((t0, tf), auto=True)
99+
with pytest.warns(UserWarning) as rec:
100+
ax.set_xlim((t0, tf), auto=True)
101+
assert len(rec) == 1
102+
assert 'Attempting to set identical left==right' in str(rec[0].message)
100103
ax.plot([], [])
101104
ax.xaxis.set_major_locator(mdates.DayLocator())
102105
with pytest.raises(RuntimeError):

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,8 @@ def test_load_from_url():
607607

608608
@image_comparison(baseline_images=['log_scale_image'],
609609
remove_text=True)
610-
def test_log_scale_image():
610+
# The recwarn fixture captures a warning in image_comparison.
611+
def test_log_scale_image(recwarn):
611612
Z = np.zeros((10, 10))
612613
Z[::2] = 1
613614

@@ -619,7 +620,6 @@ def test_log_scale_image():
619620
ax.set_yscale('log')
620621

621622

622-
623623
@image_comparison(baseline_images=['rotate_image'],
624624
remove_text=True)
625625
def test_rotate_image():

‎lib/matplotlib/tests/test_mlab.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_mlab.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import warnings
88

99
from numpy.testing import (assert_allclose, assert_almost_equal,
10-
assert_array_equal)
10+
assert_array_equal, assert_array_almost_equal_nulp)
1111
import numpy.ma.testutils as matest
1212
import numpy as np
1313
import datetime as datetime
@@ -1985,7 +1985,7 @@ def test_psd_csd_equal(self):
19851985
noverlap=self.nover_density,
19861986
pad_to=self.pad_to_density,
19871987
sides=self.sides)
1988-
assert_array_equal(Pxx, Pxy)
1988+
assert_array_almost_equal_nulp(Pxx, Pxy)
19891989
assert_array_equal(freqsxx, freqsxy)
19901990

19911991
def test_specgram_auto_default_equal(self):

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,10 @@ def __radd__(self, other):
12871287
# override `__eq__`), but some subclasses, such as TransformWrapper &
12881288
# AffineBase, override this behavior.
12891289

1290+
if six.PY2:
1291+
def __ne__(self, other):
1292+
return not (self == other)
1293+
12901294
def _iter_break_from_left_to_right(self):
12911295
"""
12921296
Returns an iterator breaking down this transform stack from left to

0 commit comments

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