You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
1
(4) |
2
|
3
(2) |
4
(3) |
5
(5) |
6
(1) |
7
(3) |
8
|
9
(3) |
10
(3) |
11
(6) |
12
(2) |
13
(4) |
14
(1) |
15
(2) |
16
(1) |
17
(6) |
18
(8) |
19
|
20
(1) |
21
|
22
|
23
(3) |
24
(2) |
25
(2) |
26
(1) |
27
(2) |
28
(7) |
29
(2) |
30
(4) |
|
|
|
|
Revision: 6084 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6084&view=rev Author: jswhit Date: 2008年09月11日 19:30:39 +0000 (2008年9月11日) Log Message: ----------- patches from David Huard Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008年09月11日 18:47:29 UTC (rev 6083) +++ trunk/toolkits/basemap/Changelog 2008年09月11日 19:30:39 UTC (rev 6084) @@ -1,4 +1,7 @@ version 0.99.2 (not yet released) + * bugfix patch for rotate_vector from David Huard. David + also contributed the beginnings of a test suite. + * _geoslib.so now installed in mpl_toolkits.basemap. * make sure scatter method sets pyplot color mappable. * added cubed_sphere example. * updated NetCDFFile to use pupynere 1.0.2 (now can write as well Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月11日 18:47:29 UTC (rev 6083) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月11日 19:30:39 UTC (rev 6084) @@ -2449,25 +2449,41 @@ vin = vin.filled(1) else: masked = False + + # Map the (lon, lat) vector in the complex plane. uvc = uin + 1j*vin uvmag = np.abs(uvc) - delta = 0.1 # increment in longitude - dlon = delta*uin/uvmag - dlat = delta*(vin/uvmag)*np.cos(lats*np.pi/180.0) - farnorth = lats+dlat >= 90.0 + theta = np.angle(uvc) + + # Define a displacement (dlon, dlat) that moves all + # positions (lons, lats) a small distance in the + # direction of the original vector. + dc = 1E-5 * np.exp(theta*1j) + dlat = dc.imag * np.cos(np.radians(lats)) + dlon = dc.real + + # Deal with displacements that overshoot the North or South Pole. + farnorth = np.abs(lats+dlat) >= 90.0 somenorth = farnorth.any() if somenorth: dlon[farnorth] *= -1.0 dlat[farnorth] *= -1.0 + + # Add displacement to original location and find the native coordinates. lon1 = lons + dlon lat1 = lats + dlat xn, yn = self(lon1, lat1) + + # Determine the angle of the displacement in the native coordinates. vecangle = np.arctan2(yn-y, xn-x) if somenorth: vecangle[farnorth] += np.pi + + # Compute the x-y components of the original vector. uvcout = uvmag * np.exp(1j*vecangle) uout = uvcout.real vout = uvcout.imag + if masked: uout = ma.array(uout, mask=mask) vout = ma.array(vout, mask=mask) @@ -3793,3 +3809,54 @@ """ cdftime = netcdftime.utime(units,calendar=calendar) return cdftime.date2num(dates) + + + +# beginnings of a test suite. + +from numpy.testing import NumpyTestCase,assert_almost_equal +class TestRotateVector(NumpyTestCase): + def make_array(self): + lat = np.array([0, 45, 75, 90]) + lon = np.array([0,90,180,270]) + u = np.ones((len(lat), len(lon))) + v = np.zeros((len(lat), len(lon))) + return u,v,lat,lon + + def test_cylindrical(self): + # Cylindrical case + B = Basemap() + u,v,lat,lon=self.make_array() + ru, rv = B.rotate_vector(u,v, lon, lat) + + # Check that the vectors are identical. + assert_almost_equal(ru, u) + assert_almost_equal(rv, v) + + def test_nan(self): + B = Basemap() + u,v,lat,lon=self.make_array() + # Set one element to 0, so that the vector magnitude is 0. + u[1,1] = 0. + ru, rv = B.rotate_vector(u,v, lon, lat) + assert not np.isnan(ru).any() + assert_almost_equal(u, ru) + assert_almost_equal(v, rv) + + def test_npstere(self): + # NP Stereographic case + B=Basemap(projection='npstere', boundinglat=50., lon_0=0.) + u,v,lat,lon=self.make_array() + v = np.ones((len(lat), len(lon))) + + ru, rv = B.rotate_vector(u,v, lon, lat) + + assert_almost_equal(ru[2, :],[1,-1,-1,1], 6) + assert_almost_equal(rv[2, :],[1,1,-1,-1], 6) + +def test(): + import unittest + suite = unittest.makeSuite(TestRotateVector,'test') + runner = unittest.TextTestRunner() + runner.run(suite) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6083 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6083&view=rev Author: jswhit Date: 2008年09月11日 18:47:29 +0000 (2008年9月11日) Log Message: ----------- install _geoslib in mpl_toolkits.basemap Modified Paths: -------------- trunk/toolkits/basemap/setup.py Modified: trunk/toolkits/basemap/setup.py =================================================================== --- trunk/toolkits/basemap/setup.py 2008年09月11日 12:17:34 UTC (rev 6082) +++ trunk/toolkits/basemap/setup.py 2008年09月11日 18:47:29 UTC (rev 6083) @@ -81,17 +81,15 @@ package_dirs = {'':'lib'} extensions = [Extension("mpl_toolkits.basemap._proj",deps+['src/_proj.c'],include_dirs = ['src'],)] extensions.append(Extension("mpl_toolkits.basemap._geod",deps+['src/_geod.c'],include_dirs = ['src'],)) -# for some reason, pickling won't work if this extension is installed -# as "matplotlib.toolkits.basemap._geoslib" if sys.platform == 'win32': # don't use runtime_library_dirs on windows (workaround # for a distutils bug - http://bugs.python.org/issue2437). - extensions.append(Extension("_geoslib",['src/_geoslib.c'], + extensions.append(Extension("mpl_toolkits.basemap._geoslib",['src/_geoslib.c'], library_dirs=geos_library_dirs, include_dirs=geos_include_dirs, libraries=['geos_c','geos'])) else: - extensions.append(Extension("_geoslib",['src/_geoslib.c'], + extensions.append(Extension("mpl_toolkits.basemap._geoslib",['src/_geoslib.c'], library_dirs=geos_library_dirs, runtime_library_dirs=geos_library_dirs, include_dirs=geos_include_dirs, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6082 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6082&view=rev Author: jswhit Date: 2008年09月11日 12:17:34 +0000 (2008年9月11日) Log Message: ----------- make sure scatter method sets color-mappable. Modified Paths: -------------- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008年09月11日 12:16:16 UTC (rev 6081) +++ trunk/toolkits/basemap/Changelog 2008年09月11日 12:17:34 UTC (rev 6082) @@ -1,4 +1,5 @@ version 0.99.2 (not yet released) + * make sure scatter method sets pyplot color mappable. * added cubed_sphere example. * updated NetCDFFile to use pupynere 1.0.2 (now can write as well as read!). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6081 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6081&view=rev Author: jswhit Date: 2008年09月11日 12:16:16 +0000 (2008年9月11日) Log Message: ----------- map scatter method sets color mappable Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月10日 18:46:10 UTC (rev 6080) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月11日 12:16:16 UTC (rev 6081) @@ -2548,6 +2548,11 @@ ax.hold(b) raise ax.hold(b) + # reset current active image (only if pyplot is imported). + try: + plt.gci._current = ret + except: + pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6080 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6080&view=rev Author: mdboom Date: 2008年09月10日 18:46:10 +0000 (2008年9月10日) Log Message: ----------- [ 2089958 ] Path simplification for vector output backends Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py trunk/matplotlib/lib/matplotlib/config/mplconfig.py trunk/matplotlib/lib/matplotlib/config/rcsetup.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/lib/matplotlib/rcsetup.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/CHANGELOG 2008年09月10日 18:46:10 UTC (rev 6080) @@ -1,3 +1,10 @@ +2008年09月10日 [ 2089958 ] Path simplification for vector output backends + Leverage the simplification code exposed through + path_to_polygons to simplify certain well-behaved paths in + the vector backends (PDF, PS and SVG). "path.simplify" + must be set to True in matplotlibrc for this to work. - + MGD + 2008年09月10日 Add "filled" kwarg to Path.intersects_path and Path.intersects_bbox. - MGD Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -331,6 +331,10 @@ def __init__(self, width, height, dpi, filename): self.width, self.height = width, height self.dpi = dpi + if rcParams['path.simplify']: + self.simplify = (width * dpi, height * dpi) + else: + self.simplify = None self.nextObject = 1 # next free object id self.xrefTable = [ [0, 65535, 'the zero object'] ] self.passed_in_file_object = False @@ -1092,12 +1096,12 @@ self.endStream() #@staticmethod - def pathOperations(path, transform): + def pathOperations(path, transform, simplify=None): tpath = transform.transform_path(path) cmds = [] last_points = None - for points, code in tpath.iter_segments(): + for points, code in tpath.iter_segments(simplify): if code == Path.MOVETO: cmds.extend(points) cmds.append(Op.moveto) @@ -1118,7 +1122,8 @@ pathOperations = staticmethod(pathOperations) def writePath(self, path, transform): - cmds = self.pathOperations(path, transform) + cmds = self.pathOperations( + path, transform, self.simplify) self.output(*cmds) def reserveObject(self, name=''): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -145,6 +145,10 @@ self.textcnt = 0 self.psfrag = [] self.imagedpi = imagedpi + if rcParams['path.simplify']: + self.simplify = (width * imagedpi, height * imagedpi) + else: + self.simplify = None # current renderer state (None=uninitialised) self.color = None @@ -444,12 +448,12 @@ # unflip im.flipud_out() - def _convert_path(self, path, transform): + def _convert_path(self, path, transform, simplify=None): path = transform.transform_path(path) ps = [] last_points = None - for points, code in path.iter_segments(): + for points, code in path.iter_segments(simplify): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: @@ -463,7 +467,7 @@ elif code == Path.CLOSEPOLY: ps.append("cl") last_points = points - + ps = "\n".join(ps) return ps @@ -482,7 +486,7 @@ """ Draws a Path instance using the given affine transform. """ - ps = self._convert_path(path, transform) + ps = self._convert_path(path, transform, self.simplify) self._draw_ps(ps, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -42,6 +42,10 @@ self.width=width self.height=height self._svgwriter = svgwriter + if rcParams['path.simplify']: + self.simplify = (width, height) + else: + self.simplify = None self._groupd = {} if not rcParams['svg.image_inline']: @@ -165,14 +169,14 @@ .scale(1.0, -1.0) .translate(0.0, self.height)) - def _convert_path(self, path, transform): + def _convert_path(self, path, transform, simplify=None): tpath = transform.transform_path(path) path_data = [] appender = path_data.append path_commands = self._path_commands currpos = 0 - for points, code in tpath.iter_segments(): + for points, code in tpath.iter_segments(simplify): if code == Path.CLOSEPOLY: segment = 'z' else: @@ -187,7 +191,7 @@ def draw_path(self, gc, path, transform, rgbFace=None): trans_and_flip = self._make_flip_transform(transform) - path_data = self._convert_path(path, trans_and_flip) + path_data = self._convert_path(path, trans_and_flip, self.simplify) self._draw_svg_element('path', 'd="%s"' % path_data, gc, rgbFace) def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None): Modified: trunk/matplotlib/lib/matplotlib/config/mplconfig.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/config/mplconfig.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -117,6 +117,9 @@ markersize = T.Float(6) antialiased = T.true + class path(TConfig): + simplify = T.false + class patch(TConfig): linewidth = T.Float(1.0) facecolor = T.Trait('blue', mplT.ColorHandler()) @@ -439,6 +442,8 @@ 'svg.image_noscale' : (self.tconfig.backend.svg, 'image_noscale'), 'svg.embed_char_paths' : (self.tconfig.backend.svg, 'embed_char_paths'), + # Path properties + 'path.simplify' : (self.tconfig.path, 'simplify') } def __setitem__(self, key, val): Modified: trunk/matplotlib/lib/matplotlib/config/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/config/rcsetup.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -476,6 +476,7 @@ 'svg.embed_char_paths' : [True, validate_bool], # True to save all characters as paths in the SVG 'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate + 'path.simplify' : [False, validate_bool] } if __name__ == '__main__': Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -145,12 +145,24 @@ def __len__(self): return len(self.vertices) - def iter_segments(self): + def iter_segments(self, simplify=None): """ Iterates over all of the curve segments in the path. Each iteration returns a 2-tuple (*vertices*, *code*), where *vertices* is a sequence of 1 - 3 coordinate pairs, and *code* is one of the :class:`Path` codes. + + If *simplify* is provided, it must be a tuple (*width*, + *height*) defining the size of the figure, in native units + (e.g. pixels or points). Simplification implies both removing + adjacent line segments that are very close to parallel, and + removing line segments outside of the figure. The path will + be simplified *only* if :attr:`should_simplify` is True, which + is determined in the constructor by this criteria: + + - No *codes* array + - No nonfinite values + - More than 128 vertices """ vertices = self.vertices if not len(vertices): @@ -166,7 +178,13 @@ CLOSEPOLY = self.CLOSEPOLY STOP = self.STOP - if codes is None: + if simplify is not None and self.should_simplify: + polygons = self.to_polygons(None, *simplify) + for vertices in polygons: + yield vertices[0], MOVETO + for v in vertices[1:]: + yield v, LINETO + elif codes is None: next_code = MOVETO for v in vertices: if (~isfinite(v)).any(): Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py =================================================================== --- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008年09月10日 18:46:10 UTC (rev 6080) @@ -487,6 +487,7 @@ 'svg.embed_char_paths' : [True, validate_bool], # True to save all characters as paths in the SVG 'plugins.directory' : ['.matplotlib_plugins', str], # where plugin directory is locate + 'path.simplify' : [False, validate_bool] } if __name__ == '__main__': Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008年09月10日 15:28:55 UTC (rev 6079) +++ trunk/matplotlib/matplotlibrc.template 2008年09月10日 18:46:10 UTC (rev 6080) @@ -270,6 +270,8 @@ #contour.negative_linestyle : dashed # dashed | solid ### SAVING FIGURES +#path.simplify : False # When True, simplify paths in vector backends, such as PDF, PS and SVG + # the default savefig params can be different for the GUI backends. # Eg, you may want a higher resolution, or to make the figure # background white This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6079 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6079&view=rev Author: mdboom Date: 2008年09月10日 15:28:55 +0000 (2008年9月10日) Log Message: ----------- Fix numpy namespace (thanks Evan Mason) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/transforms.py Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2008年09月10日 12:33:33 UTC (rev 6078) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2008年09月10日 15:28:55 UTC (rev 6079) @@ -599,7 +599,7 @@ dx1 = np.sign(vertices[:, 0] - x1) dy1 = np.sign(vertices[:, 1] - y1) inside = (abs(dx0 + dx1) + abs(dy0 + dy1)) <= 2 - return N.sum(inside) + return np.sum(inside) def count_overlaps(self, bboxes): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6078 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6078&view=rev Author: mdboom Date: 2008年09月10日 12:33:33 +0000 (2008年9月10日) Log Message: ----------- Add "filled" kwarg to path_intersects_path Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/src/_path.cpp Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月09日 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/CHANGELOG 2008年09月10日 12:33:33 UTC (rev 6078) @@ -1,7 +1,10 @@ +2008年09月10日 Add "filled" kwarg to Path.intersects_path and + Path.intersects_bbox. - MGD + 2008年09月07日 Changed full arrows slightly to avoid an xpdf rendering problem reported by Friedrich Hagedorn. - JKS -2008年09月07日 Fix conversion of quadratic to cubic Bezier curves in PDF +2008年09月07日 Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. - JKS 2008年09月06日 Added 5-point star marker to plot command - EF Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年09月09日 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年09月10日 12:33:33 UTC (rev 6078) @@ -242,21 +242,29 @@ transform = transform.frozen() return Bbox(get_path_extents(self, transform)) - def intersects_path(self, other): + def intersects_path(self, other, filled=True): """ Returns *True* if this path intersects another given path. + + *filled*, when True, treats the paths as if they were filled. + That is, if one path completely encloses the other, + :meth:`intersects_path` will return True. """ - return path_intersects_path(self, other) + return path_intersects_path(self, other, filled) - def intersects_bbox(self, bbox): + def intersects_bbox(self, bbox, filled=True): """ Returns *True* if this path intersects a given :class:`~matplotlib.transforms.Bbox`. + + *filled*, when True, treats the path as if it was filled. + That is, if one path completely encloses the other, + :meth:`intersects_path` will return True. """ from transforms import BboxTransformTo rectangle = self.unit_rectangle().transformed( BboxTransformTo(bbox)) - result = self.intersects_path(rectangle) + result = self.intersects_path(rectangle, filled) return result def interpolated(self, steps): Modified: trunk/matplotlib/src/_path.cpp =================================================================== --- trunk/matplotlib/src/_path.cpp 2008年09月09日 23:15:59 UTC (rev 6077) +++ trunk/matplotlib/src/_path.cpp 2008年09月10日 12:33:33 UTC (rev 6078) @@ -1081,14 +1081,22 @@ Py::Object _path_module::path_intersects_path(const Py::Tuple& args) { - args.verify_length(2); + args.verify_length(2, 3); PathIterator p1(args[0]); PathIterator p2(args[1]); + bool filled = false; + if (args.size() == 3) { + filled = args[2].isTrue(); + } - return Py::Int(::path_intersects_path(p1, p2) - || ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine()) - || ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine())); + if (!filled) { + return Py::Int(::path_intersects_path(p1, p2)); + } else { + return Py::Int(::path_intersects_path(p1, p2) + || ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine()) + || ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine())); + } } void _add_polygon(Py::List& polygons, const std::vector<double>& polygon) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6077 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6077&view=rev Author: jrevans Date: 2008年09月09日 23:15:59 +0000 (2008年9月09日) Log Message: ----------- Fixed some issues with unitized data. Some Patches were attempting to calculate some results without knowing how to convert (not attached to any Axes). A couple of Axes routines were assuming data was not unitized or not converting the data at the appropriate place. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年09月09日 12:58:33 UTC (rev 6076) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年09月09日 23:15:59 UTC (rev 6077) @@ -2679,10 +2679,12 @@ See :meth:`axhspan` for example plot and source code """ - ymin, ymax = self.get_ylim() - if ymax<ymin: ymin, ymax = ymax, ymin - scaley = (y<ymin) or (y>ymax) + ymin, ymax = self.get_ybound() + # We need to strip away the units for comparison with non-unitized bounds + yy = self.convert_yunits( y ) + scaley = (yy<ymin) or (yy>ymax) + trans = mtransforms.blended_transform_factory( self.transAxes, self.transData) l, = self.plot([xmin,xmax], [y,y], transform=trans, scalex=False, scaley=scaley, **kwargs) @@ -2731,10 +2733,12 @@ See :meth:`axhspan` for example plot and source code """ - xmin, xmax = self.get_xlim() - if xmax<xmin: xmin, xmax = xmax, xmin - scalex = (x<xmin) or (x>xmax) + xmin, xmax = self.get_xbound() + # We need to strip away the units for comparison with non-unitized bounds + xx = self.convert_xunits( x ) + scalex = (xx<xmin) or (xx>xmax) + trans = mtransforms.blended_transform_factory( self.transData, self.transAxes) l, = self.plot([x,x], [ymin,ymax] , transform=trans, scalex=scalex, scaley=False, **kwargs) @@ -2876,9 +2880,15 @@ raise DeprecationWarning( 'hlines now uses a collections.LineCollection and not a list of Line2D to draw; see API_CHANGES') + # We do the conversion first since not all unitized data is uniform + y = self.convert_yunits( y ) + xmin = self.convert_xunits( xmin ) + xmax = self.convert_xunits( xmax ) + if not iterable(y): y = [y] if not iterable(xmin): xmin = [xmin] if not iterable(xmax): xmax = [xmax] + y = np.asarray(y) xmin = np.asarray(xmin) xmax = np.asarray(xmax) @@ -2905,8 +2915,6 @@ miny = y.min() maxy = y.max() - minx, maxx = self.convert_xunits((minx, maxx)) - miny, maxy = self.convert_yunits((miny, maxy)) corners = (minx, miny), (maxx, maxy) self.update_datalim(corners) @@ -2947,9 +2955,15 @@ self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs) + # We do the conversion first since not all unitized data is uniform + x = self.convert_xunits( x ) + ymin = self.convert_yunits( ymin ) + ymax = self.convert_yunits( ymax ) + if not iterable(x): x = [x] if not iterable(ymin): ymin = [ymin] if not iterable(ymax): ymax = [ymax] + x = np.asarray(x) ymin = np.asarray(ymin) ymax = np.asarray(ymax) @@ -2973,17 +2987,12 @@ self.add_collection(coll) coll.update(kwargs) - # We do the conversion first since not all unitized data is uniform - xx = self.convert_xunits( x ) - yymin = self.convert_yunits( ymin ) - yymax = self.convert_yunits( ymax ) + minx = min( x ) + maxx = max( x ) - minx = min( xx ) - maxx = max( xx ) + miny = min( min(ymin), min(ymax) ) + maxy = max( max(ymin), max(ymax) ) - miny = min( min(yymin), min(yymax) ) - maxy = max( max(yymin), max(yymax) ) - corners = (minx, miny), (maxx, maxy) self.update_datalim(corners) self.autoscale_view() Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008年09月09日 12:58:33 UTC (rev 6076) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008年09月09日 23:15:59 UTC (rev 6077) @@ -380,8 +380,8 @@ self._y = xy[1] self._width = width self._height = height + # Note: This cannot be calculated until this is added to an Axes self._rect_transform = transforms.IdentityTransform() - self._update_patch_transform() __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): @@ -391,6 +391,11 @@ return Path.unit_rectangle() def _update_patch_transform(self): + """NOTE: This cannot be called until after this has been added + to an Axes, otherwise unit conversion will fail. This + maxes it very important to call the accessor method and + not directly access the transformation member variable. + """ x = self.convert_xunits(self._x) y = self.convert_yunits(self._y) width = self.convert_xunits(self._width) @@ -946,11 +951,16 @@ self.width, self.height = width, height self.angle = angle self._path = Path.unit_circle() + # Note: This cannot be calculated until this is added to an Axes self._patch_transform = transforms.IdentityTransform() - self._recompute_transform() __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def _recompute_transform(self): + """NOTE: This cannot be called until after this has been added + to an Axes, otherwise unit conversion will fail. This + maxes it very important to call the accessor method and + not directly access the transformation member variable. + """ center = (self.convert_xunits(self.center[0]), self.convert_yunits(self.center[1])) width = self.convert_xunits(self.width) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6076 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6076&view=rev Author: mdboom Date: 2008年09月09日 12:58:33 +0000 (2008年9月09日) Log Message: ----------- Add unit test for Path.intersects_bbox. Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py Added Paths: ----------- trunk/matplotlib/examples/api/bbox_intersect.py Added: trunk/matplotlib/examples/api/bbox_intersect.py =================================================================== --- trunk/matplotlib/examples/api/bbox_intersect.py (rev 0) +++ trunk/matplotlib/examples/api/bbox_intersect.py 2008年09月09日 12:58:33 UTC (rev 6076) @@ -0,0 +1,21 @@ +from pylab import * +import numpy as np +from matplotlib.transforms import Bbox +from matplotlib.path import Path +from matplotlib.patches import Rectangle + +rect = Rectangle((-1, -1), 2, 2, facecolor="#aaaaaa") +gca().add_patch(rect) +bbox = Bbox.from_bounds(-1, -1, 2, 2) + +for i in range(12): + vertices = (np.random.random((4, 2)) - 0.5) * 6.0 + vertices = np.ma.masked_array(vertices, [[False, False], [True, True], [False, False], [False, False]]) + path = Path(vertices) + if path.intersects_bbox(bbox): + color = 'r' + else: + color = 'b' + plot(vertices[:,0], vertices[:,1], color=color) + +show() Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月09日 12:33:03 UTC (rev 6075) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月09日 12:58:33 UTC (rev 6076) @@ -124,6 +124,7 @@ api_dir = os.path.join('..', 'api') api_files = [ + 'bbox_intersect.py', 'colorbar_only.py', 'color_cycle.py', 'donut_demo.py', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6075 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6075&view=rev Author: mdboom Date: 2008年09月09日 12:33:03 +0000 (2008年9月09日) Log Message: ----------- Fix small bug with quad curves in PDF backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月07日 11:28:45 UTC (rev 6074) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月09日 12:33:03 UTC (rev 6075) @@ -1106,7 +1106,7 @@ cmds.append(Op.lineto) elif code == Path.CURVE3: points = quad2cubic(*(list(last_points[-2:]) + list(points))) - cmds.extend(points) + cmds.extend(points[2:]) cmds.append(Op.curveto) elif code == Path.CURVE4: cmds.extend(points) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6074 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6074&view=rev Author: jouni Date: 2008年09月07日 11:28:45 +0000 (2008年9月07日) Log Message: ----------- Merged revisions 6073 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r6073 | jouni | 2008年09月07日 14:19:13 +0300 (2008年9月07日) | 3 lines Changed full arrows slightly to avoid an xpdf rendering problem reported by Friedrich Hagedorn. ........ Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/patches.py Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-6068 + /branches/v0_91_maint:1-6073 Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月07日 11:19:13 UTC (rev 6073) +++ trunk/matplotlib/CHANGELOG 2008年09月07日 11:28:45 UTC (rev 6074) @@ -1,3 +1,6 @@ +2008年09月07日 Changed full arrows slightly to avoid an xpdf rendering + problem reported by Friedrich Hagedorn. - JKS + 2008年09月07日 Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. - JKS Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008年09月07日 11:19:13 UTC (rev 6073) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008年09月07日 11:28:45 UTC (rev 6074) @@ -772,7 +772,11 @@ if shape == 'right': coords = right_half_arrow elif shape == 'full': - coords=np.concatenate([left_half_arrow,right_half_arrow[::-1]]) + # The half-arrows contain the midpoint of the stem, + # which we can omit from the full arrow. Including it + # twice caused a problem with xpdf. + coords=np.concatenate([left_half_arrow[:-1], + right_half_arrow[-2::-1]]) else: raise ValueError, "Got unknown shape: %s" % shape cx = float(dx)/distance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6073 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6073&view=rev Author: jouni Date: 2008年09月07日 11:19:13 +0000 (2008年9月07日) Log Message: ----------- Changed full arrows slightly to avoid an xpdf rendering problem reported by Friedrich Hagedorn. Modified Paths: -------------- branches/v0_91_maint/CHANGELOG branches/v0_91_maint/lib/matplotlib/patches.py Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008年09月07日 10:57:15 UTC (rev 6072) +++ branches/v0_91_maint/CHANGELOG 2008年09月07日 11:19:13 UTC (rev 6073) @@ -1,3 +1,6 @@ +2008年09月07日 Changed full arrows slightly to avoid an xpdf rendering + problem reported by Friedrich Hagedorn. - JKS + 2008年08月25日 Fix locale issues in SVG backend - MGD 2008年08月01日 Backported memory leak fixes in _ttconv.cpp - MGD Modified: branches/v0_91_maint/lib/matplotlib/patches.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/patches.py 2008年09月07日 10:57:15 UTC (rev 6072) +++ branches/v0_91_maint/lib/matplotlib/patches.py 2008年09月07日 11:19:13 UTC (rev 6073) @@ -634,7 +634,11 @@ if shape == 'right': coords = right_half_arrow elif shape == 'full': - coords=npy.concatenate([left_half_arrow,right_half_arrow[::-1]]) + # The half-arrows contain the midpoint of the stem, + # which we can omit from the full arrow. Including it + # twice caused a problem with xpdf. + coords=npy.concatenate([left_half_arrow[:-1], + right_half_arrow[-2::-1]]) else: raise ValueError, "Got unknown shape: %s" % shape cx = float(dx)/distance This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6072 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6072&view=rev Author: jouni Date: 2008年09月07日 10:57:15 +0000 (2008年9月07日) Log Message: ----------- Fix conversion of quadratic to cubic Bezier curves in PDF and PS backends. Patch by Jae-Joon Lee. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/cbook.py Added Paths: ----------- trunk/matplotlib/examples/api/quad_bezier.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月06日 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/CHANGELOG 2008年09月07日 10:57:15 UTC (rev 6072) @@ -1,3 +1,6 @@ +2008年09月07日 Fix conversion of quadratic to cubic Bezier curves in PDF + and PS backends. Patch by Jae-Joon Lee. - JKS + 2008年09月06日 Added 5-point star marker to plot command - EF 2008年09月05日 Fix hatching in PS backend - MGD Added: trunk/matplotlib/examples/api/quad_bezier.py =================================================================== --- trunk/matplotlib/examples/api/quad_bezier.py (rev 0) +++ trunk/matplotlib/examples/api/quad_bezier.py 2008年09月07日 10:57:15 UTC (rev 6072) @@ -0,0 +1,17 @@ +import numpy as np +import matplotlib.path as mpath +import matplotlib.patches as mpatches +import matplotlib.pyplot as plt + +fig = plt.figure() +ax = fig.add_subplot(111) +pp1 = mpatches.PathPatch( + mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)], [1, 3, 3, 5]), + fc="none", transform=ax.transData) + +ax.add_patch(pp1) +ax.plot([0.75], [0.25], "ro") +ax.set_title('The red point should be on the path') + +plt.draw() + Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月06日 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月07日 10:57:15 UTC (rev 6072) @@ -127,7 +127,8 @@ 'colorbar_only.py', 'color_cycle.py', 'donut_demo.py', - 'path_patch_demo.py' + 'path_patch_demo.py', + 'quad_bezier.py' ] units_dir = os.path.join('..', 'units') Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月06日 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月07日 10:57:15 UTC (rev 6072) @@ -26,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.backends.backend_mixed import MixedModeRenderer from matplotlib.cbook import Bunch, is_string_like, reverse_dict, \ - get_realpath_and_stat, is_writable_file_like, maxdict + get_realpath_and_stat, is_writable_file_like, maxdict, quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM @@ -1096,6 +1096,7 @@ tpath = transform.transform_path(path) cmds = [] + last_points = None for points, code in tpath.iter_segments(): if code == Path.MOVETO: cmds.extend(points) @@ -1104,15 +1105,15 @@ cmds.extend(points) cmds.append(Op.lineto) elif code == Path.CURVE3: - cmds.extend([points[0], points[1], - points[0], points[1], - points[2], points[3], - Op.curveto]) + points = quad2cubic(*(list(last_points[-2:]) + list(points))) + cmds.extend(points) + cmds.append(Op.curveto) elif code == Path.CURVE4: cmds.extend(points) cmds.append(Op.curveto) elif code == Path.CLOSEPOLY: cmds.append(Op.closepath) + last_points = points return cmds pathOperations = staticmethod(pathOperations) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月06日 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月07日 10:57:15 UTC (rev 6072) @@ -20,7 +20,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import is_string_like, get_realpath_and_stat, \ - is_writable_file_like, maxdict + is_writable_file_like, maxdict, quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font @@ -448,22 +448,23 @@ path = transform.transform_path(path) ps = [] + last_points = None for points, code in path.iter_segments(): if code == Path.MOVETO: ps.append("%g %g m" % tuple(points)) elif code == Path.LINETO: ps.append("%g %g l" % tuple(points)) elif code == Path.CURVE3: + points = quad2cubic(*(list(last_points[-2:]) + list(points))) ps.append("%g %g %g %g %g %g c" % - (points[0], points[1], - points[0], points[1], - points[2], points[3])) + tuple(points[2:])) elif code == Path.CURVE4: ps.append("%g %g %g %g %g %g c" % tuple(points)) elif code == Path.CLOSEPOLY: ps.append("cl") + last_points = points + ps = "\n".join(ps) - return ps def _get_clip_path(self, clippath, clippath_transform): Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月06日 21:37:53 UTC (rev 6071) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月07日 10:57:15 UTC (rev 6072) @@ -1390,6 +1390,20 @@ """ return np.all(X[0] == X[-1]) +def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): + """ + Converts a quadratic Bezier curve to a cubic approximation. + + The inputs are the x and y coordinates of the three control points + of a quadratic curve, and the output is a tuple of x and y + coordinates of the four control points of the cubic curve. + """ + # c0x, c0y = q0x, q0y + c1x, c1y = q0x + 2./3. * (q1x - q0x), q0y + 2./3. * (q1y - q0y) + c2x, c2y = c1x + 1./3. * (q2x - q0x), c1y + 1./3. * (q2y - q0y) + # c3x, c3y = q2x, q2y + return q0x, q0y, c1x, c1y, c2x, c2y, q2x, q2y + # a dict to cross-map linestyle arguments _linestyles = [('-', 'solid'), ('--', 'dashed'), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6071 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6071&view=rev Author: efiring Date: 2008年09月06日 21:37:53 +0000 (2008年9月06日) Log Message: ----------- Add star marker to Line2D and plot Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/line_styles.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月05日 15:37:01 UTC (rev 6070) +++ trunk/matplotlib/CHANGELOG 2008年09月06日 21:37:53 UTC (rev 6071) @@ -1,3 +1,5 @@ +2008年09月06日 Added 5-point star marker to plot command - EF + 2008年09月05日 Fix hatching in PS backend - MGD 2008年09月03日 Fix log with base 2 - MGD Modified: trunk/matplotlib/examples/pylab_examples/line_styles.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/line_styles.py 2008年09月05日 15:37:01 UTC (rev 6070) +++ trunk/matplotlib/examples/pylab_examples/line_styles.py 2008年09月06日 21:37:53 UTC (rev 6071) @@ -1,26 +1,36 @@ #!/usr/bin/env python -from pylab import * +# This should probably be replaced with a demo that shows all +# line and marker types in a single panel, with labels. -t = arange(0.0, 3.0, 0.05) -s = sin(2*pi*t) -styles = ('-', '--', ':', '.', 'o', '^', 'v', '<', '>', 's', '+') +import matplotlib.pyplot as plt +from matplotlib.lines import Line2D +import numpy as np + +t = np.arange(0.0, 1.0, 0.1) +s = np.sin(2*np.pi*t) +linestyles = ['_', '-', '--', ':'] +markers = [] +for m in Line2D.markers: + try: + if len(m) == 1 and m != ' ': + markers.append(m) + except TypeError: + pass + +styles = linestyles + markers + colors = ('b', 'g', 'r', 'c', 'm', 'y', 'k') axisNum = 0 for row in range(5): - for col in range(4): - s = sin(2*pi*t) + for col in range(5): axisNum += 1 - subplot(5,4,axisNum) + ax = plt.subplot(5, 5, axisNum) style = styles[axisNum % len(styles) ] color = colors[axisNum % len(colors) ] - plot(t,s, style + color) - # turn off the ticklabels if not first row or first col - if not gca().is_first_col(): - setp(gca(), 'yticklabels', []) - if not gca().is_last_row(): - setp(gca(), 'xticklabels', []) + plt.plot(t,s, style + color, markersize=10) + ax.set_yticklabels([]) + ax.set_xticklabels([]) -#savefig('line_styles', dpi=300) -show() +plt.show() Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年09月05日 15:37:01 UTC (rev 6070) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年09月06日 21:37:53 UTC (rev 6071) @@ -3030,6 +3030,7 @@ > # triangle right symbols s # square symbols + # plus symbols + * # star symbols x # cross symbols D # diamond symbols d # thin diamond symbols Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年09月05日 15:37:01 UTC (rev 6070) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年09月06日 21:37:53 UTC (rev 6071) @@ -99,6 +99,7 @@ '4' : '_draw_tri_right', 's' : '_draw_square', 'p' : '_draw_pentagon', + '*' : '_draw_star', 'h' : '_draw_hexagon1', 'H' : '_draw_hexagon2', '+' : '_draw_plus', @@ -120,7 +121,8 @@ '' : '_draw_nothing', } - filled_markers = ('o', '^', 'v', '<', '>', 's', 'd', 'D', 'h', 'H', 'p') + filled_markers = ('o', '^', 'v', '<', '>', + 's', 'd', 'D', 'h', 'H', 'p', '*') zorder = 2 validCap = ('butt', 'round', 'projecting') @@ -573,7 +575,7 @@ """ Set the line marker - ACCEPTS: [ '+' | ',' | '.' | '1' | '2' | '3' | '4' + ACCEPTS: [ '+' | '*' | ',' | '.' | '1' | '2' | '3' | '4' | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd' | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|' | TICKUP | TICKDOWN | TICKLEFT | TICKRIGHT @@ -815,7 +817,15 @@ renderer.draw_markers(gc, Path.unit_regular_polygon(5), transform, path, path_trans, rgbFace) + def _draw_star(self, renderer, gc, path, path_trans): + offset = 0.5 * renderer.points_to_pixels(self._markersize) + transform = Affine2D().scale(offset) + rgbFace = self._get_rgb_face() + _starpath = Path.unit_regular_star(5, innerCircle=0.381966) + renderer.draw_markers(gc, _starpath, transform, + path, path_trans, rgbFace) + def _draw_hexagon1(self, renderer, gc, path, path_trans): offset = 0.5 * renderer.points_to_pixels(self._markersize) transform = Affine2D().scale(offset) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6070 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6070&view=rev Author: jswhit Date: 2008年09月05日 15:37:01 +0000 (2008年9月05日) Log Message: ----------- allow for 'cache' option when accessing remote datasets. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月05日 13:23:21 UTC (rev 6069) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月05日 15:37:01 UTC (rev 6070) @@ -3646,7 +3646,8 @@ else: return corners -def NetCDFFile(file, mode='r', maskandscale=True, username=None, password=None): +def NetCDFFile(file, mode='r', maskandscale=True, cache=None,\ + username=None, password=None, verbose=False): """NetCDF File reader/writer. API is the same as Scientific.IO.NetCDF. If ``file`` is a URL that starts with `http`, it is assumed @@ -3666,9 +3667,17 @@ To suppress these automatic conversions, set the ``maskandscale`` keyword to False. + The keywords ``cache``, ``username``, ``password`` and ``verbose`` are only + valid for remote OPenDAP datasets. ``username`` and ``password`` are used + to access OPenDAP datasets that require authentication. ``verbose=True`` + will make the pydap client print out the URLs being accessed. + ``cache`` is a location (a directory) for caching data, so that repeated + accesses to the same URL avoid the network. + """ if file.startswith('http'): - return netcdf._RemoteFile(file,maskandscale=maskandscale,username=username,password=password) + return netcdf._RemoteFile(file,maskandscale=maskandscale,\ + cache=cache,username=username,password=password,verbose=verbose) else: return netcdf.netcdf_file(file,mode=mode,maskandscale=maskandscale) Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py 2008年09月05日 13:23:21 UTC (rev 6069) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py 2008年09月05日 15:37:01 UTC (rev 6070) @@ -8,8 +8,10 @@ class _RemoteFile(object): """A NetCDF file reader. API is the same as Scientific.IO.NetCDF.""" - def __init__(self, file, maskandscale=False, username=None, password=None): - self._buffer = open_remote(file,username=username,password=password) + def __init__(self, file, maskandscale=False, cache=None,\ + username=None, password=None, verbose=False): + self._buffer = open_remote(file,cache=cache,\ + username=username,password=password,verbose=verbose) self._maskandscale = maskandscale self._parse() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6069 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6069&view=rev Author: mdboom Date: 2008年09月05日 13:23:21 +0000 (2008年9月05日) Log Message: ----------- Merged revisions 5946-6068 via svnmerge from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint ........ r6050 | mdboom | 2008年08月25日 18:21:49 -0400 (2008年8月25日) | 2 lines Fix locale problems in SVG backend (thanks, Mathieu Leplatre for reporting) ........ Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-5945 + /branches/v0_91_maint:1-6068 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6068 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6068&view=rev Author: mdboom Date: 2008年09月05日 13:15:20 +0000 (2008年9月05日) Log Message: ----------- Fix hatching in Postscript backend. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月05日 03:23:30 UTC (rev 6067) +++ trunk/matplotlib/CHANGELOG 2008年09月05日 13:15:20 UTC (rev 6068) @@ -1,3 +1,5 @@ +2008年09月05日 Fix hatching in PS backend - MGD + 2008年09月03日 Fix log with base 2 - MGD 2008年09月01日 Added support for bilinear interpolation in Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月05日 03:23:30 UTC (rev 6067) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月05日 13:15:20 UTC (rev 6068) @@ -800,10 +800,6 @@ write(ps.strip()) write("\n") - hatch = gc.get_hatch() - if hatch: - self.set_hatch(hatch) - if fill: if stroke: write("gsave\n") @@ -812,6 +808,11 @@ else: self.set_color(store=0, *rgbFace[:3]) write("fill\n") + + hatch = gc.get_hatch() + if hatch: + self.set_hatch(hatch) + if stroke: write("stroke\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6067 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6067&view=rev Author: efiring Date: 2008年09月05日 03:23:30 +0000 (2008年9月05日) Log Message: ----------- Improve masked array support in collections and quiver Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/line_collection.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/pylab_examples/line_collection.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/line_collection.py 2008年09月05日 02:02:49 UTC (rev 6066) +++ trunk/matplotlib/examples/pylab_examples/line_collection.py 2008年09月05日 03:23:30 UTC (rev 6067) @@ -1,33 +1,42 @@ -from pylab import * +import matplotlib.pyplot as plt from matplotlib.collections import LineCollection -from matplotlib.colors import ColorConverter -colorConverter = ColorConverter() +from matplotlib.colors import colorConverter +import numpy as np + # In order to efficiently plot many lines in a single set of axes, # Matplotlib has the ability to add the lines all at once. Here is a # simple example showing how it is done. -x = arange(200) +x = np.arange(100) # Here are many sets of y to plot vs x -ys = [x+i for i in x] +ys = x[:50, np.newaxis] + x[np.newaxis, :] -# We need to set the plot limits, the will not autoscale -ax = axes() -ax.set_xlim((amin(x),amax(x))) -ax.set_ylim((amin(amin(ys)),amax(amax(ys)))) +segs = np.zeros((50, 100, 2), float) +segs[:,:,1] = ys +segs[:,:,0] = x +# Mask some values to test masked array support: +segs = np.ma.masked_where((segs > 50) & (segs < 60), segs) + +# We need to set the plot limits. +ax = plt.axes() +ax.set_xlim(x.min(), x.max()) +ax.set_ylim(ys.min(), ys.max()) + # colors is sequence of rgba tuples # linestyle is a string or dash tuple. Legal string values are # solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) # where onoffseq is an even length tuple of on and off ink in points. # If linestyle is omitted, 'solid' is used # See matplotlib.collections.LineCollection for more information -line_segments = LineCollection([zip(x,y) for y in ys], # Make a sequence of x,y pairs +line_segments = LineCollection(segs, linewidths = (0.5,1,1.5,2), colors = [colorConverter.to_rgba(i) \ for i in ('b','g','r','c','m','y','k')], linestyle = 'solid') ax.add_collection(line_segments) -show() +ax.set_title('Line collection with masked arrays') +plt.show() Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008年09月05日 02:02:49 UTC (rev 6066) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008年09月05日 03:23:30 UTC (rev 6067) @@ -602,9 +602,13 @@ if closed: self._paths = [] for xy in verts: - xy = np.asarray(xy) - if len(xy) and (xy[0] != xy[-1]).any(): - xy = np.concatenate([xy, [xy[0]]]) + if np.ma.isMaskedArray(xy): + if len(xy) and (xy[0] != xy[-1]).any(): + xy = np.ma.concatenate([xy, [xy[0]]]) + else: + xy = np.asarray(xy) + if len(xy) and (xy[0] != xy[-1]).any(): + xy = np.concatenate([xy, [xy[0]]]) self._paths.append(mpath.Path(xy)) else: self._paths = [mpath.Path(xy) for xy in verts] @@ -819,10 +823,14 @@ def set_segments(self, segments): if segments is None: return - segments = [np.asarray(seg, np.float_) for seg in segments] + _segments = [] + for seg in segments: + if not np.ma.isMaskedArray(seg): + seg = np.asarray(seg, np.float_) + _segments.append(seg) if self._uniform_offsets is not None: - segments = self._add_offsets(segments) - self._paths = [mpath.Path(seg) for seg in segments] + _segments = self._add_offsets(_segments) + self._paths = [mpath.Path(seg) for seg in _segments] set_verts = set_segments # for compatibility with PolyCollection Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月05日 02:02:49 UTC (rev 6066) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月05日 03:23:30 UTC (rev 6067) @@ -57,7 +57,7 @@ match the column and row dimensions of *U*, then *X* and *Y* will be expanded with :func:`numpy.meshgrid`. -*U*, *V*, *C* may be masked arrays, but masked *X*, ** are not +*U*, *V*, *C* may be masked arrays, but masked *X*, *Y* are not supported at present. Keyword arguments: @@ -334,12 +334,6 @@ def __init__(self, ax, *args, **kw): self.ax = ax X, Y, U, V, C = self._parse_args(*args) - if C is not None: - X, Y, U, V, C = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), - V.ravel(),C.ravel()) - else: - X, Y, U, V = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(), - V.ravel()) self.X = X self.Y = Y self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) @@ -357,7 +351,9 @@ kw.setdefault('facecolors', self.color) kw.setdefault('linewidths', (0,)) collections.PolyCollection.__init__(self, [], offsets=self.XY, - transOffset=ax.transData, **kw) + transOffset=ax.transData, + closed=False, + **kw) self.polykw = kw self.set_UVC(U, V, C) self._initialized = False @@ -420,7 +416,7 @@ self._init() if self._new_UV: verts = self._make_verts(self.U, self.V) - self.set_verts(verts) + self.set_verts(verts, closed=False) self._new_UV = False collections.PolyCollection.draw(self, renderer) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6066 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6066&view=rev Author: jswhit Date: 2008年09月05日 02:02:49 +0000 (2008年9月05日) Log Message: ----------- allow for username and password for remote opendap datasets. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月04日 19:56:37 UTC (rev 6065) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月05日 02:02:49 UTC (rev 6066) @@ -3646,7 +3646,7 @@ else: return corners -def NetCDFFile(file, mode='r', maskandscale=True): +def NetCDFFile(file, mode='r', maskandscale=True, username=None, password=None): """NetCDF File reader/writer. API is the same as Scientific.IO.NetCDF. If ``file`` is a URL that starts with `http`, it is assumed @@ -3668,7 +3668,7 @@ """ if file.startswith('http'): - return netcdf._RemoteFile(file,maskandscale=maskandscale) + return netcdf._RemoteFile(file,maskandscale=maskandscale,username=username,password=password) else: return netcdf.netcdf_file(file,mode=mode,maskandscale=maskandscale) Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py 2008年09月04日 19:56:37 UTC (rev 6065) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdf.py 2008年09月05日 02:02:49 UTC (rev 6066) @@ -8,8 +8,8 @@ class _RemoteFile(object): """A NetCDF file reader. API is the same as Scientific.IO.NetCDF.""" - def __init__(self, file, maskandscale=False): - self._buffer = open_remote(file) + def __init__(self, file, maskandscale=False, username=None, password=None): + self._buffer = open_remote(file,username=username,password=password) self._maskandscale = maskandscale self._parse() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6065 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6065&view=rev Author: ryanmay Date: 2008年09月04日 19:56:37 +0000 (2008年9月04日) Log Message: ----------- Document the linestyles keyword argument to contour. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/contour.py Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008年09月04日 19:52:42 UTC (rev 6064) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008年09月04日 19:56:37 UTC (rev 6065) @@ -998,13 +998,26 @@ *linewidths*: [ None | number | tuple of numbers ] If *linewidths* is *None*, the default width in - ``lines.linewidth`` in ``matplotlibrc`` is used + ``lines.linewidth`` in ``matplotlibrc`` is used. If a number, all levels will be plotted with this linewidth. If a tuple, different levels will be plotted with different linewidths in the order specified + *linestyles*: [None | 'solid' | 'dashed' | 'dashdot' | 'dotted' ] + If *linestyles* is *None*, the 'solid' is used. + + *linestyles* can also be an iterable of the above strings + specifying a set of linestyles to be used. If this + iterable is shorter than the number of contour levels + it will be repeated as necessary. + + If contour is using a monochrome colormap and the contour + level is less than 0, then the linestyle specified + in ``contour.negative_linestyle`` in ``matplotlibrc`` + will be used. + contourf-only keyword arguments: *antialiased*: [ True | False ] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6064 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6064&view=rev Author: ryanmay Date: 2008年09月04日 19:52:42 +0000 (2008年9月04日) Log Message: ----------- Fix typo (iterator()->iterable()) for setting linestyles in Collection class. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/collections.py Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008年09月04日 18:29:28 UTC (rev 6063) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008年09月04日 19:52:42 UTC (rev 6064) @@ -284,7 +284,7 @@ dashes.append(dashd[cbook.ls_mapper[x]]) else: raise ValueError() - elif cbook.iterator(x) and len(x) == 2: + elif cbook.iterable(x) and len(x) == 2: dashes.append(x) else: raise ValueError() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6063 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6063&view=rev Author: ryanmay Date: 2008年09月04日 18:29:28 +0000 (2008年9月04日) Log Message: ----------- Correct return in docstring for boxplot. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年09月03日 19:58:01 UTC (rev 6062) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年09月04日 18:29:28 UTC (rev 6063) @@ -4504,8 +4504,9 @@ *x* is an array or a sequence of vectors. - Returns a list of the :class:`matplotlib.lines.Line2D` - instances added. + Returns a dictionary mapping each component of the boxplot + to a list of the :class:`matplotlib.lines.Line2D` + instances created. **Example:** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6062 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6062&view=rev Author: mdboom Date: 2008年09月03日 19:58:01 +0000 (2008年9月03日) Log Message: ----------- Add donut demo (to demonstrate compound paths) Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py Added Paths: ----------- trunk/matplotlib/examples/api/donut_demo.py Added: trunk/matplotlib/examples/api/donut_demo.py =================================================================== --- trunk/matplotlib/examples/api/donut_demo.py (rev 0) +++ trunk/matplotlib/examples/api/donut_demo.py 2008年09月03日 19:58:01 UTC (rev 6062) @@ -0,0 +1,54 @@ +import numpy as np +import matplotlib.path as mpath +import matplotlib.patches as mpatches +import matplotlib.pyplot as plt + +def wise(v): + if v == 1: + return "CCW" + else: + return "CW" + +def make_circle(r): + t = np.arange(0, np.pi * 2.0, 0.01) + t = t.reshape((len(t), 1)) + x = r * np.cos(t) + y = r * np.sin(t) + return np.hstack((x, y)) + +Path = mpath.Path + +fig = plt.figure() +ax = fig.add_subplot(111) + +inside_vertices = make_circle(0.5) +outside_vertices = make_circle(1.0) +codes = np.ones(len(inside_vertices), dtype=mpath.Path.code_type) * mpath.Path.LINETO +codes[0] = mpath.Path.MOVETO + +for i, (inside, outside) in enumerate(((1, 1), (1, -1), (-1, 1), (-1, -1))): + # Concatenate the inside and outside subpaths together, changing their + # order as needed + vertices = np.concatenate((outside_vertices[::outside], + inside_vertices[::inside])) + # Shift the path + vertices[:, 0] += i * 2.5 + # The codes will be all "LINETO" commands, except for "MOVETO"s at the + # beginning of each subpath + all_codes = np.concatenate((codes, codes)) + # Create the Path object + path = mpath.Path(vertices, all_codes) + # Add plot it + patch = mpatches.PathPatch(path, facecolor='#885500', edgecolor='black') + ax.add_patch(patch) + + ax.annotate("Outside %s,\nInside %s" % (wise(outside), wise(inside)), + (i * 2.5, -1.5), va="top", ha="center") + +ax.set_xlim(-2,10) +ax.set_ylim(-3,2) +ax.set_title('Mmm, donuts!') +ax.set_aspect(1.0) +plt.show() + + Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月03日 19:15:22 UTC (rev 6061) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月03日 19:58:01 UTC (rev 6062) @@ -126,6 +126,8 @@ api_files = [ 'colorbar_only.py', 'color_cycle.py', + 'donut_demo.py', + 'path_patch_demo.py' ] units_dir = os.path.join('..', 'units') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6061 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6061&view=rev Author: mdboom Date: 2008年09月03日 19:15:22 +0000 (2008年9月03日) Log Message: ----------- [ 2091036 ] Using log axes with base 2 fails Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/scale.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月01日 22:50:47 UTC (rev 6060) +++ trunk/matplotlib/CHANGELOG 2008年09月03日 19:15:22 UTC (rev 6061) @@ -1,3 +1,5 @@ +2008年09月03日 Fix log with base 2 - MGD + 2008年09月01日 Added support for bilinear interpolation in NonUniformImage; patch by Gregory Lielens. - EF Modified: trunk/matplotlib/lib/matplotlib/scale.py =================================================================== --- trunk/matplotlib/lib/matplotlib/scale.py 2008年09月01日 22:50:47 UTC (rev 6060) +++ trunk/matplotlib/lib/matplotlib/scale.py 2008年09月03日 19:15:22 UTC (rev 6061) @@ -91,7 +91,7 @@ def transform(self, a): a = _mask_non_positives(a * 2.0) if isinstance(a, MaskedArray): - return ma.log2(a) + return ma.log(a) / np.log(2) return np.log2(a) def inverted(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6060 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6060&view=rev Author: efiring Date: 2008年09月01日 22:50:47 +0000 (2008年9月01日) Log Message: ----------- Allocate acols, arows only if needed; change suggested by Mike D. Other slight cleanups in _image.cpp. Modified Paths: -------------- trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2008年09月01日 22:27:07 UTC (rev 6059) +++ trunk/matplotlib/src/_image.cpp 2008年09月01日 22:50:47 UTC (rev 6060) @@ -711,7 +711,7 @@ size_t numrows = (size_t)Py::Int(args[0]); size_t numcols = (size_t)Py::Int(args[1]); - if (numrows > 1 << 15 || numcols > 1 << 15) { + if (numrows >= 32768 || numcols >= 32768) { throw Py::RuntimeError("numrows and numcols must both be less than 32768"); } @@ -1088,7 +1088,7 @@ size_t x = Py::Int(args[1]); size_t y = Py::Int(args[2]); - if (x > 1 << 15 || y > 1 << 15) { + if (x >= 32768 || y >= 32768) { throw Py::ValueError("x and y must both be less than 32768"); } @@ -1335,7 +1335,7 @@ PyMem_Free(arows); return; } - + Py::Object _image_module::pcolor(const Py::Tuple& args) { _VERBOSE("_image_module::pcolor"); @@ -1352,7 +1352,7 @@ Py::Tuple bounds = args[5]; unsigned int interpolation = Py::Int(args[6]); - if (rows > 1 << 15 || cols > 1 << 15) { + if (rows >= 32768 || cols >= 32768) { throw Py::ValueError("rows and cols must both be less than 32768"); } @@ -1370,11 +1370,11 @@ // Check we have something to output to if (rows == 0 || cols ==0) throw Py::ValueError("Cannot scale to zero size"); - + PyArrayObject *x = NULL; PyArrayObject *y = NULL; PyArrayObject *d = NULL; unsigned int * rowstarts = NULL; unsigned int*colstarts = NULL; float *acols = NULL; float *arows = NULL; - + // Get numpy arrays x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), PyArray_FLOAT, 1, 1); if (x == NULL) { @@ -1406,14 +1406,12 @@ // Allocate memory for pointer arrays rowstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*rows)); - arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows)); - if (rowstarts == NULL || arows == NULL ) { + if (rowstarts == NULL) { _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); throw Py::MemoryError("Cannot allocate memory for lookup table"); } colstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*cols)); - acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols)); - if (colstarts == NULL || acols == NULL) { + if (colstarts == NULL) { _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); throw Py::MemoryError("Cannot allocate memory for lookup table"); } @@ -1430,8 +1428,8 @@ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); throw Py::MemoryError("Could not allocate memory for image"); } - + // Calculate the pointer arrays to map input x to output x unsigned int i, j; unsigned int * colstart = colstarts; @@ -1451,7 +1449,7 @@ start = reinterpret_cast<unsigned char*>(d->data); int s0 = d->strides[0]; int s1 = d->strides[1]; - + if(interpolation == Image::NEAREST) { _bin_indices_middle(colstart, cols, xs1, nx,dx,x_min); _bin_indices_middle(rowstart, rows, ys1, ny, dy,y_min); @@ -1473,11 +1471,22 @@ } } else if(interpolation == Image::BILINEAR) { + arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows)); + if (arows == NULL ) { + _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); + throw Py::MemoryError("Cannot allocate memory for lookup table"); + } + acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols)); + if (acols == NULL) { + _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); + throw Py::MemoryError("Cannot allocate memory for lookup table"); + } + _bin_indices_middle_linear(acols, colstart, cols, xs1, nx,dx,x_min); _bin_indices_middle_linear(arows, rowstart, rows, ys1, ny, dy,y_min); double a00,a01,a10,a11,alpha,beta; - - + + agg::int8u * start00; agg::int8u * start01; agg::int8u * start10; @@ -1489,12 +1498,12 @@ { alpha=arows[i]; beta=acols[j]; - + a00=alpha*beta; a01=alpha*(1.0-beta); a10=(1.0-alpha)*beta; a11=1.0-a00-a01-a10; - + start00=(agg::int8u *)(start + s0*rowstart[i] + s1*colstart[j]); start01=start00+s1; start10=start00+s0; @@ -1506,22 +1515,18 @@ position += 4; } } - + } - - // Attatch output buffer to output buffer + // Attach output buffer to output buffer imo->rbufOut = new agg::rendering_buffer; imo->bufferOut = buffer; imo->rbufOut->attach(imo->bufferOut, imo->colsOut, imo->rowsOut, imo->colsOut * imo->BPP); - _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows); return Py::asObject(imo); - - } @@ -1548,7 +1553,7 @@ Py::Tuple bounds = args[5]; Py::Object bgp = args[6]; - if (rows > 1 << 15 || cols > 1 << 15) { + if (rows >= 32768 || cols >= 32768) { throw Py::ValueError("rows and cols must both be less than 32768"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.