Revision: 4828 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4828&view=rev Author: mdboom Date: 2008年01月09日 09:59:17 -0800 (2008年1月09日) Log Message: ----------- Fix pie charts (wedges). Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年01月09日 01:27:29 UTC (rev 4827) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年01月09日 17:59:17 UTC (rev 4828) @@ -491,7 +491,7 @@ Returns a wedge of the unit circle from angle theta1 to angle theta2 (in degrees). """ - return cls.arc(theta1, theta2, True, n) + return cls.arc(theta1, theta2, n, True) wedge = classmethod(wedge) _get_path_collection_extents = get_path_collection_extents This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4892 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4892&view=rev Author: mdboom Date: 2008年01月23日 12:33:27 -0800 (2008年1月23日) Log Message: ----------- Fix exception with maskedarray branch of numpy (Thanks, David Huard) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年01月23日 19:12:41 UTC (rev 4891) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年01月23日 20:33:27 UTC (rev 4892) @@ -117,7 +117,7 @@ codes = self.LINETO * npy.ones( len(vertices), self.code_type) codes[0] = self.MOVETO - vertices = ma.compress(npy.invert(mask1d), vertices, 0) + vertices = npy.compress(npy.invert(mask1d), vertices, 0) vertices = npy.asarray(vertices) codes = npy.where(npy.concatenate((mask1d[-1:], mask1d[:-1])), self.MOVETO, codes) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4893 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4893&view=rev Author: efiring Date: 2008年01月23日 14:35:10 -0800 (2008年1月23日) Log Message: ----------- streamline handling of masked values in Path.__init__ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年01月23日 20:33:27 UTC (rev 4892) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年01月23日 22:35:10 UTC (rev 4893) @@ -101,7 +101,7 @@ mask = ma.nomask if codes is not None: - codes = npy.asarray(codes, self.code_type) + codes = npy.asarray(codes, self.code_type) assert codes.ndim == 1 assert len(codes) == len(vertices) @@ -112,17 +112,15 @@ # MOVETO commands to the codes array accordingly. if is_mask: if mask is not ma.nomask: - mask1d = ma.mask_or(mask[:, 0], mask[:, 1]) + mask1d = npy.logical_or.reduce(mask, axis=1) + gmask1d = npy.invert(mask1d) if codes is None: - codes = self.LINETO * npy.ones( - len(vertices), self.code_type) + codes = npy.empty((len(vertices)), self.code_type) + codes.fill(self.LINETO) codes[0] = self.MOVETO - vertices = npy.compress(npy.invert(mask1d), vertices, 0) - vertices = npy.asarray(vertices) - codes = npy.where(npy.concatenate((mask1d[-1:], mask1d[:-1])), - self.MOVETO, codes) - codes = ma.masked_array(codes, mask=mask1d).compressed() - codes = npy.asarray(codes, self.code_type) + vertices = vertices[gmask1d].filled() # ndarray + codes[npy.roll(mask1d, 1)] = self.MOVETO + codes = codes[gmask1d] # npy.compress is much slower else: vertices = npy.asarray(vertices, npy.float_) @@ -130,7 +128,7 @@ assert vertices.shape[1] == 2 self.codes = codes - self.vertices = vertices + self.vertices = vertices #@staticmethod def make_compound_path(*args): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4905 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4905&view=rev Author: mdboom Date: 2008年01月29日 12:18:21 -0800 (2008年1月29日) Log Message: ----------- Add safety check. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年01月28日 18:02:31 UTC (rev 4904) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年01月29日 20:18:21 UTC (rev 4905) @@ -456,6 +456,8 @@ # number of curve segments to make if n is None: n = int(2 ** npy.ceil((eta2 - eta1) / halfpi)) + if n < 1: + raise ValueError("n must be >= 1 or None") deta = (eta2 - eta1) / n t = npy.tan(0.5 * deta) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4908 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4908&view=rev Author: mdboom Date: 2008年01月29日 12:50:53 -0800 (2008年1月29日) Log Message: ----------- Bugfix for Python pre-2.5 (Thanks Jorgen Stenarson and Nils Wagner) Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年01月29日 20:24:58 UTC (rev 4907) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年01月29日 20:50:53 UTC (rev 4908) @@ -198,7 +198,7 @@ elif code == STOP: return else: - num_vertices = NUM_VERTICES[code] + num_vertices = NUM_VERTICES[int(code)] curr_vertices = vertices[i:i+num_vertices].flatten() if any(isnan(curr_vertices)): was_nan = True This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4981 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4981&view=rev Author: mdboom Date: 2008年02月19日 11:41:53 -0800 (2008年2月19日) Log Message: ----------- Don't cache many-sided unit regular polygons -- just the small ones -- otherwise we could end up caching many large things. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年02月19日 15:56:10 UTC (rev 4980) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年02月19日 19:41:53 UTC (rev 4981) @@ -317,7 +317,10 @@ Returns a Path for a unit regular polygon with the given numVertices and radius of 1.0, centered at (0, 0). """ - path = cls._unit_regular_polygons.get(numVertices) + if numVertices <= 16: + path = cls._unit_regular_polygons.get(numVertices) + else: + path = None if path is None: theta = (2*npy.pi/numVertices * npy.arange(numVertices + 1).reshape((numVertices + 1, 1))) @@ -337,7 +340,10 @@ Returns a Path for a unit regular star with the given numVertices and radius of 1.0, centered at (0, 0). """ - path = cls._unit_regular_stars.get((numVertices, innerCircle)) + if numVertices <= 16: + path = cls._unit_regular_stars.get((numVertices, innerCircle)) + else: + path = None if path is None: ns2 = numVertices * 2 theta = (2*npy.pi/ns2 * npy.arange(ns2 + 1)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5575 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5575&view=rev Author: mdboom Date: 2008年06月17日 08:06:29 -0700 (2008年6月17日) Log Message: ----------- Hopefully got to_polygons correct now. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年06月17日 14:59:13 UTC (rev 5574) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年06月17日 15:06:29 UTC (rev 5575) @@ -300,11 +300,13 @@ if transform is not None: transform = transform.frozen() - if self.codes is None: + + if self.codes is None and width == 0 or height == 0: + if transform is None: + return [self.vertices] + else: return [transform.transform(self.vertices)] - else: - if self.codes is None: - return [self.vertices] + # Deal with the case where there are curves and/or multiple # subpaths (using extension code) return convert_path_to_polygons(self, transform, width, height) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5576 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5576&view=rev Author: mdboom Date: 2008年06月17日 08:09:09 -0700 (2008年6月17日) Log Message: ----------- Hopefully got to_polygons correct now. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年06月17日 15:06:29 UTC (rev 5575) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年06月17日 15:09:09 UTC (rev 5576) @@ -301,7 +301,7 @@ if transform is not None: transform = transform.frozen() - if self.codes is None and width == 0 or height == 0: + if self.codes is None and (width == 0 or height == 0): if transform is None: return [self.vertices] else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5643 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5643&view=rev Author: mdboom Date: 2008年06月23日 05:52:01 -0700 (2008年6月23日) Log Message: ----------- Fix docstrings. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年06月23日 12:44:28 UTC (rev 5642) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年06月23日 12:52:01 UTC (rev 5643) @@ -19,8 +19,8 @@ closed, line and curve segments. The underlying storage is made up of two parallel numpy arrays: - - vertices: an Nx2 float array of vertices - - codes: an N-length uint8 array of vertex types + - *vertices*: an Nx2 float array of vertices + - *codes*: an N-length uint8 array of vertex types These two arrays always have the same length in the first dimension. For example, to represent a cubic curve, you must @@ -52,9 +52,10 @@ Users of Path objects should not access the vertices and codes arrays directly. Instead, they should use :meth:`iter_segments` - to get the vertex/code pairs. This is important since many Paths, - as an optimization, do not store a codes array at all, but have a - default one provided for them by :meth:`iter_segments`. + to get the vertex/code pairs. This is important, since many + :class:`Path`s, as an optimization, do not store a codes array at + all, but have a default one provided for them by + :meth:`iter_segments`. """ # Path codes @@ -73,19 +74,20 @@ """ Create a new path with the given vertices and codes. - vertices is an Nx2 numpy float array, masked array or Python + *vertices* is an Nx2 numpy float array, masked array or Python sequence. - codes is an N-length numpy array or Python sequence of type - Path.code_type. + *codes* is an N-length numpy array or Python sequence of type + :attr:`matplotlib.path.Path.code_type`. These two arrays must have the same length in the first dimension. - If codes is None, vertices will be treated as a series of line - segments. If vertices contains masked values, the resulting - path will be compressed, with MOVETO codes inserted in the - correct places to jump over the masked regions. + If *codes* is None, *vertices* will be treated as a series of + line segments. If *vertices* contains masked values, the + resulting path will be compressed, with ``MOVETO`` codes + inserted in the correct places to jump over the masked + regions. """ if ma.isMaskedArray(vertices): is_mask = True @@ -219,10 +221,10 @@ def contains_point(self, point, transform=None): """ - Returns True if the path contains the given point. + Returns *True* if the path contains the given point. - If transform is not None, the path will be transformed before - performing the test. + If *transform* is not *None*, the path will be transformed + before performing the test. """ if transform is not None: transform = transform.frozen() @@ -230,10 +232,10 @@ def contains_path(self, path, transform=None): """ - Returns True if this path completely contains the given path. + Returns *True* if this path completely contains the given path. - If transform is not None, the path will be transformed before - performing the test. + If *transform* is not *None*, the path will be transformed + before performing the test. """ if transform is not None: transform = transform.frozen() @@ -241,9 +243,10 @@ def get_extents(self, transform=None): """ - Returns the extents (xmin, ymin, xmax, ymax) of the path. + Returns the extents (*xmin*, *ymin*, *xmax*, *ymax*) of the + path. - Unlike computing the extents on the vertices alone, this + Unlike computing the extents on the *vertices* alone, this algorithm will take into account the curves and deal with control points appropriately. """ @@ -254,13 +257,13 @@ def intersects_path(self, other): """ - Returns True if this path intersects another given path. + Returns *True* if this path intersects another given path. """ return path_intersects_path(self, other) def intersects_bbox(self, bbox): """ - Returns True if this path intersects a given + Returns *True* if this path intersects a given :class:`~matplotlib.transforms.Bbox`. """ from transforms import BboxTransformTo @@ -271,8 +274,8 @@ def interpolated(self, steps): """ - Returns a new path resampled to length N x steps. - Does not currently handle interpolating curves. + Returns a new path resampled to length N x steps. Does not + currently handle interpolating curves. """ vertices = simple_linear_interpolation(self.vertices, steps) codes = self.codes @@ -291,9 +294,9 @@ displaying in backends that do not support compound paths or Bezier curves, such as GDK. - If width and height are both non-zero then the lines will be - simplified so that vertices outside of (0, 0), (width, height) - will be clipped. + If *width* and *height* are both non-zero then the lines will + be simplified so that vertices outside of (0, 0), (width, + height) will be clipped. """ if len(self.vertices) == 0: return [] @@ -329,8 +332,8 @@ def unit_regular_polygon(cls, numVertices): """ (staticmethod) Returns a :class:`Path` for a unit regular - polygon with the given numVertices and radius of 1.0, centered - at (0, 0). + polygon with the given *numVertices* and radius of 1.0, + centered at (0, 0). """ if numVertices <= 16: path = cls._unit_regular_polygons.get(numVertices) @@ -451,11 +454,11 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False): """ (staticmethod) Returns an arc on the unit circle from angle - theta1 to angle theta2 (in degrees). + *theta1* to angle *theta2* (in degrees). - If n is provided, it is the number of spline segments to make. - If n is not provided, the number of spline segments is - determined based on the delta between theta1 and theta2. + If *n* is provided, it is the number of spline segments to make. + If *n* is not provided, the number of spline segments is + determined based on the delta between *theta1* and *theta2*. Masionobe, L. 2003. `Drawing an elliptical arc using polylines, quadratic or cubic Bezier curves @@ -530,7 +533,11 @@ def wedge(cls, theta1, theta2, n=None): """ (staticmethod) Returns a wedge of the unit circle from angle - theta1 to angle theta2 (in degrees). + *theta1* to angle *theta2* (in degrees). + + If *n* is provided, it is the number of spline segments to make. + If *n* is not provided, the number of spline segments is + determined based on the delta between *theta1* and *theta2*. """ return cls.arc(theta1, theta2, n, True) wedge = classmethod(wedge) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5703 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5703&view=rev Author: mdboom Date: 2008年07月01日 05:01:27 -0700 (2008年7月01日) Log Message: ----------- docstring fixes. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/path.py Modified: trunk/matplotlib/lib/matplotlib/path.py =================================================================== --- trunk/matplotlib/lib/matplotlib/path.py 2008年07月01日 11:59:22 UTC (rev 5702) +++ trunk/matplotlib/lib/matplotlib/path.py 2008年07月01日 12:01:27 UTC (rev 5703) @@ -24,7 +24,7 @@ These two arrays always have the same length in the first dimension. For example, to represent a cubic curve, you must - provide three vertices as well as three codes "CURVE3". + provide three vertices as well as three codes ``CURVE3``. The code types are: @@ -53,8 +53,8 @@ Users of Path objects should not access the vertices and codes arrays directly. Instead, they should use :meth:`iter_segments` to get the vertex/code pairs. This is important, since many - :class:`Path`s, as an optimization, do not store a codes array at - all, but have a default one provided for them by + :class:`Path` objects, as an optimization, do not store a *codes* + at all, but have a default one provided for them by :meth:`iter_segments`. """ @@ -168,16 +168,16 @@ if not len(vertices): return - codes = self.codes + codes = self.codes len_vertices = len(vertices) - isnan = np.isnan - any = np.any + isnan = np.isnan + any = np.any NUM_VERTICES = self.NUM_VERTICES - MOVETO = self.MOVETO - LINETO = self.LINETO - CLOSEPOLY = self.CLOSEPOLY - STOP = self.STOP + MOVETO = self.MOVETO + LINETO = self.LINETO + CLOSEPOLY = self.CLOSEPOLY + STOP = self.STOP if codes is None: next_code = MOVETO This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.