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

Skip to content

Commit fe720e2

Browse files
committed
Merge remote-tracking branch 'matplotlib/v1.5.x' into v2.x
2 parents 6a798f0 + 84f3a6f commit fe720e2

File tree

11 files changed

+69
-27
lines changed

11 files changed

+69
-27
lines changed

doc/users/plotting/examples/simple_legend01.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
plt.subplot(211)
55
plt.plot([1,2,3], label="test1")
66
plt.plot([3,2,1], label="test2")
7-
# Place a legend above this legend, expanding itself to
7+
# Place a legend above this subplot, expanding itself to
88
# fully use the given bounding box.
99
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
1010
ncol=2, mode="expand", borderaxespad=0.)
1111

1212
plt.subplot(223)
1313
plt.plot([1,2,3], label="test1")
1414
plt.plot([3,2,1], label="test2")
15-
# Place a legend to the right of this smaller figure.
15+
# Place a legend to the right of this smaller subplot.
1616
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
1717

1818
plt.show()

lib/matplotlib/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,9 @@ def __call__(self, value, clip=None):
852852
result = ma.array(np.clip(result.filled(vmax), vmin, vmax),
853853
mask=mask)
854854
# ma division is very slow; we can take a shortcut
855-
resdat = result.data
855+
# use np.asarray so data passed in as an ndarray subclass are
856+
# interpreted as an ndarray. See issue #6622.
857+
resdat = np.asarray(result.data)
856858
resdat -= vmin
857859
resdat /= (vmax - vmin)
858860
result = np.ma.array(resdat, mask=result.mask, copy=False)

lib/matplotlib/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ def set_linestyle(self, ls):
10901090
10911091
Parameters
10921092
----------
1093-
ls : { '-', '--', '-.', ':'} and more see description
1093+
ls : { ``'-'``, ``'--'``, ``'-.'``, ``':'``} and more see description
10941094
The line style.
10951095
"""
10961096
if not is_string_like(ls):

lib/matplotlib/offsetbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,12 +754,12 @@ def __init__(self, s,
754754
self._minimumdescent = minimumdescent
755755

756756
def set_text(self, s):
757-
"set text"
757+
"Set the text of this area as a string."
758758
self._text.set_text(s)
759759
self.stale = True
760760

761761
def get_text(self):
762-
"get text"
762+
"Returns the string representation of this area's text"
763763
return self._text.get_text()
764764

765765
def set_multilinebaseline(self, t):

lib/matplotlib/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ def contains_points(self, points, transform=None, radius=0.0):
510510
if transform is not None:
511511
transform = transform.frozen()
512512
result = _path.points_in_path(points, radius, self, transform)
513-
return result
513+
return result.astype('bool')
514514

515515
def contains_path(self, path, transform=None):
516516
"""

lib/matplotlib/tests/test_agg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import numpy as np
1212
from numpy.testing import assert_array_almost_equal
1313

14+
from nose.tools import assert_raises
15+
1416
from matplotlib.image import imread
1517
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
1618
from matplotlib.figure import Figure
@@ -290,6 +292,13 @@ def process_image(self, padded_src, dpi):
290292
ax.yaxis.set_visible(False)
291293

292294

295+
@cleanup
296+
def test_too_large_image():
297+
fig = plt.figure(figsize=(300, 1000))
298+
buff = io.BytesIO()
299+
assert_raises(ValueError, fig.savefig, buff)
300+
301+
293302
if __name__ == "__main__":
294303
import nose
295304
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_path.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ def test_point_in_path():
2828

2929
path = Path(verts2, closed=True)
3030
points = [(0.5, 0.5), (1.5, 0.5)]
31-
32-
assert np.all(path.contains_points(points) == [True, False])
31+
ret = path.contains_points(points)
32+
assert ret.dtype == 'bool'
33+
assert np.all(ret == [True, False])
3334

3435

3536
def test_contains_points_negative_radius():

lib/matplotlib/widgets.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,18 @@ def _release(self, event):
18271827
if not self.interactive:
18281828
self.to_draw.set_visible(False)
18291829

1830+
# update the eventpress and eventrelease with the resulting extents
1831+
x1, x2, y1, y2 = self.extents
1832+
self.eventpress.xdata = x1
1833+
self.eventpress.ydata = y1
1834+
xy1 = self.ax.transData.transform_point([x1, y1])
1835+
self.eventpress.x, self.eventpress.y = xy1
1836+
1837+
self.eventrelease.xdata = x2
1838+
self.eventrelease.ydata = y2
1839+
xy2 = self.ax.transData.transform_point([x2, y2])
1840+
self.eventrelease.x, self.eventrelease.y = xy2
1841+
18301842
if self.spancoords == 'data':
18311843
xmin, ymin = self.eventpress.xdata, self.eventpress.ydata
18321844
xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata
@@ -1848,27 +1860,16 @@ def _release(self, event):
18481860
xproblems = self.minspanx is not None and spanx < self.minspanx
18491861
yproblems = self.minspany is not None and spany < self.minspany
18501862

1851-
if (((self.drawtype == 'box') or (self.drawtype == 'line')) and
1852-
(xproblems or yproblems)):
1853-
# check if drawn distance (if it exists) is not too small in
1854-
# neither x nor y-direction
1855-
self.extents = [0, 0, 0, 0]
1863+
# check if drawn distance (if it exists) is not too small in
1864+
# either x or y-direction
1865+
if self.drawtype != 'none' and (xproblems or yproblems):
1866+
for artist in self.artists:
1867+
artist.set_visible(False)
1868+
self.update()
18561869
return
18571870

1858-
# update the eventpress and eventrelease with the resulting extents
1859-
x1, x2, y1, y2 = self.extents
1860-
self.eventpress.xdata = x1
1861-
self.eventpress.ydata = y1
1862-
xy1 = self.ax.transData.transform_point([x1, y1])
1863-
self.eventpress.x, self.eventpress.y = xy1
1864-
1865-
self.eventrelease.xdata = x2
1866-
self.eventrelease.ydata = y2
1867-
xy2 = self.ax.transData.transform_point([x2, y2])
1868-
self.eventrelease.x, self.eventrelease.y = xy2
1869-
1871+
# call desired function
18701872
self.onselect(self.eventpress, self.eventrelease)
1871-
# call desired function
18721873
self.update()
18731874

18741875
return False

src/_backend_agg_wrapper.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,15 @@ static int PyRendererAgg_init(PyRendererAgg *self, PyObject *args, PyObject *kwd
177177
return -1;
178178
}
179179

180+
if (width >= 1 << 16 || height >= 1 << 16) {
181+
PyErr_Format(
182+
PyExc_ValueError,
183+
"Image size of %dx%d pixels is too large. "
184+
"It must be less than 2^16 in each direction.",
185+
width, height);
186+
return -1;
187+
}
188+
180189
CALL_CPP_INIT("RendererAgg", self->x = new RendererAgg(width, height, dpi))
181190

182191
return 0;

src/mplutils.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ typedef unsigned __int8 uint8_t;
1818
# undef _XOPEN_SOURCE
1919
#endif
2020

21+
// Prevent multiple conflicting definitions of swab from stdlib.h and unistd.h
22+
#if defined(__sun) || defined(sun)
23+
#if defined(_XPG4)
24+
#undef _XPG4
25+
#endif
26+
#if defined(_XPG3)
27+
#undef _XPG3
28+
#endif
29+
#endif
30+
2131
#include <Python.h>
2232

2333
#if PY_MAJOR_VERSION >= 3

src/numpy_cpp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@
2525
# undef _XOPEN_SOURCE
2626
#endif
2727

28+
// Prevent multiple conflicting definitions of swab from stdlib.h and unistd.h
29+
#if defined(__sun) || defined(sun)
30+
#if defined(_XPG4)
31+
#undef _XPG4
32+
#endif
33+
#if defined(_XPG3)
34+
#undef _XPG3
35+
#endif
36+
#endif
37+
2838
#include <Python.h>
2939
#include <numpy/ndarrayobject.h>
3040

0 commit comments

Comments
 (0)