| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,15 +4,15 @@ | |||
| 4 | 4 | plt.subplot(211) | |
| 5 | 5 | plt.plot([1,2,3], label="test1") | |
| 6 | 6 | 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 | ||
| 8 | 8 | # fully use the given bounding box. | |
| 9 | 9 | plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, | |
| 10 | 10 | ncol=2, mode="expand", borderaxespad=0.) | |
| 11 | 11 | ||
| 12 | 12 | plt.subplot(223) | |
| 13 | 13 | plt.plot([1,2,3], label="test1") | |
| 14 | 14 | 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. | ||
| 16 | 16 | plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) | |
| 17 | 17 | ||
| 18 | 18 | plt.show() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -852,7 +852,9 @@ def __call__(self, value, clip=None): | |||
| 852 | 852 | result = ma.array(np.clip(result.filled(vmax), vmin, vmax), | |
| 853 | 853 | mask=mask) | |
| 854 | 854 | # 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) | ||
| 856 | 858 | resdat -= vmin | |
| 857 | 859 | resdat /= (vmax - vmin) | |
| 858 | 860 | result = np.ma.array(resdat, mask=result.mask, copy=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1090,7 +1090,7 @@ def set_linestyle(self, ls): | |||
| 1090 | 1090 | ||
| 1091 | 1091 | Parameters | |
| 1092 | 1092 | ---------- | |
| 1093 | - ls : { '-', '--', '-.', ':'} and more see description | ||
| 1093 | + ls : { ``'-'``, ``'--'``, ``'-.'``, ``':'``} and more see description | ||
| 1094 | 1094 | The line style. | |
| 1095 | 1095 | """ | |
| 1096 | 1096 | if not is_string_like(ls): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -754,12 +754,12 @@ def __init__(self, s, | |||
| 754 | 754 | self._minimumdescent = minimumdescent | |
| 755 | 755 | ||
| 756 | 756 | def set_text(self, s): | |
| 757 | - "set text" | ||
| 757 | + "Set the text of this area as a string." | ||
| 758 | 758 | self._text.set_text(s) | |
| 759 | 759 | self.stale = True | |
| 760 | 760 | ||
| 761 | 761 | def get_text(self): | |
| 762 | - "get text" | ||
| 762 | + "Returns the string representation of this area's text" | ||
| 763 | 763 | return self._text.get_text() | |
| 764 | 764 | ||
| 765 | 765 | def set_multilinebaseline(self, t): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -510,7 +510,7 @@ def contains_points(self, points, transform=None, radius=0.0): | |||
| 510 | 510 | if transform is not None: | |
| 511 | 511 | transform = transform.frozen() | |
| 512 | 512 | result = _path.points_in_path(points, radius, self, transform) | |
| 513 | - return result | ||
| 513 | + return result.astype('bool') | ||
| 514 | 514 | ||
| 515 | 515 | def contains_path(self, path, transform=None): | |
| 516 | 516 | """ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,8 @@ | |||
| 11 | 11 | import numpy as np | |
| 12 | 12 | from numpy.testing import assert_array_almost_equal | |
| 13 | 13 | ||
| 14 | + from nose.tools import assert_raises | ||
| 15 | + | ||
| 14 | 16 | from matplotlib.image import imread | |
| 15 | 17 | from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas | |
| 16 | 18 | from matplotlib.figure import Figure | |
@@ -290,6 +292,13 @@ def process_image(self, padded_src, dpi): | |||
| 290 | 292 | ax.yaxis.set_visible(False) | |
| 291 | 293 | ||
| 292 | 294 | ||
| 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 | + | ||
| 293 | 302 | if __name__ == "__main__": | |
| 294 | 303 | import nose | |
| 295 | 304 | nose.runmodule(argv=['-s', '--with-doctest'], exit=False) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,8 +28,9 @@ def test_point_in_path(): | |||
| 28 | 28 | ||
| 29 | 29 | path = Path(verts2, closed=True) | |
| 30 | 30 | 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]) | ||
| 33 | 34 | ||
| 34 | 35 | ||
| 35 | 36 | def test_contains_points_negative_radius(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1827,6 +1827,18 @@ def _release(self, event): | |||
| 1827 | 1827 | if not self.interactive: | |
| 1828 | 1828 | self.to_draw.set_visible(False) | |
| 1829 | 1829 | ||
| 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 | + | ||
| 1830 | 1842 | if self.spancoords == 'data': | |
| 1831 | 1843 | xmin, ymin = self.eventpress.xdata, self.eventpress.ydata | |
| 1832 | 1844 | xmax, ymax = self.eventrelease.xdata, self.eventrelease.ydata | |
@@ -1848,27 +1860,16 @@ def _release(self, event): | |||
| 1848 | 1860 | xproblems = self.minspanx is not None and spanx < self.minspanx | |
| 1849 | 1861 | yproblems = self.minspany is not None and spany < self.minspany | |
| 1850 | 1862 | ||
| 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() | ||
| 1856 | 1869 | return | |
| 1857 | 1870 | ||
| 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 | ||
| 1870 | 1872 | self.onselect(self.eventpress, self.eventrelease) | |
| 1871 | - # call desired function | ||
| 1872 | 1873 | self.update() | |
| 1873 | 1874 | ||
| 1874 | 1875 | return False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -177,6 +177,15 @@ static int PyRendererAgg_init(PyRendererAgg *self, PyObject *args, PyObject *kwd | |||
| 177 | 177 | return -1; | |
| 178 | 178 | } | |
| 179 | 179 | ||
| 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 | + | ||
| 180 | 189 | CALL_CPP_INIT("RendererAgg", self->x = new RendererAgg(width, height, dpi)) | |
| 181 | 190 | ||
| 182 | 191 | return 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,16 @@ typedef unsigned __int8 uint8_t; | |||
| 18 | 18 | # undef _XOPEN_SOURCE | |
| 19 | 19 | #endif | |
| 20 | 20 | ||
| 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 | + | ||
| 21 | 31 | #include <Python.h> | |
| 22 | 32 | ||
| 23 | 33 | #if PY_MAJOR_VERSION >= 3 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments