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 00b74bd

Browse filesBrowse files
committed
Merge branch 'v1.5.x' into v2.0.x
2 parents cc0c5d6 + 1f8b7f6 commit 00b74bd
Copy full SHA for 00b74bd

File tree

Expand file treeCollapse file tree

12 files changed

+128
-69
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+128
-69
lines changed

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
import platform
2828
import sys
2929
import itertools
30-
import base64
30+
try:
31+
# python3
32+
from base64 import encodebytes
33+
except ImportError:
34+
# python2
35+
from base64 import encodestring as encodebytes
3136
import contextlib
3237
import tempfile
3338
from matplotlib.cbook import iterable, is_string_like
@@ -927,7 +932,7 @@ def to_html5_video(self):
927932

928933
# Now open and base64 encode
929934
with open(f.name, 'rb') as video:
930-
vid64 = base64.encodebytes(video.read())
935+
vid64 = encodebytes(video.read())
931936
self._base64_video = vid64.decode('ascii')
932937
self._video_size = 'width="{0}" height="{1}"'.format(
933938
*writer.frame_size)

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,7 +3354,7 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
33543354
- ``q1``: The first quartile (25th percentile) (scalar
33553355
float).
33563356
3357-
- ``q3``: The first quartile (50th percentile) (scalar
3357+
- ``q3``: The third quartile (75th percentile) (scalar
33583358
float).
33593359
33603360
- ``whislo``: Lower bound of the lower whisker (scalar
@@ -7272,27 +7272,27 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
72727272
:class:`matplotlib.collections.PolyCollection` instances
72737273
containing the filled area of each violin.
72747274
7275-
- ``means``: A
7275+
- ``cmeans``: A
72767276
:class:`matplotlib.collections.LineCollection` instance
72777277
created to identify the mean values of each of the
72787278
violin's distribution.
72797279
7280-
- ``mins``: A
7280+
- ``cmins``: A
72817281
:class:`matplotlib.collections.LineCollection` instance
72827282
created to identify the bottom of each violin's
72837283
distribution.
72847284
7285-
- ``maxes``: A
7285+
- ``cmaxes``: A
72867286
:class:`matplotlib.collections.LineCollection` instance
72877287
created to identify the top of each violin's
72887288
distribution.
72897289
7290-
- ``bars``: A
7290+
- ``cbars``: A
72917291
:class:`matplotlib.collections.LineCollection` instance
72927292
created to identify the centers of each violin's
72937293
distribution.
72947294
7295-
- ``medians``: A
7295+
- ``cmedians``: A
72967296
:class:`matplotlib.collections.LineCollection` instance
72977297
created to identify the median values of each of the
72987298
violin's distribution.
@@ -7378,27 +7378,27 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
73787378
:class:`matplotlib.collections.PolyCollection` instances
73797379
containing the filled area of each violin.
73807380
7381-
- ``means``: A
7381+
- ``cmeans``: A
73827382
:class:`matplotlib.collections.LineCollection` instance
73837383
created to identify the mean values of each of the
73847384
violin's distribution.
73857385
7386-
- ``mins``: A
7386+
- ``cmins``: A
73877387
:class:`matplotlib.collections.LineCollection` instance
73887388
created to identify the bottom of each violin's
73897389
distribution.
73907390
7391-
- ``maxes``: A
7391+
- ``cmaxes``: A
73927392
:class:`matplotlib.collections.LineCollection` instance
73937393
created to identify the top of each violin's
73947394
distribution.
73957395
7396-
- ``bars``: A
7396+
- ``cbars``: A
73977397
:class:`matplotlib.collections.LineCollection` instance
73987398
created to identify the centers of each violin's
73997399
distribution.
74007400
7401-
- ``medians``: A
7401+
- ``cmedians``: A
74027402
:class:`matplotlib.collections.LineCollection` instance
74037403
created to identify the median values of each of the
74047404
violin's distribution.

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,13 @@ def set_color_cycle(self, clist):
11271127
"""
11281128
cbook.warn_deprecated(
11291129
'1.5', name='set_color_cycle', alternative='set_prop_cycle')
1130-
self.set_prop_cycle('color', clist)
1130+
if clist is None:
1131+
# Calling set_color_cycle() or set_prop_cycle() with None
1132+
# effectively resets the cycle, but you can't do
1133+
# set_prop_cycle('color', None). So we are special-casing this.
1134+
self.set_prop_cycle(None)
1135+
else:
1136+
self.set_prop_cycle('color', clist)
11311137

11321138
def ishold(self):
11331139
"""return the HOLD status of the axes"""

‎lib/matplotlib/patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patches.py
+8-21Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,13 @@ def contains(self, mouseevent, radius=None):
142142
143143
Returns T/F, {}
144144
"""
145-
# This is a general version of contains that should work on any
146-
# patch with a path. However, patches that have a faster
147-
# algebraic solution to hit-testing should override this
148-
# method.
149145
if six.callable(self._contains):
150146
return self._contains(self, mouseevent)
151147
if radius is None:
152-
radius = self.get_linewidth()
148+
if cbook.is_numlike(self._picker):
149+
radius = self._picker
150+
else:
151+
radius = self.get_linewidth()
153152
inside = self.get_path().contains_point(
154153
(mouseevent.x, mouseevent.y), self.get_transform(), radius)
155154
return inside, {}
@@ -160,7 +159,10 @@ def contains_point(self, point, radius=None):
160159
(transformed with its transform attribute).
161160
"""
162161
if radius is None:
163-
radius = self.get_linewidth()
162+
if cbook.is_numlike(self._picker):
163+
radius = self._picker
164+
else:
165+
radius = self.get_linewidth()
164166
return self.get_path().contains_point(point,
165167
self.get_transform(),
166168
radius)
@@ -670,15 +672,6 @@ def get_patch_transform(self):
670672
self._update_patch_transform()
671673
return self._rect_transform
672674

673-
def contains(self, mouseevent):
674-
# special case the degenerate rectangle
675-
if self._width == 0 or self._height == 0:
676-
return False, {}
677-
678-
x, y = self.get_transform().inverted().transform_point(
679-
(mouseevent.x, mouseevent.y))
680-
return (x >= 0.0 and x <= 1.0 and y >= 0.0 and y <= 1.0), {}
681-
682675
def get_x(self):
683676
"Return the left coord of the rectangle"
684677
return self._x
@@ -1416,12 +1409,6 @@ def get_patch_transform(self):
14161409
self._recompute_transform()
14171410
return self._patch_transform
14181411

1419-
def contains(self, ev):
1420-
if ev.x is None or ev.y is None:
1421-
return False, {}
1422-
x, y = self.get_transform().inverted().transform_point((ev.x, ev.y))
1423-
return (x * x + y * y) <= 1.0, {}
1424-
14251412

14261413
class Circle(Ellipse):
14271414
"""
Loading

‎lib/matplotlib/tests/test_collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_collections.py
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,26 @@ def test_linestyle_single_dashes():
597597
plt.draw()
598598

599599

600+
@image_comparison(baseline_images=['size_in_xy'], remove_text=True,
601+
extensions=['png'])
602+
def test_size_in_xy():
603+
fig, ax = plt.subplots()
604+
605+
widths, heights, angles = (10, 10), 10, 0
606+
widths = 10, 10
607+
coords = [(10, 10), (15, 15)]
608+
e = mcollections.EllipseCollection(
609+
widths, heights, angles,
610+
units='xy',
611+
offsets=coords,
612+
transOffset=ax.transData)
613+
614+
ax.add_collection(e)
615+
616+
ax.set_xlim(0, 30)
617+
ax.set_ylim(0, 30)
618+
619+
600620
if __name__ == '__main__':
601621
import nose
602622
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

‎lib/matplotlib/tests/test_cycles.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_cycles.py
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
from matplotlib.testing.decorators import image_comparison, cleanup
24
import matplotlib.pyplot as plt
35
import numpy as np
@@ -147,6 +149,30 @@ def test_valid_input_forms():
147149
assert True
148150

149151

152+
@cleanup
153+
def test_cycle_reset():
154+
fig, ax = plt.subplots()
155+
156+
# Can't really test a reset because only a cycle object is stored
157+
# but we can test the first item of the cycle.
158+
prop = next(ax._get_lines.prop_cycler)
159+
ax.set_prop_cycle(linewidth=[10, 9, 4])
160+
assert prop != next(ax._get_lines.prop_cycler)
161+
ax.set_prop_cycle(None)
162+
got = next(ax._get_lines.prop_cycler)
163+
assert prop == got, "expected %s, got %s" % (prop, got)
164+
165+
fig, ax = plt.subplots()
166+
# Need to double-check the old set/get_color_cycle(), too
167+
with warnings.catch_warnings():
168+
prop = next(ax._get_lines.prop_cycler)
169+
ax.set_color_cycle(['c', 'm', 'y', 'k'])
170+
assert prop != next(ax._get_lines.prop_cycler)
171+
ax.set_color_cycle(None)
172+
got = next(ax._get_lines.prop_cycler)
173+
assert prop == got, "expected %s, got %s" % (prop, got)
174+
175+
150176
@cleanup
151177
def test_invalid_input_forms():
152178
fig, ax = plt.subplots()

‎lib/matplotlib/tests/test_pickle.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_pickle.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ def test_transform():
279279
assert_equal(obj.wrapper._child, obj.composite)
280280
# Check child -> parent links of TransformWrapper.
281281
assert_equal(list(obj.wrapper._parents.values()), [obj.composite2])
282+
# Check input and output dimensions are set as expected.
283+
assert_equal(obj.wrapper.input_dims, obj.composite.input_dims)
284+
assert_equal(obj.wrapper.output_dims, obj.composite.output_dims)
282285

283286

284287
if __name__ == '__main__':

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,17 +1552,24 @@ def __eq__(self, other):
15521552
def __str__(self):
15531553
return str(self._child)
15541554

1555+
# NOTE: Transform.__[gs]etstate__ should be sufficient when using only
1556+
# Python 3.4+.
15551557
def __getstate__(self):
1556-
# only store the child and parents
1558+
# only store the child information and parents
15571559
return {
15581560
'child': self._child,
1561+
'input_dims': self.input_dims,
1562+
'output_dims': self.output_dims,
15591563
# turn the weakkey dictionary into a normal dictionary
15601564
'parents': dict(six.iteritems(self._parents))
15611565
}
15621566

15631567
def __setstate__(self, state):
15641568
# re-initialise the TransformWrapper with the state's child
15651569
self._init(state['child'])
1570+
# The child may not be unpickled yet, so restore its information.
1571+
self.input_dims = state['input_dims']
1572+
self.output_dims = state['output_dims']
15661573
# turn the normal dictionary back into a WeakValueDictionary
15671574
self._parents = WeakValueDictionary(state['parents'])
15681575

0 commit comments

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