SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

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

Showing results of 5455

<< < 1 .. 198 199 200 201 202 .. 219 > >> (Page 200 of 219)
From: <md...@us...> - 2007年10月26日 16:03:06
Revision: 4011
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4011&view=rev
Author: mdboom
Date: 2007年10月26日 08:58:50 -0700 (2007年10月26日)
Log Message:
-----------
More coverage. Add draw_path_collection to SVG.
Modified Paths:
--------------
 branches/transforms/examples/backend_driver.py
 branches/transforms/examples/legend_auto.py
 branches/transforms/lib/matplotlib/axis.py
 branches/transforms/lib/matplotlib/backends/backend_ps.py
 branches/transforms/lib/matplotlib/backends/backend_svg.py
 branches/transforms/lib/matplotlib/figure.py
 branches/transforms/lib/matplotlib/quiver.py
 branches/transforms/lib/matplotlib/scale.py
 branches/transforms/lib/matplotlib/transforms.py
Modified: branches/transforms/examples/backend_driver.py
===================================================================
--- branches/transforms/examples/backend_driver.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/examples/backend_driver.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -55,6 +55,7 @@
 'image_origin.py',
 'invert_axes.py',
 'layer_images.py',
+ 'legend_auto.py',
 'legend_demo.py',
 'legend_demo2.py',
 'line_collection.py',
Modified: branches/transforms/examples/legend_auto.py
===================================================================
--- branches/transforms/examples/legend_auto.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/examples/legend_auto.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -79,7 +79,12 @@
 
 if __name__ == '__main__':
 nfigs = 10
- figures = [int(f) for f in sys.argv[1:]]
+ figures = []
+ for f in sys.argv[1:]:
+ try:
+ figures.append(int(f))
+ except ValueError:
+ pass
 if len(figures) == 0:
 figures = range(1, nfigs+1)
 
Modified: branches/transforms/lib/matplotlib/axis.py
===================================================================
--- branches/transforms/lib/matplotlib/axis.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/axis.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -18,7 +18,7 @@
 from font_manager import FontProperties
 from text import Text, TextWithDash, _process_text_args
 from transforms import Affine2D, Bbox, blended_transform_factory, interval_contains, \
- interval_contains_open, IntervalTransform, IdentityTransform
+ interval_contains_open, IdentityTransform
 from patches import bbox_artist
 from scale import scale_factory
 
Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -505,12 +505,13 @@
 path_codes = []
 for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
 master_transform, paths, all_transforms)):
- ps_cmd = ['/p%x_%x {' % (self._path_collection_id, i),
+ name = 'p%x_%x' % (self._path_collection_id, i)
+ ps_cmd = ['/%s {' % name,
 'newpath', 'translate']
 ps_cmd.append(self._convert_path(path, transform))
 ps_cmd.extend(['} bind def\n'])
 write('\n'.join(ps_cmd))
- path_codes.append("p%x_%x" % (self._path_collection_id, i))
+ path_codes.append(name)
 
 for xo, yo, path_id, gc, rgbFace in self._iter_collection(
 path_codes, cliprect, clippath, clippath_trans,
Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_svg.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/backends/backend_svg.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -42,6 +42,7 @@
 self._clipd = {}
 self._char_defs = {}
 self._markers = {}
+ self._path_collection_id = 0
 self.mathtext_parser = MathTextParser('SVG')
 self.fontd = {}
 svgwriter.write(svgProlog%(width,height,width,height))
@@ -192,7 +193,33 @@
 for x, y in tpath.vertices:
 details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y)
 self._draw_svg_element('use', details, gc, rgbFace)
+
+ def draw_path_collection(self, master_transform, cliprect, clippath,
+ clippath_trans, paths, all_transforms, offsets,
+ offsetTrans, facecolors, edgecolors, linewidths,
+ linestyles, antialiaseds):
+ write = self._svgwriter.write
+ 
+ path_codes = []
+ write('<defs>\n')
+ for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
+ master_transform, paths, all_transforms)):
+ name = 'coll%x_%x' % (self._path_collection_id, i)
+ transform = transform.frozen().scale(1.0, -1.0)
+ d = self._convert_path(path, transform)
+ write('<path id="%s" d="%s"/>\n' % (name, d))
+ path_codes.append(name)
+ write('</defs>\n')
 
+ for xo, yo, path_id, gc, rgbFace in self._iter_collection(
+ path_codes, cliprect, clippath, clippath_trans,
+ offsets, offsetTrans, facecolors, edgecolors,
+ linewidths, linestyles, antialiaseds):
+ details = 'xlink:href="#%s" x="%f" y="%f"' % (path_id, xo, self.height - yo)
+ self._draw_svg_element('use', details, gc, rgbFace)
+
+ self._path_collection_id += 1
+ 
 def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
 # MGDTODO: Support clippath here
 trans = [1,0,0,1,0,0]
Modified: branches/transforms/lib/matplotlib/figure.py
===================================================================
--- branches/transforms/lib/matplotlib/figure.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/figure.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -328,7 +328,7 @@
 w,h = args
 
 	dpival = self.dpi
-	self.bbox_inches.max = w, h
+	self.bbox_inches.p1 = w, h
 	
 if forward:
 dpival = self.dpi
@@ -339,7 +339,7 @@
 manager.resize(int(canvasw), int(canvash))
 
 def get_size_inches(self):
- return self.bbox_inches.max
+ return self.bbox_inches.p1
 
 def get_edgecolor(self):
 'Get the edge color of the Figure rectangle'
Modified: branches/transforms/lib/matplotlib/quiver.py
===================================================================
--- branches/transforms/lib/matplotlib/quiver.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/quiver.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -238,8 +238,8 @@
 self.set_transform(self.Q.ax.figure.transFigure)
 elif self.coord == 'inches':
 dx = ax.figure.dpi
- bb = transforms.Bbox(transforms.origin(), transforms.Point(dx, dx))
- trans = transforms.get_bbox_transform(transforms.unit_bbox(), bb)
+ bb = transforms.Bbox.from_extents(0, 0, dx, dy)
+ trans = transforms.BboxTransform(Bbox.unit(), bb)
 self.set_transform(trans)
 else:
 raise ValueError('unrecognized coordinates')
Modified: branches/transforms/lib/matplotlib/scale.py
===================================================================
--- branches/transforms/lib/matplotlib/scale.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/scale.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -6,8 +6,7 @@
 LogFormatter, LogFormatterMathtext
 from ticker import NullLocator, FixedLocator, LinearLocator, LogLocator, \
 AutoLocator
-from transforms import Affine1DBase, IntervalTransform, Transform, \
- composite_transform_factory, IdentityTransform
+from transforms import Transform, composite_transform_factory, IdentityTransform
 
 class ScaleBase(object):
 def set_default_locators_and_formatters(self, axis):
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py	2007年10月26日 03:40:33 UTC (rev 4010)
+++ branches/transforms/lib/matplotlib/transforms.py	2007年10月26日 15:58:50 UTC (rev 4011)
@@ -128,62 +128,63 @@
 might normally be used.
 """
 return self
- 
- def write_graphviz(self, fobj, highlight=[]):
- """
- For debugging purposes.
 
- Writes the transform tree rooted at 'self' to a graphviz "dot"
- format file. This file can be run through the "dot" utility
- to produce a graph of the transform tree.
+ if DEBUG:
+ def write_graphviz(self, fobj, highlight=[]):
+ """
+ For debugging purposes.
 
- Affine transforms are marked in blue. Bounding boxes are
- marked in yellow.
+ Writes the transform tree rooted at 'self' to a graphviz "dot"
+ format file. This file can be run through the "dot" utility
+ to produce a graph of the transform tree.
 
- fobj: A Python file-like object
- """
- if not DEBUG:
- return
- 
- seen = cbook.set()
+ Affine transforms are marked in blue. Bounding boxes are
+ marked in yellow.
 
- def recurse(root):
- if root in seen:
- return
- seen.add(root)
- props = {}
- label = root.__class__.__name__
- if root._invalid:
- label = '[%s]' % label
- if root in highlight:
- props['style'] = 'bold'
- if root.is_affine:
- props['shape'] = 'parallelogram'
- if root.is_bbox:
- props['shape'] = 'box'
- props['label'] = '"%s"' % label
- props = ' '.join(['%s=%s' % (key, val) for key, val in props.items()])
+ fobj: A Python file-like object
+ """
+ seen = cbook.set()
 
- fobj.write('%s [%s];\n' %
- (hash(root), props))
+ def recurse(root):
+ if root in seen:
+ return
+ seen.add(root)
+ props = {}
+ label = root.__class__.__name__
+ if root._invalid:
+ label = '[%s]' % label
+ if root in highlight:
+ props['style'] = 'bold'
+ if root.is_affine:
+ props['shape'] = 'parallelogram'
+ if root.is_bbox:
+ props['shape'] = 'box'
+ props['label'] = '"%s"' % label
+ props = ' '.join(['%s=%s' % (key, val) for key, val in props.items()])
 
- for child in root._children:
- name = '?'
- for key, val in root.__dict__.items():
- if val is child:
- name = key
- break
- fobj.write('%s -> %s [label="%s", fontsize=10];\n' % (
- hash(root),
- hash(child),
- name))
- recurse(child)
+ fobj.write('%s [%s];\n' %
+ (hash(root), props))
 
- fobj.write("digraph G {\n")
- recurse(self)
- fobj.write("}\n")
+ for child in root._children:
+ name = '?'
+ for key, val in root.__dict__.items():
+ if val is child:
+ name = key
+ break
+ fobj.write('%s -> %s [label="%s", fontsize=10];\n' % (
+ hash(root),
+ hash(child),
+ name))
+ recurse(child)
+
+ fobj.write("digraph G {\n")
+ recurse(self)
+ fobj.write("}\n")
+ else:
+ def write_graphviz(self, fobj, highlight=[]):
+ return
+ 
 
- 
 class BboxBase(TransformNode):
 """
 This is the base class of all bounding boxes, and provides
@@ -226,6 +227,14 @@
 return self.get_points()[1, 1]
 y1 = property(_get_y1)
 
+ def _get_p0(self):
+ return self.get_points()[0]
+ p0 = property(_get_p0)
+
+ def _get_p1(self):
+ return self.get_points()[1]
+ p1 = property(_get_p1)
+ 
 def _get_xmin(self):
 return min(self.get_points()[:, 0])
 xmin = property(_get_xmin)
@@ -737,15 +746,15 @@
 self.invalidate()
 y1 = property(BboxBase._get_y1, _set_y1)
 
- def _set_min(self, val):
+ def _set_p0(self, val):
 self._points[0] = val
 self.invalidate()
- min = property(BboxBase._get_min, _set_min)
- 
- def _set_max(self, val):
+ p0 = property(BboxBase._get_p0, _set_p0)
+
+ def _set_p1(self, val):
 self._points[1] = val
 self.invalidate()
- max = property(BboxBase._get_max, _set_max)
+ p1 = property(BboxBase._get_p1, _set_p1)
 
 def _set_intervalx(self, interval):
 self._points[:, 0] = interval
@@ -1137,240 +1146,6 @@
 get_affine.__doc__ = Transform.get_affine.__doc__
 
 
-class Affine1DBase(AffineBase):
- """
- The base class of all 1D affine transforms.
-
- Provides the read-only interface.
-
- 1D affine transformations are performed using a 2x2 numpy array:
- 
- a b
- 0 1
-
- where a is scale and b is translation.
- """
- input_dims = 1
- output_dims = 1
- is_separable = True
-
- def __init__(self):
- AffineBase.__init__(self)
-
- def frozen(self):
- return Affine1D(self.get_matrix().copy())
- frozen.__doc__ = AffineBase.frozen.__doc__
- 
- def __array__(self, *args, **kwargs):
-	return self.get_matrix()
-
- def to_values(self):
- """
- Returns a, b
- """
- mtx = self.get_matrix()
- return mtx[0]
- 
- #@staticmethod
- def matrix_from_values(a, b):
- """
- Create a new transformation matrix as a numpy array using the
- values a, b, where:
-
- a: scale
- b: translation
- """
- return npy.array([[a, b], [0.0, 1.0]], npy.float_)
- matrix_from_values = staticmethod(matrix_from_values)
-
- def transform(self, values):
- mtx = self.get_matrix()
- points = npy.asarray(values, npy.float_)
- return points * mtx[0, 0] + mtx[0, 1]
-
- if DEBUG:
- _transform = transform
- def transform(self, values):
- # The major speed trap here is just converting to the points
- # to an array in the first place. If we can use more arrays
- # upstream, that should help here.
- if not isinstance(values, npy.ndarray):
- warnings.warn(
- ('A non-numpy array of type %s was passed in for ' +
- 'transformation. Please correct this.')
- % type(values))
- return self._transform(values)
- transform.__doc__ = AffineBase.transform.__doc__
- 
- transform_affine = transform
- transform_affine.__doc__ = AffineBase.transform_affine.__doc__
- 
- def inverted(self):
- if self._inverted is None or self._invalid:
- mtx = self.get_matrix()
- self._inverted = Affine1D(inv(mtx))
- self._invalid = 0
- return self._inverted
- inverted.__doc__ = AffineBase.inverted.__doc__
-
- 
-class Affine1D(Affine1DBase):
- """
- A concrete 1D affine transformation.
-
- 1D affine transformations are performed using a 2x2 numpy array:
- 
- a b
- 0 1
-
- where a is scale and b is translation.
- """
- def __init__(self, matrix = None):
- """
- Initialize an Affine transform from a 2x2 numpy float array.
-
- If matrix is None, initialize with the identity transform.
- """
- Affine1DBase.__init__(self)
- if matrix is None:
- matrix = npy.identity(2)
- else:
-	 matrix = npy.asarray(matrix, npy.float_)
- assert matrix.shape == (2, 2)
- self._mtx = matrix
- self._invalid = 0
-
- def __repr__(self):
- return "Affine1D(%s)" % repr(self._mtx)
- __str__ = __repr__
-
- def __cmp__(self, other):
- if (isinstance(other, Affine1D) and
- (self.get_matrix() == other.get_matrix()).all()):
- return 0
- return -1
- 
- #@staticmethod
- def from_values(a, b):
- """
- Create a new Affine1D instance from the given values.
-
- a: scale
- b: translation
- """
- return Affine1D(Affine1D.matrix_from_values(a, b))
- from_values = staticmethod(from_values)
-
- def get_matrix(self):
- """
- Get the underlying transformation matrix as a 2x2 numpy array.
-
- a b
- 0 1
-
- where a is scale and b is translation.
- """
- self._invalid = 0
- return self._mtx
- 
- def set_matrix(self, mtx):
- """
- Set the underlying transformation matrix from a 2x2 numpy array.
- 
- a b
- 0 1
-
- where a is scale and b is translation.
- """
- self._mtx = mtx
- self.invalidate()
- 
- def set(self, other):
- """
- Set this transformation from a frozen copy of another
- Affine1DBase instance.
- """
- assert isinstance(other, Affine1DBase)
- self._mtx = other.get_matrix()
- self.invalidate()
- 
- #@staticmethod
- def identity():
- """
- Return a new Affine1D instance that is the identity transform.
-
- Unless this transform will be mutated later on, consider using
- the faster IdentityTransform class instead.
- """
- return Affine1D(npy.identity(2))
- identity = staticmethod(identity)
-
- def clear(self):
- """
- Resets this transformation back to the identity transform.
- """
- self._mtx = npy.identity(2)
- self.invalidate()
- return self
- 
- def translate(self, t):
- """
- Add a translation t to this transform.
-
- Returns self, so this method can easily be chained with more
- calls to translate() and scale().
- """
- self._mtx[0, 1] += t
- self.invalidate()
- return self
-
- def scale(self, s):
- """
- Add a scale s to this transform.
-
- Returns self, so this method can easily be chained with more
- calls to translate() and scale().
- """
- self._mtx[0, 0] *= s
- self.invalidate()
- return self
-
- 
-class IntervalTransform(Affine1DBase):
- """
- A 1D transformation that linearly transforms points along the
- input interval (0.0, 1.0) to an arbitrary child interval.
- """
- def __init__(self, bbox, direction):
- """
- bbox: A Bbox instance containing the child interval.
- direction: A string 'x' or 'y' indicating the interval of the
- bbox to use as the child interval.
- """
- assert direction in ('x', 'y')
- assert bbox.is_bbox
- 
- Affine1DBase.__init__(self)
- self._bbox = bbox
- self._direction = "interval" + direction
- self.set_children(bbox)
- self._mtx = None
- 
- def __repr__(self):
- return "IntervalTransform(%s)" % (getattr(self._bbox, self._direction))
- __str__ = __repr__
-
- def get_matrix(self):
- if self._invalid:
- vmin, vmax = getattr(self._bbox, self._direction)
- self._mtx = inv(npy.array([[vmax - vmin, vmin],
- [0.0, 1.0]], npy.float_))
- self._inverted = None
- self._invalid = 0
- return self._mtx
- get_matrix.__doc__ = Affine1DBase.get_matrix.__doc__
-
- 
 class Affine2DBase(AffineBase):
 """
 The base class of all 2D affine transformations.
@@ -1780,58 +1555,8 @@
 self._invalid = 0
 return self._affine
 get_affine.__doc__ = Transform.get_affine.__doc__
-
-
-class BlendedAffine1D(Affine2DBase):
- """
- A "blended" transform uses one transform for the x-direction, and
- another transform for the y-direction.
-
- This version is an optimization for the case where both child
- transforms are of type Affine1DBase.
- """
- is_separable = True
 
- def __init__(self, x_transform, y_transform):
- """
- Create a new "blended" transform using x_transform to
- transform the x-axis and y_transform to transform the y_axis.
-
- Both x_transform and y_transform must be 1D affine transforms.
- 
- You will generally not call this constructor directly but use
- the blended_transform_factory function instead, which can
- determine automatically which kind of blended transform to
- create.
- """
- assert isinstance(x_transform, Affine1DBase)
- assert isinstance(y_transform, Affine1DBase)
-
- Transform.__init__(self)
- self._x = x_transform
- self._y = y_transform
- self.set_children(x_transform, y_transform)
- 
- Affine2DBase.__init__(self)
- self._mtx = None
-
- def __repr__(self):
- return "BlendedAffine1D(%s,%s)" % (self._x, self._y)
- __str__ = __repr__
- 
- def get_matrix(self):
- if self._invalid:
- x_mtx = self._x.get_matrix()
- y_mtx = self._y.get_matrix()
- self._mtx = npy.array([[x_mtx[0, 0], 0.0, x_mtx[0, 1]],
- [0.0, y_mtx[0, 0], y_mtx[0, 1]],
- [0.0, 0.0, 1.0]])
- self._inverted = None
- self._invalid = 0
- return self._mtx
- get_matrix.__doc__ = Affine2DBase.get_matrix.__doc__
 
- 
 class BlendedAffine2D(Affine2DBase):
 """
 A "blended" transform uses one transform for the x-direction, and
@@ -1900,9 +1625,6 @@
 if (isinstance(x_transform, Affine2DBase)
 and isinstance(y_transform, Affine2DBase)):
 return BlendedAffine2D(x_transform, y_transform)
- elif (isinstance(x_transform, Affine1DBase)
- and isinstance(y_transform, Affine1DBase)):
- return BlendedAffine1D(x_transform, y_transform)
 return BlendedGenericTransform(x_transform, y_transform)
 
 
@@ -2235,7 +1957,7 @@
 
 bbox_copy = copy.deepcopy(bbox)
 assert (bbox.extents == bbox_copy.extents).all()
- bbox_copy.max = (14, 15)
+ bbox_copy.p1 = (14, 15)
 assert bbox.bounds == (10, 11, 12, 13)
 assert bbox_copy.bounds == (10, 11, 4, 4)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2007年10月26日 03:40:37
Revision: 4010
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4010&view=rev
Author: jdh2358
Date: 2007年10月25日 20:40:33 -0700 (2007年10月25日)
Log Message:
-----------
added quicksort example
Added Paths:
-----------
 trunk/py4science/examples/quicksort.c
Added: trunk/py4science/examples/quicksort.c
===================================================================
--- trunk/py4science/examples/quicksort.c	 (rev 0)
+++ trunk/py4science/examples/quicksort.c	2007年10月26日 03:40:33 UTC (rev 4010)
@@ -0,0 +1,115 @@
+/* Copyright (c) 2007 the authors listed at the following URL, and/or
+the authors of referenced articles or incorporated external code:
+http://en.literateprograms.org/Quicksort_(C)?action=history&offset=20070511214343
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Retrieved from: http://en.literateprograms.org/Quicksort_(C)?oldid=10011
+*/
+
+#include <stdlib.h>
+
+#include "quicksort.h"
+
+#define MIN_QUICKSORT_LIST_SIZE 32
+
+static int compare_elements_helper(void *base, size_t element_size, int idx1, int idx2,
+ int(*comparer)(const void *, const void*))
+{
+ char* base_bytes = base;
+ return comparer(&base_bytes[idx1*element_size], &base_bytes[idx2*element_size]);
+}
+
+#define element_less_than(i,j) (compare_elements_helper(base, element_size, (i), (j), comparer) < 0)
+
+static void exchange_elements_helper(void *base, size_t element_size, int idx1, int idx2)
+{
+ char* base_bytes = base;
+ int i;
+ for (i=0; i<element_size; i++)
+ {
+ char temp = base_bytes[idx1*element_size + i];
+ base_bytes[idx1*element_size + i] = base_bytes[idx2*element_size + i];
+ base_bytes[idx2*element_size + i] = temp;
+ }
+}
+
+#define exchange_elements(i,j) (exchange_elements_helper(base, element_size, (i), (j)))
+
+void insertion_sort(void * base, size_t num_elements, size_t element_size,
+ int (*comparer)(const void *, const void *))
+{
+ int i;
+ for (i=0; i < num_elements; i++)
+ {
+ int j;
+ for (j = i - 1; j >= 0; j--)
+ {
+ if (element_less_than(j, j + 1)) break;
+ exchange_elements(j, j + 1);
+ }
+ }
+}
+
+int partition(void * base, size_t num_elements, size_t element_size,
+ int (*comparer)(const void *, const void *), int pivotIndex)
+
+{
+ int low = 0, high = num_elements - 1;
+ exchange_elements(num_elements - 1, pivotIndex);
+
+ while (1) {
+ while (element_less_than(low, num_elements-1)) {
+	 low++;
+	}
+	while (!element_less_than(high, num_elements-1)) {
+	 high--;
+	}
+
+ if (low > high) break;
+ exchange_elements(low, high);
+
+ }
+ exchange_elements(low, num_elements - 1);
+ return low;
+
+}
+
+void quicksort(void * base, size_t num_elements, size_t element_size,
+ int (*comparer)(const void *, const void *))
+{
+ int pivotIndex;
+
+ if (num_elements < MIN_QUICKSORT_LIST_SIZE) {
+ insertion_sort(base, num_elements, element_size, comparer);
+ return;
+ }
+
+ pivotIndex = rand() % num_elements;
+
+ pivotIndex = partition(base, num_elements, element_size, comparer, pivotIndex);
+
+ quicksort(base, pivotIndex, element_size, comparer);
+ quicksort(((char*)base) + element_size*(pivotIndex+1),
+ num_elements - (pivotIndex + 1), element_size, comparer);
+
+}
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4009
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4009&view=rev
Author: astraw
Date: 2007年10月25日 20:13:24 -0700 (2007年10月25日)
Log Message:
-----------
fix for numpy
Modified Paths:
--------------
 trunk/py4science/examples/weave_examples_simple.py
Modified: trunk/py4science/examples/weave_examples_simple.py
===================================================================
--- trunk/py4science/examples/weave_examples_simple.py	2007年10月26日 02:35:23 UTC (rev 4008)
+++ trunk/py4science/examples/weave_examples_simple.py	2007年10月26日 03:13:24 UTC (rev 4009)
@@ -40,7 +40,7 @@
 def main():
 zz = N.zeros([10,10])
 print 'tr(zz)=',trace(zz)
- oo = N.ones([4,4],N.Float)
+ oo = N.ones([4,4],N.float)
 print 'tr(oo)=',trace(oo)
 aa = rand(128,128)
 print 'tr(aa)=',trace(aa)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2007年10月26日 02:35:25
Revision: 4008
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4008&view=rev
Author: jdh2358
Date: 2007年10月25日 19:35:23 -0700 (2007年10月25日)
Log Message:
-----------
added workbook
Modified Paths:
--------------
 trunk/py4science/workbook/main.tex
Added Paths:
-----------
 trunk/py4science/workbook/main.pdf
Added: trunk/py4science/workbook/main.pdf
===================================================================
--- trunk/py4science/workbook/main.pdf	 (rev 0)
+++ trunk/py4science/workbook/main.pdf	2007年10月26日 02:35:23 UTC (rev 4008)
@@ -0,0 +1,8917 @@
+%PDF-1.4
+5 0 obj
+<< /S /GoTo /D (chapter.1) >>
+endobj
+8 0 obj
+(Chapter 1. Introduction)
+endobj
+9 0 obj
+<< /S /GoTo /D (chapter.2) >>
+endobj
+12 0 obj
+(Chapter 2. Simple non-numerical problems)
+endobj
+13 0 obj
+<< /S /GoTo /D (section.2.1) >>
+endobj
+16 0 obj
+(1. Sorting quickly with QuickSort )
+endobj
+17 0 obj
+<< /S /GoTo /D (section.2.2) >>
+endobj
+20 0 obj
+(2. Dictionaries for counting words)
+endobj
+21 0 obj
+<< /S /GoTo /D (chapter.3) >>
+endobj
+24 0 obj
+(Chapter 3. Working with files, the internet, and numpy arrays)
+endobj
+25 0 obj
+<< /S /GoTo /D (section.3.1) >>
+endobj
+28 0 obj
+(1. Loading and saving ASCII data)
+endobj
+29 0 obj
+<< /S /GoTo /D (section.3.2) >>
+endobj
+32 0 obj
+(2. Working with CSV files)
+endobj
+33 0 obj
+<< /S /GoTo /D (section.3.3) >>
+endobj
+36 0 obj
+(3. Loading and saving binary data)
+endobj
+37 0 obj
+<< /S /GoTo /D (chapter.4) >>
+endobj
+40 0 obj
+(Chapter 4. Elementary Numerics)
+endobj
+41 0 obj
+<< /S /GoTo /D (section.4.1) >>
+endobj
+44 0 obj
+(1. Wallis' slow road to )
+endobj
+45 0 obj
+<< /S /GoTo /D (section.4.2) >>
+endobj
+48 0 obj
+(2. Trapezoidal rule)
+endobj
+49 0 obj
+<< /S /GoTo /D (section.4.3) >>
+endobj
+52 0 obj
+(3. Newton's method)
+endobj
+53 0 obj
+<< /S /GoTo /D (chapter.5) >>
+endobj
+56 0 obj
+(Chapter 5. Linear algebra)
+endobj
+57 0 obj
+<< /S /GoTo /D (section.5.1) >>
+endobj
+60 0 obj
+(1. Glass Moir351円 Patterns)
+endobj
+61 0 obj
+<< /S /GoTo /D [62 0 R /Fit ] >>
+endobj
+64 0 obj <<
+/Length 292 
+/Filter /FlateDecode
+>>
+stream
+xڍQ;O\xC30\xDE\xF3+<ڃ\x9F_\x8F\xBC
+\xEAT\x89H\x94\xA1\xA4\xA1\x8DJm\xB5\xFCz\xEC\x86VEb\xA8,\xD9:/\xDF\x99\xCAY0\xE0\x95Ҍ\x8C\x81`\x89X\xBB\xAD[e\xEC\xA1\xC2_\x8E\xD5(\x9F\x8BP\xE9\xB0B\xCD\xE4\xB9\xC9MS]M\x8Cch\xC1X\xAFY\xF3δR\xA0\x9D\xAF\x99G\xB5Ɋf\xF9\xC2gâ\xDD\xF5\xED\xE2CH\xE3\x89?\xB5}\x85Q|'\x90\xF7B"\x9F+c\xDBz~\x9B\xB6\xE5\xE6s\xE3J\xBC6SF\xD11\xA9P+:8\xF7q\xB4\x9C}f\x91\xACS<\xD0e
Revision: 4007
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4007&view=rev
Author: jdh2358
Date: 2007年10月25日 19:12:14 -0700 (2007年10月25日)
Log Message:
-----------
added intro talk pdf
Added Paths:
-----------
 trunk/py4science/doc/intro_python_scicomp.pdf
Added: trunk/py4science/doc/intro_python_scicomp.pdf
===================================================================
--- trunk/py4science/doc/intro_python_scicomp.pdf	 (rev 0)
+++ trunk/py4science/doc/intro_python_scicomp.pdf	2007年10月26日 02:12:14 UTC (rev 4007)
@@ -0,0 +1,78172 @@
+%PDF-1.4
+9 0 obj
+<< /S /GoTo /D (Outline0.1) >>
+endobj
+12 0 obj
+(Scientific Computing)
+endobj
+13 0 obj
+<< /S /GoTo /D (Outline0.1.1.6) >>
+endobj
+16 0 obj
+(Traditional approaches)
+endobj
+17 0 obj
+<< /S /GoTo /D (Outline0.1.2.22) >>
+endobj
+20 0 obj
+(Python?)
+endobj
+21 0 obj
+<< /S /GoTo /D (Outline0.2) >>
+endobj
+24 0 obj
+(Interlude: Python in the real world)
+endobj
+25 0 obj
+<< /S /GoTo /D (Outline0.2.1.34) >>
+endobj
+28 0 obj
+(EEG analysis for epilepsy)
+endobj
+29 0 obj
+<< /S /GoTo /D (Outline0.2.2.39) >>
+endobj
+32 0 obj
+(Multiwavelets)
+endobj
+33 0 obj
+<< /S /GoTo /D (Outline0.2.3.40) >>
+endobj
+36 0 obj
+(PMV: molecular structures)
+endobj
+37 0 obj
+<< /S /GoTo /D (Outline0.2.4.43) >>
+endobj
+40 0 obj
+(MayaVi: customizable data visualization)
+endobj
+41 0 obj
+<< /S /GoTo /D (Outline0.2.5.54) >>
+endobj
+44 0 obj
+(SAGE: System for Algebra and Geometry Experimentation)
+endobj
+45 0 obj
+<< /S /GoTo /D (Outline0.2.6.55) >>
+endobj
+48 0 obj
+(IPython)
+endobj
+49 0 obj
+<< /S /GoTo /D (Outline0.2.7.61) >>
+endobj
+52 0 obj
+(PyNGL)
+endobj
+53 0 obj
+<< /S /GoTo /D (Outline0.2.8.63) >>
+endobj
+56 0 obj
+endobj
+57 0 obj
+<< /S /GoTo /D (Outline0.3) >>
+endobj
+60 0 obj
+(Python and Scientific Computing)
+endobj
+61 0 obj
+<< /S /GoTo /D (Outline0.3.1.65) >>
+endobj
+64 0 obj
+(Basic features)
+endobj
+65 0 obj
+<< /S /GoTo /D (Outline0.3.2.68) >>
+endobj
+68 0 obj
+(Development in Python)
+endobj
+69 0 obj
+<< /S /GoTo /D (Outline0.4) >>
+endobj
+72 0 obj
+(Wrapup)
+endobj
+73 0 obj
+<< /S /GoTo /D (Outline1) >>
+endobj
+76 0 obj
+(Appendix)
+endobj
+77 0 obj
+<< /S /GoTo /D (Outline1.5) >>
+endobj
+80 0 obj
+(Appendix)
+endobj
+81 0 obj
+<< /S /GoTo /D (Outline1.5.1.75) >>
+endobj
+84 0 obj
+(Python overview)
+endobj
+85 0 obj
+<< /S /GoTo /D [86 0 R /Fit ] >>
+endobj
+92 0 obj <<
+/Length 1772 
+/Filter /FlateDecode
+>>
+stream
+x\xDA\xCDY\xDFO7~\xBF\xBFbA\xEA:\xFF\xB6TU%i\x88\xA9UTyh\xFA\x80\x8E\x83 q\\xA5\xED_\xDF\xCF\xF6\xDA޽\xDB[ \x8D\xD4
+\x81׳3\xE3o<\xE3\xF1\xCCB
+\xC75\x9E9r\xD4\xC3I\xA9\x9B\xF9rƛ+\xBCz3\xA3\x8E\xA5\xEDx\xDA1\xA6\xCA|\xD60\xE7\x8D4\x829\xA9l#\xAC`$5\xEBEsY\xF4\x95\xD7|L\xD1\xCE\xEA\xBB\xDA&\xA4\xB6\xA5y\xD31\xEF\x85H1Ѥ_۬\xAF\x9A\xFE\xF4}\x95\x95J2\xF2N\xC3p噗J\x8C\x9Eqf\xF6)\xEE}\xD2{\xF6\xE4?\xC3Y\xB8#,\x87Q:\xA6\xAC\x8D\xCC\xD5\xD7[̆\x985އ\x88QF
+\xE3\x84\xD7t\x9CK\xD6(\xEF\xFBN#\xA6\xBCRA\xFE\xBE\x99\xED06#\xDA@\x92\xC1\xA8/M1\xCC[\xE9\xDE"\x99tV\xCAF\x80\x81\xB8\xB1h\x99\xE3\x9C;\x90Fj\x96\x85"\x99\xC0(\x9B\x9Ba\x83Gc,ドル\xA6<\x88S7s̄I\xE6^f\x82b\x98cY\xF0\x8B\xF0Hz\x8CD\x81\x99\x8B\xFE"\x95t\xDA\xCCN\x82\x81.\xFF\xC0\xB4\xB8\x83
+v\xA6g\xE5
Revision: 4006
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4006&view=rev
Author: jdh2358
Date: 2007年10月25日 12:41:13 -0700 (2007年10月25日)
Log Message:
-----------
replaced image read w/ pylab for portability
Modified Paths:
--------------
 trunk/py4science/examples/skel/fft_imdenoise_skel.py
Modified: trunk/py4science/examples/skel/fft_imdenoise_skel.py
===================================================================
--- trunk/py4science/examples/skel/fft_imdenoise_skel.py	2007年10月25日 19:39:31 UTC (rev 4005)
+++ trunk/py4science/examples/skel/fft_imdenoise_skel.py	2007年10月25日 19:41:13 UTC (rev 4006)
@@ -31,8 +31,10 @@
 # 'main' script
 
 
-im = # XXX make an image array from the file 'moonlanding.jpg', using the
- # imread() function from scipy.misc.pilutil.
+im = # XXX make an image array from the file 'moonlanding.png', using the
+ # pylab imread() function. You will need to just extract the red
+ # channel from the MxNx4 RGBA matrix to represent the grayscale
+ # intensities
 
 F = # Compute the 2d FFT of the input image. Look for a 2-d FFT in N.dft
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2007年10月25日 19:39:32
Revision: 4005
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4005&view=rev
Author: jdh2358
Date: 2007年10月25日 12:39:31 -0700 (2007年10月25日)
Log Message:
-----------
fixed convolution example w/ zero padding
Added Paths:
-----------
 trunk/py4science/examples/convolution_demo.py
 trunk/py4science/examples/data/moonlanding.png
 trunk/py4science/examples/skel/convolution_demo_skel.py
Added: trunk/py4science/examples/convolution_demo.py
===================================================================
--- trunk/py4science/examples/convolution_demo.py	 (rev 0)
+++ trunk/py4science/examples/convolution_demo.py	2007年10月25日 19:39:31 UTC (rev 4005)
@@ -0,0 +1,74 @@
+"""
+In signal processing, the output of a linear system to an arbitrary
+input is given by the convolution of the impule response function (the
+system response to a Dirac-delta impulse) and the input signal.
+
+Mathematically:
+
+ y(t) = \int_0^\t x(\tau)r(t-\tau)d\tau
+
+
+where x(t) is the input signal at time t, y(t) is the output, and r(t)
+is the impulse response function.
+
+In this exercise, we will compute investigate the convolution of a
+white noise process with a double exponential impulse response
+function, and compute the results 
+
+ * using numpy.convolve
+
+ * in Fourier space using the property that a convolution in the
+ temporal domain is a multiplication in the fourier domain
+"""
+
+import numpy as npy
+import matplotlib.mlab as mlab
+from pylab import figure, show
+
+# build the time, input, output and response arrays
+dt = 0.01
+t = npy.arange(0.0, 20.0, dt) # the time vector from 0..20
+Nt = len(t)
+
+def impulse_response(t):
+ 'double exponential response function'
+ return (npy.exp(-t) - npy.exp(-5*t))*dt
+
+
+x = npy.random.randn(Nt) # gaussian white noise
+
+# evaluate the impulse response function, and numerically convolve it
+# with the input x
+r = impulse_response(t) # evaluate the impulse function
+y = npy.convolve(x, r, mode='full') # convultion of x with r
+y = y[:Nt]
+
+# compute y by applying F^-1[F(x) * F(r)]. The fft assumes the signal
+# is periodic, so to avoid edge artificats, pad the fft with zeros up
+# to the length of r + x do avoid circular convolution artifacts
+R = npy.fft.fft(r, len(r)+len(x)-1)
+X = npy.fft.fft(x, len(r)+len(x)-1)
+Y = R*X
+
+# now inverse fft and extract just the part up to len(x)
+yi = npy.fft.ifft(Y)[:len(x)].real
+
+# plot t vs x, t vs y and yi, and t vs r in three subplots
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax1.plot(t, x)
+ax1.set_ylabel('input x')
+
+ax2 = fig.add_subplot(312)
+ax2.plot(t, y, label='convolve')
+ax2.set_ylabel('output y')
+
+ax3 = fig.add_subplot(313)
+ax3.plot(t, r)
+ax3.set_ylabel('input response')
+ax3.set_xlabel('time (s)')
+
+ax2.plot(t, yi, label='fft')
+ax2.legend(loc='best')
+
+show()
Added: trunk/py4science/examples/data/moonlanding.png
===================================================================
(Binary files differ)
Property changes on: trunk/py4science/examples/data/moonlanding.png
___________________________________________________________________
Name: svn:mime-type
 + application/octet-stream
Added: trunk/py4science/examples/skel/convolution_demo_skel.py
===================================================================
--- trunk/py4science/examples/skel/convolution_demo_skel.py	 (rev 0)
+++ trunk/py4science/examples/skel/convolution_demo_skel.py	2007年10月25日 19:39:31 UTC (rev 4005)
@@ -0,0 +1,59 @@
+"""
+In signal processing, the output of a linear system to an arbitrary
+input is given by the convolution of the impule response function (the
+system response to a Dirac-delta impulse) and the input signal.
+
+Mathematically:
+
+ y(t) = \int_0^\t x(\tau)r(t-\tau)d\tau
+
+
+where x(t) is the input signal at time t, y(t) is the output, and r(t)
+is the impulse response function.
+
+In this exercise, we will compute investigate the convolution of a
+white noise process with a double exponential impulse response
+function, and compute the results 
+
+ * using numpy.convolve
+
+ * in Fourier space using the property that a convolution in the
+ temporal domain is a multiplication in the fourier domain
+"""
+
+import numpy as npy
+import matplotlib.mlab as mlab
+from pylab import figure, show
+
+# build the time, input, output and response arrays
+dt = 0.01
+t = XXX # the time vector from 0..20
+Nt = len(t)
+
+def impulse_response(t):
+ 'double exponential response function'
+ return XXX
+
+
+x = XXX # gaussian white noise
+
+# evaluate the impulse response function, and numerically convolve it
+# with the input x
+r = XXX # evaluate the impulse function
+y = XXX # convultion of x with r
+y = XXX # extract just the length Nt part
+
+# compute y by applying F^-1[F(x) * F(r)]. The fft assumes the signal
+# is periodic, so to avoid edge artificats, pad the fft with zeros up
+# to the length of r + x do avoid circular convolution artifacts
+R = XXX # the zero padded FFT of r
+X = XXX # the zero padded FFT of x
+Y = XXX # the product of R and S 
+
+# now inverse fft and extract the real part, just the part up to
+# len(x)
+yi = XXX
+
+# plot t vs x, t vs y and yi, and t vs r in three subplots
+XXX
+show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月25日 19:16:14
Revision: 4004
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4004&view=rev
Author: mdboom
Date: 2007年10月25日 12:16:11 -0700 (2007年10月25日)
Log Message:
-----------
Increased coverage of backend_driver.py to include almost everything
in axes.py. Lots of little bug fixes.
Modified Paths:
--------------
 branches/transforms/PASSED_DEMOS
 branches/transforms/examples/arrow_demo.py
 branches/transforms/examples/backend_driver.py
 branches/transforms/lib/matplotlib/artist.py
 branches/transforms/lib/matplotlib/axes.py
 branches/transforms/lib/matplotlib/backend_bases.py
 branches/transforms/lib/matplotlib/backends/backend_pdf.py
 branches/transforms/lib/matplotlib/backends/backend_ps.py
 branches/transforms/lib/matplotlib/backends/backend_svg.py
 branches/transforms/lib/matplotlib/backends/backend_template.py
 branches/transforms/lib/matplotlib/cbook.py
 branches/transforms/lib/matplotlib/collections.py
 branches/transforms/lib/matplotlib/contour.py
 branches/transforms/lib/matplotlib/lines.py
 branches/transforms/lib/matplotlib/patches.py
 branches/transforms/lib/matplotlib/path.py
 branches/transforms/lib/matplotlib/scale.py
 branches/transforms/lib/matplotlib/transforms.py
 branches/transforms/lib/matplotlib/widgets.py
 branches/transforms/src/_gtkagg.cpp
Added Paths:
-----------
 branches/transforms/examples/equal_aspect_ratio.py
 branches/transforms/examples/hline_demo.py
Modified: branches/transforms/PASSED_DEMOS
===================================================================
--- branches/transforms/PASSED_DEMOS	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/PASSED_DEMOS	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -60,7 +60,7 @@
 dynamic_demo_wx.py	[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
 dynamic_image_gtkagg.py O
 dynamic_image_wxagg2.py O
-dynamic_image_wxagg.py	
+dynamic_image_wxagg.py	[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
 ellipse_demo.py		O
 ellipse_rotated.py	O
 embedding_in_gtk2.py	[REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED]
Modified: branches/transforms/examples/arrow_demo.py
===================================================================
--- branches/transforms/examples/arrow_demo.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/examples/arrow_demo.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -280,6 +280,7 @@
 
 if __name__ == '__main__':
 from sys import argv
+ d = None
 if len(argv) > 1:
 if argv[1] == 'full':
 d = all_on_max
@@ -293,7 +294,7 @@
 elif argv[1] == 'sample':
 d = sample_data
 scaled = True
- else:
+ if d is None:
 d = all_on_max
 scaled=False
 if len(argv) > 2:
Modified: branches/transforms/examples/backend_driver.py
===================================================================
--- branches/transforms/examples/backend_driver.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/examples/backend_driver.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -22,10 +22,16 @@
 files = (
 'alignment_test.py',
 'arctest.py',
+ 'arrow_demo.py',
 'axes_demo.py',
+ 'axhspan_demo.py',
 'bar_stacked.py',
 'barchart_demo.py',
+ 'boxplot_demo.py',
+ 'broken_barh.py',
+ 'barh_demo.py',
 'color_demo.py',
+ 'colorbar_only.py',
 'contour_demo.py',
 'contourf_demo.py',
 'csd_demo.py',
@@ -33,6 +39,8 @@
 'customize_rc.py',
 'date_demo1.py',
 'date_demo2.py',
+ 'equal_aspect_ratio.py',
+ 'errorbar_limits.py',
 'figimage_demo.py',
 'figlegend_demo.py',
 'figtext.py',
@@ -40,6 +48,7 @@
 'finance_demo.py',
 'fonts_demo_kw.py',
 'histogram_demo.py',
+ 'hline_demo.py',
 'image_demo.py',
 'image_demo2.py',
 'image_masked.py',
@@ -66,11 +75,18 @@
 'polar_demo.py',
 'polar_scatter.py',
 'psd_demo.py',
+ 'quadmesh_demo.py',
 'quiver_demo.py',
 'scatter_demo.py',
 'scatter_demo2.py',
+ 'scatter_star_poly.py',
+ 'shared_axis_demo.py',
+ 'shared_axis_across_figures.py',
 'simple_plot.py',
 'specgram_demo.py',
+ 'spy_demos.py',
+ 'stem_plot.py',
+ 'step_demo.py',
 'stock_demo.py',
 'subplot_demo.py',
 # 'set_and_get.py',
@@ -104,7 +120,7 @@
 def run(arglist):
 os.system(' '.join(arglist))
 
-def drive(backend, python='python', switches = []):
+def drive(backend, python=['python'], switches = []):
 
 exclude = failbackend.get(backend, [])
 switchstring = ' '.join(switches)
@@ -151,17 +167,20 @@
 tmpfile.write('savefig("%s", dpi=150)' % outfile)
 
 tmpfile.close()
- run([python, tmpfile_name, switchstring])
+ run(python + [tmpfile_name, switchstring])
 #os.system('%s %s %s' % (python, tmpfile_name, switchstring))
 os.remove(tmpfile_name)
 
 if __name__ == '__main__':
 times = {}
 default_backends = ['Agg', 'PS', 'SVG', 'PDF', 'Template']
- if sys.platform == 'win32':
- python = r'c:\Python24\python.exe'
+ if '--coverage' in sys.argv:
+ python = ['coverage.py', '-x']
+ sys.argv.remove('--coverage')
+ elif sys.platform == 'win32':
+ python = [r'c:\Python24\python.exe']
 else:
- python = 'python'
+ python = ['python']
 all_backends = [b.lower() for b in mplbe.all_backends]
 all_backends.extend(['cairo.png', 'cairo.ps', 'cairo.pdf', 'cairo.svg'])
 backends = []
Added: branches/transforms/examples/equal_aspect_ratio.py
===================================================================
--- branches/transforms/examples/equal_aspect_ratio.py	 (rev 0)
+++ branches/transforms/examples/equal_aspect_ratio.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+"""
+Example: simple line plot.
+Show how to make a plot that has equal aspect ratio
+"""
+from pylab import *
+
+t = arange(0.0, 1.0+0.01, 0.01)
+s = cos(2*2*pi*t)
+plot(t, s, '-', lw=2)
+
+xlabel('time (s)')
+ylabel('voltage (mV)')
+title('About as simple as it gets, folks')
+grid(True)
+
+axes().set_aspect('equal', 'datalim')
+
+
+#savefig('simple_plot.png')
+savefig('equal_aspect')
+
+show()
Property changes on: branches/transforms/examples/equal_aspect_ratio.py
___________________________________________________________________
Name: svn:executable
 + *
Added: branches/transforms/examples/hline_demo.py
===================================================================
--- branches/transforms/examples/hline_demo.py	 (rev 0)
+++ branches/transforms/examples/hline_demo.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+from matplotlib.pyplot import *
+from numpy import sin, exp, absolute, pi, arange
+from numpy.random import normal
+
+def f(t):
+ s1 = sin(2*pi*t)
+ e1 = exp(-t)
+ return absolute((s1*e1))+.05
+
+
+t = arange(0.0, 5.0, 0.1)
+s = f(t)
+nse = normal(0.0, 0.3, t.shape) * s
+
+plot(s+nse, t, 'b^')
+hlines(t, [0], s)
+xlabel('time (s)')
+title('Comparison of model with data')
+show()
+
Property changes on: branches/transforms/examples/hline_demo.py
___________________________________________________________________
Name: svn:executable
 + *
Modified: branches/transforms/lib/matplotlib/artist.py
===================================================================
--- branches/transforms/lib/matplotlib/artist.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/artist.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -1,5 +1,5 @@
 from __future__ import division
-import sys, re
+import sys, re, warnings
 from cbook import iterable, flatten
 from transforms import Affine2D, Bbox, IdentityTransform, TransformedBbox, \
 TransformedPath
@@ -174,7 +174,7 @@
 """
 if callable(self._contains): return self._contains(self,mouseevent)
 #raise NotImplementedError,str(self.__class__)+" needs 'contains' method"
- print str(self.__class__)+" needs 'contains' method"
+ warnings.warn("'%s' needs 'contains' method" % self.__class__.__name__)
 return False,{}
 
 def set_contains(self,picker):
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/axes.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -821,16 +821,15 @@
 Use self._aspect and self._adjustable to modify the
 axes box or the view limits.
 '''
- #MGDTODO: Numpify
-
- if self._aspect == 'auto':
+ aspect = self.get_aspect()
+ if aspect == 'auto':
 self.set_position( self._originalPosition , 'active')
 return
 
- if self._aspect == 'equal':
+ if aspect == 'equal':
 A = 1
 else:
- A = self._aspect
+ A = aspect
 
 #Ensure at drawing time that any Axes involved in axis-sharing
 # does not have its position changed.
@@ -843,7 +842,7 @@
 box_aspect = A * self.get_data_ratio()
 pb = self._originalPosition.frozen()
 pb1 = pb.shrunk_to_aspect(box_aspect, pb, fig_aspect)
- self.set_position(pb1.anchored(self._anchor, pb), 'active')
+ self.set_position(pb1.anchored(self.get_anchor(), pb), 'active')
 return
 
 xmin,xmax = self.get_xbound()
@@ -1040,7 +1039,7 @@
 a.set_clip_path(self.axesPatch)
 a._remove_method = lambda h: self.artists.remove(h)
 
- def add_collection(self, collection, autolim=False):
+ def add_collection(self, collection, autolim=True):
 'add a Collection instance to Axes'
 label = collection.get_label()
 if not label:
@@ -1127,8 +1126,8 @@
 	self.ignore_existing_data_limits = False
 
 def update_datalim_bounds(self, bounds):
- # MGDTODO: Document me
- self.dataLim.bounds = Bbox.union([self.dataLim, bounds]).bounds
+ 'Update the datalim to include the given Bbox'
+ self.dataLim.set(Bbox.union([self.dataLim, bounds]))
 
 def _get_verts_in_data_coords(self, trans, xys):
 if trans == self.transData:
@@ -2017,8 +2016,9 @@
 Note this algorithm calculates distance to the vertices of the
 polygon, so if you want to pick a patch, click on the edge!
 """
+ # MGDTODO: Needs updating
 if trans is not None:
- xywin = trans.xy_tup((x,y))
+ xywin = trans.transform_point((x,y))
 else:
 xywin = x,y
 
@@ -2036,12 +2036,12 @@
 def dist(a):
 if isinstance(a, Text):
 bbox = a.get_window_extent()
- l,b,w,h = bbox.get_bounds()
+ l,b,w,h = bbox.bounds
 verts = (l,b), (l,b+h), (l+w,b+h), (l+w, b)
 xt, yt = zip(*verts)
 elif isinstance(a, Patch):
- verts = a.get_verts()
- tverts = a.get_transform().seq_xy_tups(verts)
+ path = a.get_path()
+ tverts = a.get_transform().transform_path(path)
 xt, yt = zip(*tverts)
 elif isinstance(a, mlines.Line2D):
 xdata = a.get_xdata(orig=False)
@@ -3278,19 +3278,19 @@
 self.hold(holdstate) # restore previous hold state
 
 if adjust_xlim:
- xmin, xmax = self.dataLim.intervalx().get_bounds()
+ xmin, xmax = self.dataLim.intervalx
 xmin = npy.amin(width)
 if xerr is not None:
 xmin = xmin - npy.amax(xerr)
 xmin = max(xmin*0.9, 1e-100)
- self.dataLim.intervalx().set_bounds(xmin, xmax)
+ self.dataLim.intervalx = (xmin, xmax)
 if adjust_ylim:
- ymin, ymax = self.dataLim.intervaly().get_bounds()
+ ymin, ymax = self.dataLim.intervaly
 ymin = npy.amin(height)
 if yerr is not None:
 ymin = ymin - npy.amax(yerr)
 ymin = max(ymin*0.9, 1e-100)
- self.dataLim.intervaly().set_bounds(ymin, ymax)
+ self.dataLim.intervaly = (ymin, ymax)
 self.autoscale_view()
 return patches
 bar.__doc__ = cbook.dedent(bar.__doc__) % martist.kwdocd
@@ -4197,7 +4197,7 @@
 
 def quiver(self, *args, **kw):
 q = mquiver.Quiver(self, *args, **kw)
- self.add_collection(q)
+ self.add_collection(q, False)
 self.update_datalim_numerix(q.X, q.Y)
 self.autoscale_view()
 return q
@@ -5170,6 +5170,7 @@
 'get the subplot geometry, eg 2,2,3'
 return self._rows, self._cols, self._num+1
 
+ # COVERAGE NOTE: Never used internally or from examples
 def change_geometry(self, numrows, numcols, num):
 'change subplot geometry, eg from 1,1,1 to 2,2,3'
 self._rows = numrows
@@ -5238,6 +5239,7 @@
 def is_last_col(self):
 return self.colNum==self.numCols-1
 
+ # COVERAGE NOTE: Never used internally or from examples
 def label_outer(self):
 """
 set the visible property on ticklabels so xticklabels are
Modified: branches/transforms/lib/matplotlib/backend_bases.py
===================================================================
--- branches/transforms/lib/matplotlib/backend_bases.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/backend_bases.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -223,7 +223,7 @@
 baseline (descent), in display coords of the string s with
 FontPropertry prop
 """
- return 1,1,1
+ raise NotImplementedError
 
 def new_gc(self):
 """
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -1180,11 +1180,12 @@
 def get_image_magnification(self):
 return self.image_magnification
 
- def draw_image(self, x, y, im, bbox):
+ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
 #print >>sys.stderr, "draw_image called"
 
+ # MGDTODO: Support clippath here
 gc = self.new_gc()
- gc.set_clip_rectangle(bbox.get_bounds())
+ gc.set_clip_rectangle(bbox.bounds)
 self.check_gc(gc)
 
 h, w = im.get_size_out()
@@ -1714,13 +1715,19 @@
 """
 cmds = []
 for params, cmd in self.commands:
- ours = [ getattr(self, p) for p in params ] 
- theirs = [ getattr(other, p) for p in params ]
- try:
- different = ours != theirs
- except ValueError:
- different = ours.shape != theirs.shape or npy.any(ours != theirs)
- if ours is not theirs:
+ different = False
+ for p in params:
+ ours = getattr(self, p)
+ theirs = getattr(other, p)
+ try:
+ different = bool(ours != theirs)
+ except ValueError:
+ different = ours.shape != theirs.shape or npy.any(ours != theirs)
+ if different:
+ break
+ 
+ if different:
+ theirs = [getattr(other, p) for p in params]
 cmds.extend(cmd(self, *theirs))
 for p in params:
 setattr(self, p, getattr(other, p))
Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -994,12 +994,12 @@
 tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest())
 fh = file(tmpfile, 'w')
 
- self.figure.dpi.set(72) # ignore the dpi kwarg
+ self.figure.dpi = 72 # ignore the dpi kwarg
 width, height = self.figure.get_size_inches()
 xo = 0
 yo = 0
 
- l, b, w, h = self.figure.bbox.get_bounds()
+ l, b, w, h = self.figure.bbox.bounds
 llx = xo
 lly = yo
 urx = llx + w
Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_svg.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/backends/backend_svg.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -193,7 +193,8 @@
 details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y)
 self._draw_svg_element('use', details, gc, rgbFace)
 
- def draw_image(self, x, y, im, bbox):
+ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ # MGDTODO: Support clippath here
 trans = [1,0,0,1,0,0]
 transstr = ''
 if rcParams['svg.image_noscale']:
Modified: branches/transforms/lib/matplotlib/backends/backend_template.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_template.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/backends/backend_template.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -66,24 +66,23 @@
 rotation):
 pass
 
- def draw_image(self, x, y, im, bbox):
+ def draw_path(self, gc, path, transform, rgbFace=None):
 pass
 
- def draw_line(self, gc, x1, y1, x2, y2):
+ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
 pass
 
- def draw_lines(self, gc, x, y):
+ # draw_path_collection is optional, and we get more correct
+ # relative timings by leaving it out.
+# def draw_path_collection(self, master_transform, cliprect, clippath,
+# clippath_trans, paths, all_transforms, offsets,
+# offsetTrans, facecolors, edgecolors, linewidths,
+# linestyles, antialiaseds):
+# pass
+ 
+ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
 pass
 
- def draw_point(self, gc, x, y):
- pass
-
- def draw_polygon(self, gcEdge, rgbFace, points):
- pass
-
- def draw_rectangle(self, gcEdge, rgbFace, x, y, width, height):
- pass
-
 def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
 pass
 
Modified: branches/transforms/lib/matplotlib/cbook.py
===================================================================
--- branches/transforms/lib/matplotlib/cbook.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/cbook.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -174,7 +174,6 @@
 def __str__(self):
 return '<a list of %d %s objects>' % (len(self), self.type)
 
-# MGDTODO: This is very incomplete
 def strip_math(s):
 'remove latex formatting from mathtext'
 remove = (r'\rm', '\cal', '\tt', '\it', '\\', '{', '}')
Modified: branches/transforms/lib/matplotlib/collections.py
===================================================================
--- branches/transforms/lib/matplotlib/collections.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/collections.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -126,13 +126,21 @@
 return self._transforms
 
 def get_datalim(self, transData):
+ transform = self.get_transform()
+ transOffset = self._transOffset
+ offsets = self._offsets
+ paths = self.get_paths()
+ if not transform.is_affine:
+ paths = [transform.transform_path_non_affine(p) for p in paths]
+ transform = transform.get_affine()
+ if not transOffset.is_affine:
+ offsets = transOffset.transform_non_affine(offsets)
+ transOffset = transOffset.get_affine()
+ 
 result = path.get_path_collection_extents(
- self.get_transform().frozen(),
- self.get_paths(),
- self.get_transforms(),
- self._offsets,
- self._transOffset.frozen())
- result = result.transformed(transData.inverted())
+ transform.frozen(), paths, self.get_transforms(),
+ npy.asarray(offsets, npy.float_), transOffset.frozen())
+ result = result.inverse_transformed(transData)
 return result
 
 def draw(self, renderer):
@@ -143,7 +151,6 @@
 offsets = self._offsets
 paths = self.get_paths()
 
- # MGDTODO: Test me
 if self.have_units():
 paths = []
 for path in self._paths:
@@ -163,7 +170,6 @@
 if clippath_trans is not None:
 clippath_trans = clippath_trans.frozen()
 
- # MGDTODO: This may benefit from using TransformedPath
 if not transform.is_affine:
 paths = [transform.transform_path_non_affine(path) for path in paths]
 transform = transform.get_affine()
@@ -193,7 +199,6 @@
 paths = [transform.transform_path_non_affine(path) for path in paths]
 transform = transform.get_affine()
 
- # MGDTODO: Don't pick when outside of clip path / clip box
 ind = path.point_in_path_collection(
 mouseevent.x, mouseevent.y, self._pickradius,
 transform.frozen(), paths, self.get_transforms(),
@@ -201,45 +206,6 @@
 self._transOffset.frozen(), len(self._facecolors))
 return len(ind)>0,dict(ind=ind)
 
- # MGDTODO: Update
- def get_transformed_patches(self):
- """
- get a sequence of the polygons in the collection in display (transformed) space
-
- The ith element in the returned sequence is a list of x,y
- vertices defining the ith polygon
- """
-
- verts = self._verts
- offsets = self._offsets
- usingOffsets = offsets is not None
- transform = self.get_transform()
- transOffset = self.get_transoffset()
- Noffsets = 0
- Nverts = len(verts)
- if usingOffsets:
- Noffsets = len(offsets)
-
- N = max(Noffsets, Nverts)
-
- data = []
- #print 'verts N=%d, Nverts=%d'%(N, Nverts), verts
- #print 'offsets; Noffsets=%d'%Noffsets
- for i in xrange(N):
- #print 'i%%Nverts=%d'%(i%Nverts)
- polyverts = verts[i % Nverts]
- if npy.any(npy.isnan(polyverts)):
- continue
- #print 'thisvert', i, polyverts
- tverts = transform.seq_xy_tups(polyverts)
- if usingOffsets:
- #print 'using offsets'
- xo,yo = transOffset.xy_tup(offsets[i % Noffsets])
- tverts = [(x+xo,y+yo) for x,y in tverts]
-
- data.append(tverts)
- return data
-
 def set_pickradius(self,pickradius): self.pickradius = 5
 def get_pickradius(self): return self.pickradius
 
@@ -414,8 +380,8 @@
 self._meshHeight = meshHeight
 self._coordinates = coordinates
 self._showedges = showedges
- 
- # MGDTODO: Numpify
+
+ # MGDTODO: Is it possible to Numpify this?
 coordinates = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2))
 c = coordinates
 paths = []
@@ -542,24 +508,6 @@
 
 def get_paths(self):
 return self._paths
- 
- # MGDTODO: Update
- def get_transformed_patches(self):
- # Shouldn't need all these calls to asarray;
- # the variables should be converted when stored.
- # Similar speedups with numpy should be attainable
- # in many other places.
- verts = npy.asarray(self._verts)
- offsets = npy.asarray(self._offsets)
- Npoly = len(offsets)
- scales = npy.sqrt(npy.asarray(self._sizes)*self._dpi.get()/72.0)
- Nscales = len(scales)
- if Nscales >1:
- scales = npy.resize(scales, (Npoly, 1, 1))
- transOffset = self.get_transoffset()
- xyo = transOffset.numerix_xy(offsets)
- polys = scales * verts + xyo[:, npy.newaxis, :]
- return polys
 
 
 class StarPolygonCollection(RegularPolyCollection):
Modified: branches/transforms/lib/matplotlib/contour.py
===================================================================
--- branches/transforms/lib/matplotlib/contour.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/contour.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -464,7 +464,7 @@
 ls = mpl.rcParams['contour.negative_linestyle']
 col.set_linestyle(ls)
 col.set_label('_nolegend_')
- self.ax.add_collection(col)
+ self.ax.add_collection(col, False)
 self.collections.append(col)
 self.changed() # set the colors
 x0 = ma.minimum(x)
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -25,6 +25,7 @@
 (TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN,
 CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8)
 
+# COVERAGE NOTE: Never called internally or from examples
 def unmasked_index_ranges(mask, compressed = True):
 '''
 Calculate the good data ranges in a masked 1-D npy.array, based on mask.
@@ -72,45 +73,6 @@
 ic1 = breakpoints
 return npy.concatenate((ic0[:, npy.newaxis], ic1[:, npy.newaxis]), axis=1)
 
-def segment_hits(cx,cy,x,y,radius):
- """Determine if any line segments are within radius of a point. Returns
- the list of line segments that are within that radius.
- """
- # Process single points specially
- if len(x) < 2:
- res, = npy.nonzero( (cx - x)**2 + (cy - y)**2 <= radius**2 )
- return res
-
- # We need to lop the last element off a lot.
- xr,yr = x[:-1],y[:-1]
-
- # Only look at line segments whose nearest point to C on the line
- # lies within the segment.
- dx,dy = x[1:]-xr, y[1:]-yr
- Lnorm_sq = dx**2+dy**2 # Possibly want to eliminate Lnorm==0
- u = ( (cx-xr)*dx + (cy-yr)*dy )/Lnorm_sq
- candidates = (u>=0) & (u<=1)
- #if any(candidates): print "candidates",xr[candidates]
-
- # Note that there is a little area near one side of each point
- # which will be near neither segment, and another which will
- # be near both, depending on the angle of the lines. The
- # following radius test eliminates these ambiguities.
- point_hits = (cx - x)**2 + (cy - y)**2 <= radius**2
- #if any(point_hits): print "points",xr[candidates]
- candidates = candidates & ~point_hits[:-1] & ~point_hits[1:]
-
- # For those candidates which remain, determine how far they lie away
- # from the line.
- px,py = xr+u*dx,yr+u*dy
- line_hits = (cx-px)**2 + (cy-py)**2 <= radius**2
- #if any(line_hits): print "lines",xr[candidates]
- line_hits = line_hits & candidates
- points, = point_hits.ravel().nonzero()
- lines, = line_hits.ravel().nonzero()
- #print points,lines
- return npy.concatenate((points,lines))
-
 class Line2D(Artist):
 lineStyles = _lineStyles = { # hidden names deprecated
 '-' : '_draw_solid',
@@ -381,12 +343,17 @@
 else:
 x, y = args
 
+ not_masked = 0
 if not ma.isMaskedArray(x):
 x = npy.asarray(x)
+ not_masked += 1
 if not ma.isMaskedArray(y):
 y = npy.asarray(y)
- if ((x.shape != self._xorig.shape or npy.any(x != self._xorig)) or
- (y.shape != self._yorig.shape or npy.any(y != self._yorig))):
+ not_masked += 1
+ 
+ if (not_masked < 2 or
+ ((x.shape != self._xorig.shape or npy.any(x != self._xorig)) or
+ (y.shape != self._yorig.shape or npy.any(y != self._yorig)))):
 self._xorig = x
 self._yorig = y
 self.recache()
Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/patches.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -224,7 +224,6 @@
 
 path = self.get_path()
 transform = self.get_transform()
- # MGDTODO: Use a transformed path here?
 tpath = transform.transform_path_non_affine(path)
 affine = transform.get_affine()
 
@@ -328,7 +327,7 @@
 
 def __str__(self):
 return str(self.__class__).split('.')[-1] \
- + "(%g,%g;%gx%g)"%(self.xy[0],self.xy[1],self.width,self.height)
+ + "(%g,%g;%gx%g)" % tuple(self._bbox.bounds)
 
 def __init__(self, xy, width, height, **kwargs):
 """
@@ -433,7 +432,7 @@
 A regular polygon patch.
 """
 def __str__(self):
- return "Poly%d(%g,%g)"%(self.numVertices,self.xy[0],self.xy[1])
+ return "Poly%d(%g,%g)"%(self._numVertices,self._xy[0],self._xy[1])
 
 def __init__(self, xy, numVertices, radius=5, orientation=0,
 **kwargs):
@@ -447,6 +446,7 @@
 %(Patch)s
 """
 self._xy = xy
+ self._numVertices = numVertices
 self._orientation = orientation
 self._radius = radius
 	self._path = Path.unit_regular_polygon(numVertices)
@@ -483,6 +483,13 @@
 self._radius = xy
 self._update_transform()
 radius = property(_get_radius, _set_radius)
+
+ def _get_numvertices(self):
+ return self._numVertices
+ def _set_numvertices(self, numVertices):
+ self._numVertices = numVertices
+ self._path = Path.unit_regular_polygon(numVertices)
+ numvertices = property(_get_numvertices, _set_numvertices)
 
 def get_path(self):
 	return self._path
@@ -495,7 +502,7 @@
 A general polygon patch.
 """
 def __str__(self):
- return "Poly(%g, %g)" % tuple(self._path.vertices[0])
+ return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0])
 
 def __init__(self, xy, **kwargs):
 """
@@ -507,15 +514,17 @@
 """
 Patch.__init__(self, **kwargs)
 	self._path = Path(xy, closed=True)
- self.xy = self._path.vertices
 __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
 
 def get_path(self):
 	return self._path
 
- def update(self):
- self._path = Path(self.xy, closed=True)
- 
+ def _get_xy(self):
+ return self._path.vertices
+ def _set_xy(self, vertices):
+ self._path = Path(vertices, closed=True)
+ xy = property(_get_xy, _set_xy)
+ 
 class Wedge(Patch):
 def __str__(self):
 return "Wedge(%g,%g)"%self.xy[0]
@@ -539,16 +548,14 @@
 
 def get_patch_transform(self):
 	return self._patch_transform
- 
+
+# COVERAGE NOTE: Not used internally or from examples
 class Arrow(Polygon):
 """
 An arrow patch
 """
 def __str__(self):
- x1,y1 = self.xy[0]
- x2,y2 = self.xy[1]
- cx,cy = (x1+x2)/2.,(y1+y2)/2.
- return "Arrow(%g,%g)"%(cx,cy)
+ return "Arrow()"
 
 _path = Path( [
 [ 0.0, 0.1 ], [ 0.0, -0.1],
@@ -584,10 +591,7 @@
 """Like Arrow, but lets you set head width and head height independently."""
 
 def __str__(self):
- x1,y1 = self.xy[0]
- x2,y2 = self.xy[1]
- cx,cy = (x1+x2)/2.,(y1+y2)/2.
- return "FancyArrow(%g,%g)"%(cx,cy)
+ return "FancyArrow()"
 
 def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False, \
 head_width=None, head_length=None, shape='full', overhang=0, \
@@ -608,7 +612,6 @@
 %(Patch)s
 
 """
-	# MGDTODO: Implement me
 if head_width is None:
 head_width = 3 * width
 if head_length is None:
@@ -664,10 +667,7 @@
 x1,y1 and a base at x2, y2.
 """
 def __str__(self):
- x1,y1 = self.xy[0]
- x2,y2 = self.xy[1]
- cx,cy = (x1+x2)/2.,(y1+y2)/2.
- return "YAArrow(%g,%g)"%(cx,cy)
+ return "YAArrow()"
 
 def __init__(self, dpi, xytip, xybase, width=4, frac=0.1, headwidth=12, **kwargs):
 """
@@ -692,9 +692,8 @@
 __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
 
 def get_path(self):
- # MGDTODO: Since this is dpi dependent, we need to recompute
- # the path every time. Perhaps this can be plugged through the
- # dpi transform instead (if only we know how to get it...)
+ # Since this is dpi dependent, we need to recompute the path
+ # every time.
 
 # the base vertices
 x1, y1 = self.xytip
@@ -786,13 +785,16 @@
 """
 Patch.__init__(self, **kwargs)
 
- self.center = xy
- self.width, self.height = width, height
- self.angle = angle
-	self._patch_transform = transforms.Affine2D() \
-	 .scale(self.width * 0.5, self.height * 0.5) \
-	 .rotate_deg(angle) \
-	 .translate(*xy)
+ self._center = xy
+ self._width, self._height = width, height
+ self._angle = angle
+ self._recompute_transform()
+
+ def _recompute_transform(self):
+ self._patch_transform = transforms.Affine2D() \
+	 .scale(self._width * 0.5, self._height * 0.5) \
+	 .rotate_deg(self._angle) \
+	 .translate(*self._center)
 
 def get_path(self):
 """
@@ -808,7 +810,28 @@
 x, y = self.get_transform().inverted().transform_point((ev.x, ev.y))
 return (x*x + y*y) <= 1.0, {}
 
+ def _get_center(self):
+ return self._center
+ def _set_center(self, center):
+ self._center = center
+ self._recompute_transform()
+ center = property(_get_center, _set_center)
 
+ def _get_xy(self):
+ return self._xy
+ def _set_xy(self, xy):
+ self._xy = xy
+ self._recompute_transform()
+ xy = property(_get_xy, _set_xy)
+
+ def _get_angle(self):
+ return self._angle
+ def _set_angle(self, angle):
+ self._angle = angle
+ self._recompute_transform()
+ angle = property(_get_angle, _set_angle)
+ 
+ 
 class Circle(Ellipse):
 """
 A circle patch
@@ -816,8 +839,7 @@
 def __str__(self):
 return "Circle((%g,%g),r=%g)"%(self.center[0],self.center[1],self.radius)
 
- def __init__(self, xy, radius=5,
- **kwargs):
+ def __init__(self, xy, radius=5, **kwargs):
 """
 Create true circle at center xy=(x,y) with given radius;
 unlike circle polygon which is a polygonal approcimation, this
@@ -837,122 +859,6 @@
 __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
 
 
-class PolygonInteractor:
- """
- An polygon editor.
-
- Key-bindings
-
- 't' toggle vertex markers on and off. When vertex markers are on,
- you can move them, delete them
-
- 'd' delete the vertex under point
-
- 'i' insert a vertex at point. You must be within epsilon of the
- line connecting two existing vertices
-
- """
-
- showverts = True
- epsilon = 5 # max pixel distance to count as a vertex hit
-
- def __str__(self):
- return "PolygonInteractor"
-
- def __init__(self, poly):
- if poly.figure is None:
- raise RuntimeError('You must first add the polygon to a figure or canvas before defining the interactor')
- canvas = poly.figure.canvas
- self.poly = poly
- self.poly.verts = list(self.poly.verts)
- x, y = zip(*self.poly.verts)
- self.line = lines.Line2D(x,y,marker='o', markerfacecolor='r')
- #self._update_line(poly)
-
- cid = self.poly.add_callback(self.poly_changed)
- self._ind = None # the active vert
-
- canvas.mpl_connect('button_press_event', self.button_press_callback)
- canvas.mpl_connect('key_press_event', self.key_press_callback)
- canvas.mpl_connect('button_release_event', self.button_release_callback)
- canvas.mpl_connect('motion_notify_event', self.motion_notify_callback)
- self.canvas = canvas
-
-
- def poly_changed(self, poly):
- 'this method is called whenever the polygon object is called'
- # only copy the artist props to the line (except visibility)
- vis = self.line.get_visible()
- artist.Artist.update_from(self.line, poly)
- self.line.set_visible(vis) # don't use the poly visibility state
-
-
- def get_ind_under_point(self, event):
- 'get the index of the vertex under point if within epsilon tolerance'
- x, y = zip(*self.poly.verts)
-
- # display coords
- xt, yt = self.poly.get_transform().numerix_x_y(x, y)
- d = npy.sqrt((xt-event.x)**2 + (yt-event.y)**2)
- ind, = npy.nonzero(npy.equal(d, npy.amin(d)))
-
- if d[ind]>=self.epsilon:
- ind = None
-
- return ind
-
- def button_press_callback(self, event):
- 'whenever a mouse button is pressed'
- if not self.showverts: return
- if event.inaxes==None: return
- if event.button != 1: return
- self._ind = self.get_ind_under_point(event)
-
- def button_release_callback(self, event):
- 'whenever a mouse button is released'
- if not self.showverts: return
- if event.button != 1: return
- self._ind = None
-
- def key_press_callback(self, event):
- 'whenever a key is pressed'
- if not event.inaxes: return
- if event.key=='t':
- self.showverts = not self.showverts
- self.line.set_visible(self.showverts)
- if not self.showverts: self._ind = None
- elif event.key=='d':
- ind = self.get_ind_under_point(event)
- if ind is not None:
- self.poly.verts = [tup for i,tup in enumerate(self.poly.verts) if i!=ind]
- self.line.set_data(zip(*self.poly.verts))
- elif event.key=='i':
- xys = self.poly.get_transform().seq_xy_tups(self.poly.verts)
- p = event.x, event.y # display coords
- for i in range(len(xys)-1):
- s0 = xys[i]
- s1 = xys[i+1]
- d = mlab.dist_point_to_segment(p, s0, s1)
- if d<=self.epsilon:
- self.poly.verts.insert(i+1, (event.xdata, event.ydata))
- self.line.set_data(zip(*self.poly.verts))
- break
-
-
- self.canvas.draw()
-
- def motion_notify_callback(self, event):
- 'on mouse movement'
- if not self.showverts: return
- if self._ind is None: return
- if event.inaxes is None: return
- if event.button != 1: return
- x,y = event.xdata, event.ydata
- self.poly.verts[self._ind] = x,y
- self.line.set_data(zip(*self.poly.verts))
- self.canvas.draw_idle()
-
-
 def bbox_artist(artist, renderer, props=None, fill=True):
 """
 This is a debug function to draw a rectangle around the bounding
Modified: branches/transforms/lib/matplotlib/path.py
===================================================================
--- branches/transforms/lib/matplotlib/path.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/path.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -405,4 +405,7 @@
 wedge = classmethod(wedge)
 
 def get_path_collection_extents(*args):
+ from transforms import Bbox
+ if len(args[1]) == 0:
+ raise ValueError("No paths provided")
 return Bbox.from_extents(*_path.get_path_collection_extents(*args))
Modified: branches/transforms/lib/matplotlib/scale.py
===================================================================
--- branches/transforms/lib/matplotlib/scale.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/scale.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -9,8 +9,6 @@
 from transforms import Affine1DBase, IntervalTransform, Transform, \
 composite_transform_factory, IdentityTransform
 
-# MGDTODO: Should the tickers/locators be moved here?
-
 class ScaleBase(object):
 def set_default_locators_and_formatters(self, axis):
 raise NotImplementedError
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/transforms.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -32,7 +32,7 @@
 import cbook
 from path import Path
 
-DEBUG = True
+DEBUG = False
 if DEBUG:
 import warnings
 
@@ -276,7 +276,7 @@
 size = property(_get_size)
 
 def _get_bounds(self):
- ((x0, y0), (x1, y1)) = self.get_points()
+ x0, y0, x1, y1 = self.get_points().flatten()
 return (x0, y0, x1 - x0, y1 - y0)
 bounds = property(_get_bounds)
 
@@ -608,21 +608,24 @@
 def invalidate(self):
 self._check(self._points)
 TransformNode.invalidate(self)
- 
+
+ _unit_values = npy.array([[0.0, 0.0], [1.0, 1.0]], npy.float_)
 #@staticmethod
 def unit():
 """
 Create a new unit BBox from (0, 0) to (1, 1).
 """
- return Bbox.from_extents(0., 0., 1., 1.)
+ return Bbox(Bbox._unit_values.copy())
 unit = staticmethod(unit)
 
 #@staticmethod
- def from_bounds(left, bottom, width, height):
+ def from_bounds(x0, y0, width, height):
 """
- Create a new Bbox from left, bottom, width and height.
+ Create a new Bbox from x0, y0, width and height.
+
+ width and height may be negative.
 """
- return Bbox.from_extents(left, bottom, left + width, bottom + height)
+ return Bbox.from_extents(x0, y0, x0 + width, y0 + height)
 from_bounds = staticmethod(from_bounds)
 
 #@staticmethod
@@ -663,7 +666,6 @@
 when False, include the existing bounds of the Bbox.
 when None, use the last value passed to Bbox.ignore().
 """
- # MGDTODO: It may be more efficient for some callers to use update_from_data_xy instead
 if ignore is None:
 ignore = self._ignore
 
@@ -830,7 +832,11 @@
 
 def get_points(self):
 if self._invalid:
- self._points = self._transform.transform(self._bbox.get_points())
+ points = self._transform.transform(self._bbox.get_points())
+ if ma.isMaskedArray(points):
+ points.putmask(0.0)
+ points = npy.asarray(points)
+ self._points = points
 self._invalid = 0
 return self._points
 
@@ -1429,8 +1435,8 @@
 if DEBUG:
 _transform = transform
 def transform(self, points):
- # MGDTODO: The major speed trap here is just converting to
- # the points to an array in the first place. If we can use
+ # The major speed trap here is just converting to the
+ # points to an array in the first place. If we can use
 # more arrays upstream, that should help here.
 if (not ma.isMaskedArray(points) and
 not isinstance(points, npy.ndarray)):
@@ -2074,7 +2080,7 @@
 """
 assert boxin.is_bbox
 assert boxout.is_bbox
-
+ 
 Affine2DBase.__init__(self)
 self._boxin = boxin
 self._boxout = boxout
@@ -2092,6 +2098,8 @@
 outl, outb, outw, outh = self._boxout.bounds
 x_scale = outw / inw
 y_scale = outh / inh
+ if DEBUG and (x_scale == 0 or y_scale == 0):
+ raise ValueError("Transforming from or to a singular bounding box.")
 self._mtx = npy.array([[x_scale, 0.0 , (-inl*x_scale+outl)],
 [0.0 , y_scale, (-inb*y_scale+outb)],
 [0.0 , 0.0 , 1.0 ]],
@@ -2175,18 +2183,17 @@
 return vmin, vmax
 
 
-# MGDTODO: Optimize (perhaps in an extension)
 def interval_contains(interval, val):
 a, b = interval
- return (((a < b)
- and (a <= val and b >= val))
- or (b <= val and a >= val))
+ return (
+ ((a < b) and (a <= val and b >= val))
+ or (b <= val and a >= val))
 
 def interval_contains_open(interval, val):
 a, b = interval
- return (((a < b)
- and (a < val and b > val))
- or (b < val and a > val))
+ return (
+ ((a < b) and (a < val and b > val))
+ or (b < val and a > val))
 
 if __name__ == '__main__':
 import copy
Modified: branches/transforms/lib/matplotlib/widgets.py
===================================================================
--- branches/transforms/lib/matplotlib/widgets.py	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/lib/matplotlib/widgets.py	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -240,9 +240,10 @@
 self.set_val(val)
 
 def set_val(self, val):
- self.poly.xy[-1] = val, 0
- self.poly.xy[-2] = val, 1
- self.poly.update()
+ xy = self.poly.xy
+ xy[-1] = val, 0
+ xy[-2] = val, 1
+ self.poly.xy = xy
 self.valtext.set_text(self.valfmt%val)
 if self.drawon: self.ax.figure.canvas.draw()
 self.val = val
Modified: branches/transforms/src/_gtkagg.cpp
===================================================================
--- branches/transforms/src/_gtkagg.cpp	2007年10月25日 18:16:03 UTC (rev 4003)
+++ branches/transforms/src/_gtkagg.cpp	2007年10月25日 19:16:11 UTC (rev 4004)
@@ -70,7 +70,6 @@
 }
 else {
 //bbox is not None; copy the image in the bbox
- // MGDTODO: Use PyArray rather than buffer interface here
 PyObject* clipbox = args[2].ptr();
 PyArrayObject* bbox = NULL;
 double l, b, r, t;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2007年10月25日 18:16:06
Revision: 4003
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4003&view=rev
Author: jdh2358
Date: 2007年10月25日 11:16:03 -0700 (2007年10月25日)
Log Message:
-----------
added convolution example
Modified Paths:
--------------
 trunk/py4science/examples/fft_imdenoise.py
 trunk/py4science/examples/skel/glass_dots1_skel.py
 trunk/py4science/examples/stock_records.py
 trunk/py4science/workbook/files_etc.tex
 trunk/py4science/workbook/main.tex
Modified: trunk/py4science/examples/fft_imdenoise.py
===================================================================
--- trunk/py4science/examples/fft_imdenoise.py	2007年10月25日 16:24:28 UTC (rev 4002)
+++ trunk/py4science/examples/fft_imdenoise.py	2007年10月25日 18:16:03 UTC (rev 4003)
@@ -14,16 +14,18 @@
 
 def plot_spectrum(F, amplify=1000):
 """Normalise, amplify and plot an amplitude spectrum."""
- M = mag_phase(F)[0]
+ M, Phase = mag_phase(F)
 M *= amplify/M.max()
 M[M > 1] = 1
- 
+
+ print M.shape, M.dtype
 P.imshow(M, P.cm.Blues)
 
 try:
 # Read in original image, convert to floating point for further
- # manipulation
- im = S.misc.pilutil.imread('data/moonlanding.jpg').astype(float)
+ # manipulation; imread returns a MxNx4 RGBA image. Since the
+ # image is grayscale, just extrac the 1st channel
+ im = P.imread('data/moonlanding.png').astype(float)[:,:,0]
 except:
 print "Could not open image."
 sys.exit(-1)
Modified: trunk/py4science/examples/skel/glass_dots1_skel.py
===================================================================
--- trunk/py4science/examples/skel/glass_dots1_skel.py	2007年10月25日 16:24:28 UTC (rev 4002)
+++ trunk/py4science/examples/skel/glass_dots1_skel.py	2007年10月25日 18:16:03 UTC (rev 4003)
@@ -11,24 +11,19 @@
 from pylab import figure, show
 
 def csqrt(x):
- """
- sqrt func that handles returns sqrt(x)j for x<0
- """
+ 'sqrt func that handles returns sqrt(x)j for x<0'
 XXX
 
 def myeig(M):
 """
 compute eigen values and eigenvectors analytically
-
 Solve quadratic:
-
 lamba^2 - tau*lambda + Delta = 0
-
 where tau = trace(M) and Delta = Determinant(M)
- 
+
+ Return value is lambda1, lambda2
 """
 XXX
- return lambda1, lambda2
 
 # 2000 random x,y points in the interval[-0.5 ... 0.5]
 X1 = XXX
@@ -39,10 +34,7 @@
 #name = 'center'
 #sx, sy, angle = XXX
 
-#name = 'stable focus' # spiral
-#sx, sy, angle = XXX
-
-name= 'spiral'
+name = 'spiral' #stable focus
 sx, sy, angle = XXX
 
 theta = angle * pi/180. # the rotation in radians
@@ -62,16 +54,14 @@
 M = XXX
 
 # compute the eigenvalues using numpy linear algebra
-vals, vecs = XXX
-print 'numpy eigenvalues', vals
+print 'numpy eigenvalues', XXX
 
 # compare with the analytic values from myeig
-avals = myeig(M)
-print 'analytic eigenvalues', avals
+print 'analytic eigenvalues', myeig(M)
 
 # transform X1 by the matrix M
 X2 = XXX
 
-# plot the original x,y as green dots and the transformed x, y as red
+# plot the original X1 as green dots and the transformed X2 as red
 # dots
-show()
+XXX
Modified: trunk/py4science/examples/stock_records.py
===================================================================
--- trunk/py4science/examples/stock_records.py	2007年10月25日 16:24:28 UTC (rev 4002)
+++ trunk/py4science/examples/stock_records.py	2007年10月25日 18:16:03 UTC (rev 4003)
@@ -67,6 +67,6 @@
 print '%s: %1.1f%%'%(ticker, 100*g)
 
 
-p.savefig('fig/stock_records.png', dpi=100)
-p.savefig('fig/stock_records.eps')
+p.savefig('stock_records.png', dpi=100)
+p.savefig('stock_records.eps')
 p.show()
Modified: trunk/py4science/workbook/files_etc.tex
===================================================================
--- trunk/py4science/workbook/files_etc.tex	2007年10月25日 16:24:28 UTC (rev 4002)
+++ trunk/py4science/workbook/files_etc.tex	2007年10月25日 18:16:03 UTC (rev 4003)
@@ -204,7 +204,7 @@
 \par\end{center}
 
 
-\subsection{Loading and saving binary data}
+\section{Loading and saving binary data}
 \label{sec:binary_data}
 
 ASCII is bloated and slow for working with large arrays, and so binary
Modified: trunk/py4science/workbook/main.tex
===================================================================
--- trunk/py4science/workbook/main.tex	2007年10月25日 16:24:28 UTC (rev 4002)
+++ trunk/py4science/workbook/main.tex	2007年10月25日 18:16:03 UTC (rev 4003)
@@ -57,4 +57,11 @@
 \input{trapezoid.tex}
 
 \input{quad_newton.tex}
+
+\chapter{Linear algebra}
+\input{intro_linalg.tex}
+\input{glass_dots.tex}
+
+
+
 \end{document}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 4002
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4002&view=rev
Author: efiring
Date: 2007年10月25日 09:24:28 -0700 (2007年10月25日)
Log Message:
-----------
Fix vector rotation; southern hemisphere vectors were reversed
Modified Paths:
--------------
 trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py
Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py
===================================================================
--- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py	2007年10月25日 14:10:16 UTC (rev 4001)
+++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py	2007年10月25日 16:24:28 UTC (rev 4002)
@@ -12,7 +12,7 @@
 from proj import Proj
 import matplotlib.numerix as NX
 from matplotlib.numerix import ma
-from matplotlib.mlab import linspace
+from numpy import linspace
 from matplotlib.numerix.mlab import squeeze
 from matplotlib.cbook import popd, is_scalar
 from shapelib import ShapeFile
@@ -2175,12 +2175,11 @@
 uin = interp(uin,lons,lats,lonsout,latsout,checkbounds=checkbounds,order=order,masked=masked)
 vin = interp(vin,lons,lats,lonsout,latsout,checkbounds=checkbounds,order=order,masked=masked)
 # rotate from geographic to map coordinates.
- delta = 0.1 # incement in latitude used to estimate derivatives.
+ delta = 0.1 # increment in latitude used to estimate derivatives.
 xn,yn = self(lonsout,NX.where(latsout+delta<90.,latsout+delta,latsout-delta))
- dxdlat = NX.where(latsout+delta<90.,(xn-x)/(latsout+delta),(x-xn)/(latsout+delta))
- dydlat = NX.where(latsout+delta<90.,(yn-y)/(latsout+delta),(y-yn)/(latsout+delta))
 # northangle is the angle between true north and the y axis.
- northangle = NX.arctan2(dxdlat,dydlat)
+ northangle = NX.where(lats+delta<90, NX.arctan2(xn-x, yn-y),
+ NX.arctan2(x-xn, y-yn))
 uout = uin*NX.cos(northangle) + vin*NX.sin(northangle)
 vout = vin*NX.cos(northangle) - uin*NX.sin(northangle)
 if returnxy:
@@ -2211,12 +2210,10 @@
 """
 x, y = self(lons, lats)
 # rotate from geographic to map coordinates.
- delta = 0.1 # incement in latitude used to estimate derivatives.
+ delta = 0.1 # increment in latitude used to estimate derivatives.
 xn,yn = self(lons,NX.where(lats+delta<90.,lats+delta,lats-delta))
- dxdlat = NX.where(lats+delta<90.,(xn-x)/(lats+delta),(x-xn)/(lats+delta))
- dydlat = NX.where(lats+delta<90.,(yn-y)/(lats+delta),(y-yn)/(lats+delta))
- # northangle is the angle between true north and the y axis.
- northangle = NX.arctan2(dxdlat,dydlat)
+ northangle = NX.where(lats+delta<90, NX.arctan2(xn-x, yn-y),
+ NX.arctan2(x-xn, y-yn))
 uout = uin*NX.cos(northangle) + vin*NX.sin(northangle)
 vout = vin*NX.cos(northangle) - uin*NX.sin(northangle)
 if returnxy:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月25日 14:10:57
Revision: 4001
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4001&view=rev
Author: mdboom
Date: 2007年10月25日 07:10:16 -0700 (2007年10月25日)
Log Message:
-----------
Merged revisions 3984-4000 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib
........
 r3991 | efiring | 2007年10月23日 17:25:24 -0400 (2007年10月23日) | 2 lines
 
 Bugfix: save colorbar axis label so it won't get lost
........
 r3999 | efiring | 2007年10月24日 18:14:57 -0400 (2007年10月24日) | 2 lines
 
 Added ax kwarg to pyplot.colorbar and Figure.colorbar
........
Modified Paths:
--------------
 branches/transforms/API_CHANGES
 branches/transforms/CHANGELOG
 branches/transforms/lib/matplotlib/colorbar.py
 branches/transforms/lib/matplotlib/figure.py
 branches/transforms/lib/matplotlib/pyplot.py
Property Changed:
----------------
 branches/transforms/
Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
 - /trunk/matplotlib:1-3983
 + /trunk/matplotlib:1-4000
Modified: branches/transforms/API_CHANGES
===================================================================
--- branches/transforms/API_CHANGES	2007年10月25日 14:07:44 UTC (rev 4000)
+++ branches/transforms/API_CHANGES	2007年10月25日 14:10:16 UTC (rev 4001)
@@ -1,6 +1,11 @@
- Changed cbook.reversed so it yields a tuple rather than a 
+ Added ax kwarg to pyplot.colorbar and Figure.colorbar so that
+ one can specify the axes object from which space for the colorbar
+ is to be taken, if one does not want to make the colorbar axes
+ manually.
+
+ Changed cbook.reversed so it yields a tuple rather than a
 (index, tuple). This agrees with the python reversed builtin,
- and cbook only defines reversed if python doesnt provide the 
+ and cbook only defines reversed if python doesnt provide the
 builtin.
 
 Made skiprows=1 the default on csv2rec
Modified: branches/transforms/CHANGELOG
===================================================================
--- branches/transforms/CHANGELOG	2007年10月25日 14:07:44 UTC (rev 4000)
+++ branches/transforms/CHANGELOG	2007年10月25日 14:10:16 UTC (rev 4001)
@@ -1,3 +1,5 @@
+2007年10月24日 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF
+
 2007年10月19日 Removed a gsave/grestore pair surrounding _draw_ps, which
 was causing a loss graphics state info (see "EPS output
 problem - scatter & edgecolors" on mpl-dev, 2007年10月29日)
@@ -12,7 +14,7 @@
 unit/ellipse_compare.py to compare spline with vertex
 approx for both aspects. JDH
 
-2007年10月05日 remove generator expressions from texmanager and mpltraits. 
+2007年10月05日 remove generator expressions from texmanager and mpltraits.
 generator expressions are not supported by python-2.3 - DSD
 
 2007年10月01日 Made matplotlib.use() raise an exception if called after
Modified: branches/transforms/lib/matplotlib/colorbar.py
===================================================================
--- branches/transforms/lib/matplotlib/colorbar.py	2007年10月25日 14:07:44 UTC (rev 4000)
+++ branches/transforms/lib/matplotlib/colorbar.py	2007年10月25日 14:10:16 UTC (rev 4001)
@@ -70,21 +70,27 @@
 colorbar_doc = '''
 Add a colorbar to a plot.
 
-Function signatures:
+Function signatures for the pyplot interface; all but the first are
+also method signatures for the Figure.colorbar method:
 
 colorbar(**kwargs)
-
 colorbar(mappable, **kwargs)
+ colorbar(mappable, cax=cax, **kwargs)
+ colorbar(mappable, ax=ax, **kwargs)
 
- colorbar(mappable, cax, **kwargs)
+ arguments:
+ mappable: the image, ContourSet, etc. to which the colorbar applies;
+ this argument is mandatory for the Figure.colorbar
+ method but optional for the pyplot.colorbar function,
+ which sets the default to the current image.
 
-The optional arguments mappable and cax may be included in the kwargs;
-they are image, ContourSet, etc. to which the colorbar applies, and
-the axes object in which the colorbar will be drawn. Defaults are
-the current image and a new axes object created next to that image
-after resizing the image.
+ keyword arguments:
+ cax: None | axes object into which the colorbar will be drawn
+ ax: None | parent axes object from which space for a new
+ colorbar axes will be stolen
 
-kwargs are in two groups:
+
+**kwargs are in two groups:
 axes properties:
 %s
 colorbar properties:
@@ -155,6 +161,7 @@
 self.filled = filled
 self.solids = None
 self.lines = None
+ self.set_label('')
 if cbook.iterable(ticks):
 self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
 else:
@@ -183,6 +190,7 @@
 self._config_axes(X, Y)
 if self.filled:
 self._add_solids(X, Y, C)
+ self._set_label()
 
 def _config_axes(self, X, Y):
 '''
@@ -220,12 +228,18 @@
 ax.set_xticklabels(ticklabels)
 ax.xaxis.get_major_formatter().set_offset_string(offset_string)
 
- def set_label(self, label, **kw):
+ def _set_label(self):
 if self.orientation == 'vertical':
- self.ax.set_ylabel(label, **kw)
+ self.ax.set_ylabel(self._label, **self._labelkw)
 else:
- self.ax.set_xlabel(label, **kw)
+ self.ax.set_xlabel(self._label, **self._labelkw)
 
+ def set_label(self, label, **kw):
+ self._label = label
+ self._labelkw = kw
+ self._set_label()
+
+
 def _outline(self, X, Y):
 '''
 Return x, y arrays of colorbar bounding polygon,
@@ -556,6 +570,10 @@
 is changed.
 '''
 cm.ScalarMappable.notify(self, mappable)
+ # We are using an ugly brute-force method: clearing and
+ # redrawing the whole thing. The problem is that if any
+ # properties have been changed by methods other than the
+ # colorbar methods, those changes will be lost.
 self.ax.cla()
 self.draw_all()
 #if self.vmin != self.norm.vmin or self.vmax != self.norm.vmax:
Modified: branches/transforms/lib/matplotlib/figure.py
===================================================================
--- branches/transforms/lib/matplotlib/figure.py	2007年10月25日 14:07:44 UTC (rev 4000)
+++ branches/transforms/lib/matplotlib/figure.py	2007年10月25日 14:10:16 UTC (rev 4001)
@@ -790,9 +790,9 @@
 
 self.canvas.print_figure(*args, **kwargs)
 
- def colorbar(self, mappable, cax=None, **kw):
- orientation = kw.get('orientation', 'vertical')
- ax = self.gca()
+ def colorbar(self, mappable, cax=None, ax=None, **kw):
+ if ax is None:
+ ax = self.gca()
 if cax is None:
 cax, kw = cbar.make_axes(ax, **kw)
 cb = cbar.Colorbar(cax, mappable, **kw)
Modified: branches/transforms/lib/matplotlib/pyplot.py
===================================================================
--- branches/transforms/lib/matplotlib/pyplot.py	2007年10月25日 14:07:44 UTC (rev 4000)
+++ branches/transforms/lib/matplotlib/pyplot.py	2007年10月25日 14:10:16 UTC (rev 4001)
@@ -1081,10 +1081,10 @@
 
 
 from matplotlib.colorbar import colorbar_doc
-def colorbar(mappable = None, cax=None,**kw):
+def colorbar(mappable=None, cax=None, ax=None, **kw):
 if mappable is None:
 mappable = gci()
- ret = gcf().colorbar(mappable, cax = cax, **kw)
+ ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
 draw_if_interactive()
 return ret
 colorbar.__doc__ = colorbar_doc
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月25日 14:07:46
Revision: 4000
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4000&view=rev
Author: mdboom
Date: 2007年10月25日 07:07:44 -0700 (2007年10月25日)
Log Message:
-----------
table_demo working. Lots of minor fixes. Faster transforms when
debugging is turned off.
Modified Paths:
--------------
 branches/transforms/PASSED_DEMOS
 branches/transforms/examples/contour_demo.py
 branches/transforms/lib/matplotlib/axes.py
 branches/transforms/lib/matplotlib/backend_bases.py
 branches/transforms/lib/matplotlib/backends/backend_pdf.py
 branches/transforms/lib/matplotlib/backends/backend_ps.py
 branches/transforms/lib/matplotlib/lines.py
 branches/transforms/lib/matplotlib/patches.py
 branches/transforms/lib/matplotlib/scale.py
 branches/transforms/lib/matplotlib/table.py
 branches/transforms/lib/matplotlib/transforms.py
Modified: branches/transforms/PASSED_DEMOS
===================================================================
--- branches/transforms/PASSED_DEMOS	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/PASSED_DEMOS	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -156,13 +156,13 @@
 polar_demo.py		O
 polar_legend.py		O
 polar_scatter.py	O
-poly_editor.py		[NEEDS OVERHAUL]
+poly_editor.py		O
 poormans_contour.py	O
-printing_in_wx.py
+printing_in_wx.py	[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
 print_stdout.py		[BROKEN?]
 psd_demo.py		O
-pstest.py
-pylab_with_gtk.py
+pstest.py		O
+pylab_with_gtk.py	O
 pythonic_matplotlib.py	O
 quadmesh_demo.py	O [MASKED VALUES ARE SHOWN DUE TO A BUG IN TRUNK]
 quiver_demo.py		O
@@ -190,7 +190,7 @@
 subplots_adjust.py	O
 subplot_toolbar.py	O
 system_monitor.py	O
-table_demo.py		
+table_demo.py		O
 tex_demo.py		O
 text_handles.py		O
 text_rotation.py	O	
@@ -204,7 +204,7 @@
 vertical_ticklabels.py	O
 vline_demo.py		O
 webapp_demo.py		
-wxcursor_demo.py	
+wxcursor_demo.py	O
 xcorr_demo.py		O	
 zoom_window.py		O
 zorder_demo.py		O
Modified: branches/transforms/examples/contour_demo.py
===================================================================
--- branches/transforms/examples/contour_demo.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/examples/contour_demo.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -92,8 +92,8 @@
 # This makes the original colorbar look a bit out of place,
 # so let's improve its position.
 
-l,b,w,h = gca().get_position()
-ll,bb,ww,hh = CB.ax.get_position()
+l,b,w,h = gca().get_position().bounds
+ll,bb,ww,hh = CB.ax.get_position().bounds
 CB.ax.set_position([ll, b+0.1*h, ww, h*0.8])
 
 
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/axes.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -582,8 +582,6 @@
 self._yaxis_transform = mtransforms.blended_transform_factory(
 self.axes.transAxes, self.axes.transData)
 
- self.transData.write_graphviz(open("trans.dot", "w"))
-
 def get_xaxis_transform(self):
 return self._xaxis_transform
 
@@ -636,8 +634,10 @@
 'original' to change the second;
 'both' to change both
 
- ACCEPTS: len(4) sequence of floats
+ ACCEPTS: len(4) sequence of floats, or a Bbox object
 """
+ if not isinstance(pos, mtransforms.BboxBase):
+ pos = mtransforms.Bbox.from_bounds(*pos)
 if which in ('both', 'active'):
 	 self._position.set(pos)
 if which in ('both', 'original'):
Modified: branches/transforms/lib/matplotlib/backend_bases.py
===================================================================
--- branches/transforms/lib/matplotlib/backend_bases.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/backend_bases.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -155,7 +155,7 @@
 gc.set_clip_rectangle(cliprect)
 if clippath is not None:
 clippath = transforms.TransformedPath(clippath, clippath_trans)
- gc.set_clippath(clippath)
+ gc.set_clip_path(clippath)
 
 if Nfacecolors == 0:
 rgbFace = None
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -1032,7 +1032,7 @@
 def writeMarkers(self):
 for tup in self.markers.values():
 name, object, path, trans, fillp, lw = tup
- bbox = Bbox.from_extents(*path.get_extents(trans))
+ bbox = path.get_extents(trans)
 bbox = bbox.padded(lw * 0.5)
 self.beginStream(
 object.id, None,
Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/backends/backend_ps.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -402,7 +402,6 @@
 clipx,clipy,clipw,cliph = bbox.bounds
 clip.append('%s clipbox' % _nums_to_str(clipw, cliph, clipx, clipy))
 if clippath is not None:
- print "clippath"
 id = self._get_clip_path(clippath, clippath_trans)
 clip.append('%s' % id)
 clip = '\n'.join(clip)
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -448,7 +448,6 @@
 renderer.open_group('line2d')
 
 if not self._visible: return
- self._newstyle = hasattr(renderer, 'draw_markers')
 gc = renderer.new_gc()
 self._set_gc_clip(gc)
 
Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/patches.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -102,7 +102,7 @@
 self.set_fill(other.get_fill())
 self.set_hatch(other.get_hatch())
 self.set_linewidth(other.get_linewidth())
- self.set_transform(other.get_transform())
+ self.set_transform(other.get_data_transform())
 self.set_figure(other.get_figure())
 self.set_alpha(other.get_alpha())
 
Modified: branches/transforms/lib/matplotlib/scale.py
===================================================================
--- branches/transforms/lib/matplotlib/scale.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/scale.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -42,9 +42,6 @@
 is_separable = True
 
 def transform(self, a):
- # MGDTODO: Remove me
- if len(a) > 10:
- print "log transforming"
 return ma.log10(ma.masked_where(a <= 0.0, a * 10.0))
 
 def inverted(self):
Modified: branches/transforms/lib/matplotlib/table.py
===================================================================
--- branches/transforms/lib/matplotlib/table.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/table.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -75,7 +75,6 @@
 return self._text
 
 def set_fontsize(self, size):
-
 self._text.set_fontsize(size)
 
 def get_fontsize(self):
@@ -108,7 +107,7 @@
 Currently support 'left', 'center' and 'right'
 """
 bbox = self.get_window_extent(renderer)
- l, b, w, h = bbox.get_bounds()
+ l, b, w, h = bbox.bounds
 
 # draw in center vertically
 self._text.set_verticalalignment('center')
@@ -130,8 +129,8 @@
 def get_text_bounds(self, renderer):
 """ Get text bounds in axes co-ordinates. """
 bbox = self._text.get_window_extent(renderer)
-	bboxa = bbox.inverse_transformed(self.get_transform())
- return bboxa.get_bounds()
+	bboxa = bbox.inverse_transformed(self.get_data_transform())
+ return bboxa.bounds
 
 def get_required_width(self, renderer):
 """ Get width required for this cell. """
@@ -246,8 +245,8 @@
 for pos in self._cells.keys()
 if pos[0] >= 0 and pos[1] >= 0]
 
- bbox = bbox_all(boxes)
- return inverse_transform_bbox(self.get_transform(), bbox)
+ bbox = Bbox.union(boxes)
+ return bbox.inverse_transformed(self.get_transform())
 
 def contains(self,mouseevent):
 """Test whether the mouse event occurred in the table.
@@ -393,7 +392,7 @@
 self._do_cell_alignment()
 
 bbox = self._get_grid_bbox(renderer)
- l,b,w,h = bbox.get_bounds()
+ l,b,w,h = bbox.bounds
 
 if self._bbox is not None:
 # Position according to bbox
@@ -530,7 +529,7 @@
 if rowLabels is not None:
 for row in xrange(rows):
 table.add_cell(row+offset, -1,
- width=rowLabelWidth, height=height,
+ width=rowLabelWidth or 1e-15, height=height,
 text=rowLabels[row], facecolor=rowColours[row],
 loc=rowLoc)
 if rowLabelWidth == 0:
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py	2007年10月24日 22:14:57 UTC (rev 3999)
+++ branches/transforms/lib/matplotlib/transforms.py	2007年10月25日 14:07:44 UTC (rev 4000)
@@ -32,7 +32,9 @@
 import cbook
 from path import Path
 
-DEBUG = False
+DEBUG = True
+if DEBUG:
+ import warnings
 
 class TransformNode(object):
 """
@@ -140,6 +142,9 @@
 
 fobj: A Python file-like object
 """
+ if not DEBUG:
+ return
+ 
 seen = cbook.set()
 
 def recurse(root):
@@ -189,6 +194,15 @@
 def __init__(self):
 TransformNode.__init__(self)
 
+ if DEBUG:
+ def _check(points):
+ if ma.isMaskedArray(points):
+ warnings.warn("Bbox bounds are a masked array.")
+ if (points[1,0] - points[0,0] == 0 or
+ points[1,1] - points[0,1] == 0):
+ warnings.warn("Singular Bbox.")
+ _check = staticmethod(_check)
+ 
 def frozen(self):
 return Bbox(self.get_points().copy())
 frozen.__doc__ = TransformNode.__doc__
@@ -585,6 +599,16 @@
 self._minpos = npy.array([0.0000001, 0.0000001])
 self._ignore = True
 
+ if DEBUG:
+ ___init__ = __init__
+ def __init__(self, points):
+ self._check(points)
+ self.___init__(points)
+ 
+ def invalidate(self):
+ self._check(self._points)
+ TransformNode.invalidate(self)
+ 
 #@staticmethod
 def unit():
 """
@@ -809,8 +833,14 @@
 self._points = self._transform.transform(self._bbox.get_points())
 self._invalid = 0
 return self._points
+
+ if DEBUG:
+ _get_points = get_points
+ def get_points(self):
+ points = self._get_points()
+ self._check(points)
+ return points
 
- 
 class Transform(TransformNode):
 """
 The base class of all TransformNodes that actually perform a
@@ -1148,20 +1178,24 @@
 matrix_from_values = staticmethod(matrix_from_values)
 
 def transform(self, values):
- # The major speed trap here is just converting to the points
- # to an array in the first place. If we can use more arrays
- # upstream, that should help here.
- if DEBUG and not isinstance(values, npy.ndarray):
- import traceback
- print '-' * 60
- print 'A non-numpy array of type %s was passed in for transformation.' % type(values)
- print 'Please correct this.'
- print "".join(traceback.format_stack())
 mtx = self.get_matrix()
 points = npy.asarray(values, npy.float_)
 return points * mtx[0, 0] + mtx[0, 1]
+
+ if DEBUG:
+ _transform = transform
+ def transform(self, values):
+ # The major speed trap here is just converting to the points
+ # to an array in the first place. If we can use more arrays
+ # upstream, that should help here.
+ if not isinstance(values, npy.ndarray):
+ warnings.warn(
+ ('A non-numpy array of type %s was passed in for ' +
+ 'transformation. Please correct this.')
+ % type(values))
+ return self._transform(values)
 transform.__doc__ = AffineBase.transform.__doc__
-
+ 
 transform_affine = transform
 transform_affine.__doc__ = AffineBase.transform_affine.__doc__
 
@@ -1385,22 +1419,26 @@
 matrix_from_values = staticmethod(matrix_from_values)
 
 def transform(self, points):
- # MGDTODO: The major speed trap here is just converting to
- # the points to an array in the first place. If we can use
- # more arrays upstream, that should help here.
- if DEBUG and not ma.isMaskedArray(points) and not isinstance(points, npy.ndarray):
- import traceback
- print '-' * 60
- print 'A non-numpy array of type %s was passed in for transformation.' % type(points)
- print 'Please correct this.'
- print "".join(traceback.format_stack())
 mtx = self.get_matrix()
 if ma.isMaskedArray(points):
 points = ma.dot(mtx[0:2, 0:2], points.transpose()) + mtx[0:2, 2:]
 else:
- # points = npy.asarray(points, npy.float_)
 points = npy.dot(mtx[0:2, 0:2], points.transpose()) + mtx[0:2, 2:]
 return points.transpose()
+
+ if DEBUG:
+ _transform = transform
+ def transform(self, points):
+ # MGDTODO: The major speed trap here is just converting to
+ # the points to an array in the first place. If we can use
+ # more arrays upstream, that should help here.
+ if (not ma.isMaskedArray(points) and
+ not isinstance(points, npy.ndarray)):
+ warnings.warn(
+ ('A non-numpy array of type %s was passed in for ' +
+ 'transformation. Please correct this.')
+ % type(values))
+ return self._transform(points)
 transform.__doc__ = AffineBase.transform.__doc__
 
 transform_affine = transform
@@ -1660,9 +1698,6 @@
 create.
 """
 	# Here we ask: "Does it blend?"
- # MGDTODO: Reinvoke these asserts?
- # assert x_transform.is_separable()
- # assert y_transform.is_separable()
 
 Transform.__init__(self)
 self._x = x_transform
@@ -2111,6 +2146,7 @@
 
 def get_affine(self):
 return self._transform.get_affine()
+
 
 def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
 '''
@@ -2231,5 +2267,3 @@
 points = npy.asarray([(random(), random()) for i in xrange(10000)])
 t = timeit.Timer("trans_sum.transform(points)", "from __main__ import trans_sum, points")
 print "Time to transform 10000 x 10 points:", t.timeit(10)
- 
-__all__ = ['Transform', 'Affine2D']
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2007年10月24日 22:15:01
Revision: 3999
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3999&view=rev
Author: efiring
Date: 2007年10月24日 15:14:57 -0700 (2007年10月24日)
Log Message:
-----------
Added ax kwarg to pyplot.colorbar and Figure.colorbar
Modified Paths:
--------------
 trunk/matplotlib/API_CHANGES
 trunk/matplotlib/CHANGELOG
 trunk/matplotlib/lib/matplotlib/colorbar.py
 trunk/matplotlib/lib/matplotlib/figure.py
 trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/API_CHANGES
===================================================================
--- trunk/matplotlib/API_CHANGES	2007年10月24日 19:42:49 UTC (rev 3998)
+++ trunk/matplotlib/API_CHANGES	2007年10月24日 22:14:57 UTC (rev 3999)
@@ -1,6 +1,11 @@
- Changed cbook.reversed so it yields a tuple rather than a 
+ Added ax kwarg to pyplot.colorbar and Figure.colorbar so that
+ one can specify the axes object from which space for the colorbar
+ is to be taken, if one does not want to make the colorbar axes
+ manually.
+
+ Changed cbook.reversed so it yields a tuple rather than a
 (index, tuple). This agrees with the python reversed builtin,
- and cbook only defines reversed if python doesnt provide the 
+ and cbook only defines reversed if python doesnt provide the
 builtin.
 
 Made skiprows=1 the default on csv2rec
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG	2007年10月24日 19:42:49 UTC (rev 3998)
+++ trunk/matplotlib/CHANGELOG	2007年10月24日 22:14:57 UTC (rev 3999)
@@ -1,3 +1,5 @@
+2007年10月24日 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF
+
 2007年10月19日 Removed a gsave/grestore pair surrounding _draw_ps, which
 was causing a loss graphics state info (see "EPS output
 problem - scatter & edgecolors" on mpl-dev, 2007年10月29日)
@@ -12,7 +14,7 @@
 unit/ellipse_compare.py to compare spline with vertex
 approx for both aspects. JDH
 
-2007年10月05日 remove generator expressions from texmanager and mpltraits. 
+2007年10月05日 remove generator expressions from texmanager and mpltraits.
 generator expressions are not supported by python-2.3 - DSD
 
 2007年10月01日 Made matplotlib.use() raise an exception if called after
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py	2007年10月24日 19:42:49 UTC (rev 3998)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py	2007年10月24日 22:14:57 UTC (rev 3999)
@@ -70,21 +70,27 @@
 colorbar_doc = '''
 Add a colorbar to a plot.
 
-Function signatures:
+Function signatures for the pyplot interface; all but the first are
+also method signatures for the Figure.colorbar method:
 
 colorbar(**kwargs)
-
 colorbar(mappable, **kwargs)
+ colorbar(mappable, cax=cax, **kwargs)
+ colorbar(mappable, ax=ax, **kwargs)
 
- colorbar(mappable, cax, **kwargs)
+ arguments:
+ mappable: the image, ContourSet, etc. to which the colorbar applies;
+ this argument is mandatory for the Figure.colorbar
+ method but optional for the pyplot.colorbar function,
+ which sets the default to the current image.
 
-The optional arguments mappable and cax may be included in the kwargs;
-they are image, ContourSet, etc. to which the colorbar applies, and
-the axes object in which the colorbar will be drawn. Defaults are
-the current image and a new axes object created next to that image
-after resizing the image.
+ keyword arguments:
+ cax: None | axes object into which the colorbar will be drawn
+ ax: None | parent axes object from which space for a new
+ colorbar axes will be stolen
 
-kwargs are in two groups:
+
+**kwargs are in two groups:
 axes properties:
 %s
 colorbar properties:
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py	2007年10月24日 19:42:49 UTC (rev 3998)
+++ trunk/matplotlib/lib/matplotlib/figure.py	2007年10月24日 22:14:57 UTC (rev 3999)
@@ -769,9 +769,9 @@
 
 self.canvas.print_figure(*args, **kwargs)
 
- def colorbar(self, mappable, cax=None, **kw):
- orientation = kw.get('orientation', 'vertical')
- ax = self.gca()
+ def colorbar(self, mappable, cax=None, ax=None, **kw):
+ if ax is None:
+ ax = self.gca()
 if cax is None:
 cax, kw = cbar.make_axes(ax, **kw)
 cb = cbar.Colorbar(cax, mappable, **kw)
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py	2007年10月24日 19:42:49 UTC (rev 3998)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py	2007年10月24日 22:14:57 UTC (rev 3999)
@@ -1080,10 +1080,10 @@
 
 
 from matplotlib.colorbar import colorbar_doc
-def colorbar(mappable = None, cax=None,**kw):
+def colorbar(mappable=None, cax=None, ax=None, **kw):
 if mappable is None:
 mappable = gci()
- ret = gcf().colorbar(mappable, cax = cax, **kw)
+ ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
 draw_if_interactive()
 return ret
 colorbar.__doc__ = colorbar_doc
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 19:42:58
Revision: 3998
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3998&view=rev
Author: mdboom
Date: 2007年10月24日 12:42:49 -0700 (2007年10月24日)
Log Message:
-----------
More examples working.
Modified Paths:
--------------
 branches/transforms/examples/poly_editor.py
 branches/transforms/examples/wxcursor_demo.py
 branches/transforms/lib/matplotlib/backends/backend_wx.py
 branches/transforms/lib/matplotlib/patches.py
 branches/transforms/lib/matplotlib/transforms.py
Modified: branches/transforms/examples/poly_editor.py
===================================================================
--- branches/transforms/examples/poly_editor.py	2007年10月24日 19:22:00 UTC (rev 3997)
+++ branches/transforms/examples/poly_editor.py	2007年10月24日 19:42:49 UTC (rev 3998)
@@ -68,10 +68,11 @@
 
 def get_ind_under_point(self, event):
 'get the index of the vertex under point if within epsilon tolerance'
- x, y = zip(*self.poly.xy)
 
 # display coords
- xt, yt = self.poly.get_transform().numerix_x_y(x, y)
+ xy = npy.asarray(self.poly.xy)
+ xyt = self.poly.get_transform().transform(xy)
+ xt, yt = xyt[:, 0], xyt[:, 1]
 d = sqrt((xt-event.x)**2 + (yt-event.y)**2)
 indseq = nonzero(equal(d, amin(d)))
 ind = indseq[0]
@@ -130,7 +131,7 @@
 x,y = event.xdata, event.ydata
 self.poly.xy[self._ind] = x,y
 self.line.set_data(zip(*self.poly.xy))
-
+ 
 self.canvas.restore_region(self.background)
 self.ax.draw_artist(self.poly)
 self.ax.draw_artist(self.line)
Modified: branches/transforms/examples/wxcursor_demo.py
===================================================================
--- branches/transforms/examples/wxcursor_demo.py	2007年10月24日 19:22:00 UTC (rev 3997)
+++ branches/transforms/examples/wxcursor_demo.py	2007年10月24日 19:42:49 UTC (rev 3998)
@@ -3,6 +3,8 @@
 """
 
 import matplotlib
+matplotlib.use('WXAgg')
+
 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
 from matplotlib.backends.backend_wx import NavigationToolbar2Wx
 from matplotlib.figure import Figure
@@ -65,6 +67,5 @@
 return True
 
 if __name__=='__main__':
- matplotlib.use('WXAgg')
 app = App(0)
 app.MainLoop()
Modified: branches/transforms/lib/matplotlib/backends/backend_wx.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_wx.py	2007年10月24日 19:22:00 UTC (rev 3997)
+++ branches/transforms/lib/matplotlib/backends/backend_wx.py	2007年10月24日 19:42:49 UTC (rev 3998)
@@ -2043,7 +2043,7 @@
 vscale = float(ppw) / fig_dpi
 
 # set figure resolution,bg color for printer
- self.canvas.figure.dpi.set(ppw)
+ self.canvas.figure.dpi = ppw
 self.canvas.figure.set_facecolor('#FFFFFF')
 
 renderer = RendererWx(self.canvas.bitmap, self.canvas.figure.dpi)
Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py	2007年10月24日 19:22:00 UTC (rev 3997)
+++ branches/transforms/lib/matplotlib/patches.py	2007年10月24日 19:42:49 UTC (rev 3998)
@@ -506,8 +506,8 @@
 See Patch documentation for additional kwargs
 """
 Patch.__init__(self, **kwargs)
- self.xy = xy
 	self._path = Path(xy, closed=True)
+ self.xy = self._path.vertices
 __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
 
 def get_path(self):
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py	2007年10月24日 19:22:00 UTC (rev 3997)
+++ branches/transforms/lib/matplotlib/transforms.py	2007年10月24日 19:42:49 UTC (rev 3998)
@@ -927,6 +927,7 @@
 The transformed point is returned as a sequence of length
 self.output_dims.
 """
+ assert len(point) == 2
 return self.transform(npy.asarray([point]))[0]
 
 def transform_path(self, path):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 19:22:04
Revision: 3997
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3997&view=rev
Author: mdboom
Date: 2007年10月24日 12:22:00 -0700 (2007年10月24日)
Log Message:
-----------
Renamed [xmin, ymin, xmax, ymax] in Bbox to [x0, y0, x1, y1] and
provide functions that really do give xmax etc. as well.
Renamed lbrt to extents and lbwh to bounds (for consistency).
Removed some dead code.
Modified Paths:
--------------
 branches/transforms/lib/matplotlib/axes.py
 branches/transforms/lib/matplotlib/axis.py
 branches/transforms/lib/matplotlib/backend_bases.py
 branches/transforms/lib/matplotlib/backends/backend_agg.py
 branches/transforms/lib/matplotlib/backends/backend_pdf.py
 branches/transforms/lib/matplotlib/collections.py
 branches/transforms/lib/matplotlib/figure.py
 branches/transforms/lib/matplotlib/image.py
 branches/transforms/lib/matplotlib/legend.py
 branches/transforms/lib/matplotlib/lines.py
 branches/transforms/lib/matplotlib/patches.py
 branches/transforms/lib/matplotlib/path.py
 branches/transforms/lib/matplotlib/projections/polar.py
 branches/transforms/lib/matplotlib/text.py
 branches/transforms/lib/matplotlib/transforms.py
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/axes.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -480,7 +480,7 @@
 if isinstance(rect, mtransforms.Bbox):
 self._position = rect
 else:
- self._position = mtransforms.Bbox.from_lbwh(*rect)
+ self._position = mtransforms.Bbox.from_bounds(*rect)
 self._originalPosition = self._position.frozen()
 self.set_axes(self)
 self.set_aspect('auto')
@@ -1696,7 +1696,7 @@
 	 # Call all of the other y-axes that are shared with this one
 	 for other in self._shared_y_axes.get_siblings(self):
 		if other is not self:
-		 other.set_ylim(self.viewLim.ymin, self.viewLim.ymax, emit=False)
+		 other.set_ylim(self.viewLim.intervaly, emit=False)
 
 if self.figure.canvas is not None:
 self.figure.canvas.draw_idle()
@@ -1902,7 +1902,6 @@
 if self.get_aspect() != 'auto':
 dx = 0.5 * (dx + dy)
 dy = dx
- xmin, ymin, xmax, ymax = p.lim.lbrt
 
 alpha = npy.power(10.0, (dx, dy))
 start = p.trans_inverse.transform_point((p.x, p.y))
@@ -5207,7 +5206,7 @@
 figBottom = top - (rowNum+1)*figH - rowNum*sepH
 figLeft = left + colNum*(figW + sepW)
 
- self.figbox = mtransforms.Bbox.from_lbwh(figLeft, figBottom, figW, figH)
+ self.figbox = mtransforms.Bbox.from_bounds(figLeft, figBottom, figW, figH)
 self.rowNum = rowNum
 self.colNum = colNum
 self.numRows = rows
Modified: branches/transforms/lib/matplotlib/axis.py
===================================================================
--- branches/transforms/lib/matplotlib/axis.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/axis.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -1070,7 +1070,7 @@
 bottom = self.axes.bbox.ymin
 else:
 bbox = Bbox.union(bboxes)
- bottom = bbox.ymin
+ bottom = bbox.y0
 self.label.set_position( (x, bottom - self.LABELPAD*self.figure.dpi / 72.0))
 
 else:
@@ -1078,8 +1078,7 @@
 top = self.axes.bbox.ymax
 else:
 bbox = bbox_union(bboxes2)
- top = bbox.ymax
- 
+ top = bbox.y1
 self.label.set_position( (x, top+self.LABELPAD*self.figure.dpi / 72.0))
 
 def _update_offset_text_position(self, bboxes, bboxes2):
@@ -1092,7 +1091,7 @@
 bottom = self.axes.bbox.ymin
 else:
 bbox = Bbox.union(bboxes)
- bottom = bbox.ymin
+ bottom = bbox.y0
 self.offsetText.set_position((x, bottom-self.OFFSETTEXTPAD*self.figure.dpi/72.0))
 	
 def set_ticks_position(self, position):
@@ -1280,9 +1279,8 @@
 if not len(bboxes):
 left = self.axes.bbox.xmin
 else:
-
 bbox = Bbox.union(bboxes)
- left = bbox.xmin
+ left = bbox.x0
 
 self.label.set_position( (left-self.LABELPAD*self.figure.dpi/72.0, y))
 	 
@@ -1291,7 +1289,7 @@
 right = self.axes.bbox.xmax
 else:
 bbox = Bbox.union(bboxes2)
- right = bbox.xmax
+ right = bbox.x1
 
 self.label.set_position( (right+self.LABELPAD*self.figure.dpi/72.0, y))
 
Modified: branches/transforms/lib/matplotlib/backend_bases.py
===================================================================
--- branches/transforms/lib/matplotlib/backend_bases.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/backend_bases.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -1422,7 +1422,7 @@
 self.draw()
 return
 
- xmin, ymin, xmax, ymax = lim.lbrt
+ x0, y0, x1, y1 = lim.extents
 
 # zoom to rect
 	 inverse = a.transData.inverted()
@@ -1432,49 +1432,49 @@
 Ymin,Ymax=a.get_ylim()
 
 if Xmin < Xmax:
- if x<lastx: xmin, xmax = x, lastx
- else: xmin, xmax = lastx, x
- if xmin < Xmin: xmin=Xmin
- if xmax > Xmax: xmax=Xmax
+ if x<lastx: x0, x1 = x, lastx
+ else: x0, x1 = lastx, x
+ if x0 < Xmin: x0=Xmin
+ if x1 > Xmax: x1=Xmax
 else:
- if x>lastx: xmin, xmax = x, lastx
- else: xmin, xmax = lastx, x
- if xmin > Xmin: xmin=Xmin
- if xmax < Xmax: xmax=Xmax
+ if x>lastx: x0, x1 = x, lastx
+ else: x0, x1 = lastx, x
+ if x0 > Xmin: x0=Xmin
+ if x1 < Xmax: x1=Xmax
 
 if Ymin < Ymax:
- if y<lasty: ymin, ymax = y, lasty
- else: ymin, ymax = lasty, y
- if ymin < Ymin: ymin=Ymin
- if ymax > Ymax: ymax=Ymax
+ if y<lasty: y0, y1 = y, lasty
+ else: y0, y1 = lasty, y
+ if y0 < Ymin: y0=Ymin
+ if y1 > Ymax: y1=Ymax
 else:
- if y>lasty: ymin, ymax = y, lasty
- else: ymin, ymax = lasty, y
- if ymin > Ymin: ymin=Ymin
- if ymax < Ymax: ymax=Ymax
+ if y>lasty: y0, y1 = y, lasty
+ else: y0, y1 = lasty, y
+ if y0 > Ymin: y0=Ymin
+ if y1 < Ymax: y1=Ymax
 
 if self._button_pressed == 1:
- a.set_xlim((xmin, xmax))
- a.set_ylim((ymin, ymax))
+ a.set_xlim((x0, x1))
+ a.set_ylim((y0, y1))
 elif self._button_pressed == 3:
 if a.get_xscale()=='log':
- alpha=npy.log(Xmax/Xmin)/npy.log(xmax/xmin)
- x1=pow(Xmin/xmin,alpha)*Xmin
- x2=pow(Xmax/xmin,alpha)*Xmin
+ alpha=npy.log(Xmax/Xmin)/npy.log(x1/x0)
+ rx1=pow(Xmin/x0,alpha)*Xmin
+ x2=pow(Xmax/x0,alpha)*Xmin
 else:
- alpha=(Xmax-Xmin)/(xmax-xmin)
- x1=alpha*(Xmin-xmin)+Xmin
- x2=alpha*(Xmax-xmin)+Xmin
+ alpha=(Xmax-Xmin)/(x1-x0)
+ rx1=alpha*(Xmin-x0)+Xmin
+ x2=alpha*(Xmax-x0)+Xmin
 if a.get_yscale()=='log':
- alpha=npy.log(Ymax/Ymin)/npy.log(ymax/ymin)
- y1=pow(Ymin/ymin,alpha)*Ymin
- y2=pow(Ymax/ymin,alpha)*Ymin
+ alpha=npy.log(Ymax/Ymin)/npy.log(y1/y0)
+ ry1=pow(Ymin/y0,alpha)*Ymin
+ ry2=pow(Ymax/y0,alpha)*Ymin
 else:
- alpha=(Ymax-Ymin)/(ymax-ymin)
- y1=alpha*(Ymin-ymin)+Ymin
- y2=alpha*(Ymax-ymin)+Ymin
- a.set_xlim((x1, x2))
- a.set_ylim((y1, y2))
+ alpha=(Ymax-Ymin)/(y1-y0)
+ ry1=alpha*(Ymin-y0)+Ymin
+ ry2=alpha*(Ymax-y0)+Ymin
+ a.set_xlim((rx1, rx2))
+ a.set_ylim((ry1, ry2))
 
 self.draw()
 self._xypress = None
Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_agg.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/backends/backend_agg.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -118,7 +118,7 @@
 self.mathtext_parser = MathTextParser('Agg')
 self._fontd = {}
 
- self.bbox = Bbox.from_lbwh(0,0, self.width, self.height)
+ self.bbox = Bbox.from_bounds(0, 0, self.width, self.height)
 if __debug__: verbose.report('RendererAgg.__init__ done',
 'debug-annoying')
 
@@ -227,7 +227,7 @@
 
 cliprect = gc.get_clip_rectangle()
 if cliprect is None: bbox = None
- else: bbox = Bbox.from_lbwh(*cliprect)
+ else: bbox = Bbox.from_bounds(*cliprect)
 self.draw_image(x, self.height-y, im, bbox)
 
 def get_canvas_width_height(self):
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -1032,12 +1032,12 @@
 def writeMarkers(self):
 for tup in self.markers.values():
 name, object, path, trans, fillp, lw = tup
- bbox = Bbox.from_lbrt(*path.get_extents(trans))
+ bbox = Bbox.from_extents(*path.get_extents(trans))
 bbox = bbox.padded(lw * 0.5)
 self.beginStream(
 object.id, None,
 {'Type': Name('XObject'), 'Subtype': Name('Form'),
- 'BBox': list(bbox.lbrt) })
+ 'BBox': list(bbox.extents) })
 self.writePath(path, trans)
 if fillp:
 self.output(Op.fill_stroke)
Modified: branches/transforms/lib/matplotlib/collections.py
===================================================================
--- branches/transforms/lib/matplotlib/collections.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/collections.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -126,12 +126,12 @@
 return self._transforms
 
 def get_datalim(self, transData):
- result = transforms.Bbox.from_lbrt(*path.get_path_collection_extents(
- self.get_transform().frozen(),
- self.get_paths(),
- self.get_transforms(),
- self._offsets,
- self._transOffset.frozen()))
+ result = path.get_path_collection_extents(
+ self.get_transform().frozen(),
+ self.get_paths(),
+ self.get_transforms(),
+ self._offsets,
+ self._transOffset.frozen())
 result = result.transformed(transData.inverted())
 return result
 
Modified: branches/transforms/lib/matplotlib/figure.py
===================================================================
--- branches/transforms/lib/matplotlib/figure.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/figure.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -131,7 +131,7 @@
 
 	self._dpi_scale_trans = Affine2D()
 self.dpi = dpi
-	self.bbox_inches = Bbox.from_lbwh(0, 0, *figsize)
+	self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
 	self.bbox = TransformedBbox(self.bbox_inches, self._dpi_scale_trans)
 	
 self.frameon = frameon
@@ -351,11 +351,11 @@
 
 def get_figwidth(self):
 'Return the figwidth as a float'
-	return self.bbox_inches.xmax
+	return self.bbox_inches.width
 
 def get_figheight(self):
 'Return the figheight as a float'
- return self.bbox_inches.ymax
+ return self.bbox_inches.height
 
 def get_dpi(self):
 'Return the dpi as a float'
@@ -395,7 +395,7 @@
 
 ACCEPTS: float
 """
-	self.bbox_inches.xmax = val
+	self.bbox_inches.x1 = val
 	
 def set_figheight(self, val):
 """
@@ -403,7 +403,7 @@
 
 ACCEPTS: float
 """
-	self.bbox_inches.ymax = val
+	self.bbox_inches.y1 = val
 
 def set_frameon(self, b):
 """
Modified: branches/transforms/lib/matplotlib/image.py
===================================================================
--- branches/transforms/lib/matplotlib/image.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/image.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -156,8 +156,8 @@
 im.apply_translation(-1, -1)
 
 # the viewport translation
- tx = (xmin-self.axes.viewLim.xmin)/dxintv * numcols
- ty = (ymin-self.axes.viewLim.ymin)/dyintv * numrows
+ tx = (xmin-self.axes.viewLim.x0)/dxintv * numcols
+ ty = (ymin-self.axes.viewLim.y0)/dyintv * numrows
 
 l, b, widthDisplay, heightDisplay = self.axes.bbox.bounds
 widthDisplay *= magnification
Modified: branches/transforms/lib/matplotlib/legend.py
===================================================================
--- branches/transforms/lib/matplotlib/legend.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/legend.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -442,7 +442,7 @@
 
 candidates = []
 for l, b in consider:
- legendBox = Bbox.from_lbwh(l, b, width, height)
+ legendBox = Bbox.from_bounds(l, b, width, height)
 badness = 0
 badness = legendBox.count_contains(verts)
 badness += legendBox.count_overlaps(bboxes)
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -673,39 +673,6 @@
 gc.set_linestyle('solid')
 	renderer.draw_path(gc, path, trans)
 
-
- def _step(self, x, y, where):
- if not cbook.iterable(x):
- x = ma.array([x], dtype=npy.float_)
- if not cbook.iterable(y):
- y = ma.array([y], dtype=npy.float_)
-
- if where=='pre':
- x2 = ma.zeros((2*len(x)-1,), npy.float_)
- y2 = ma.zeros((2*len(y)-1,), npy.float_)
-
- x2[0::2], x2[1::2] = x, x[:-1]
- y2[0::2], y2[1:-1:2] = y, y[1:]
-
- elif where=='post':
- x2 = ma.zeros((2*len(x)-1,), npy.float_)
- y2 = ma.zeros((2*len(y)-1,), npy.float_)
-
- x2[::2], x2[1:-1:2] = x, x[1:]
- y2[0::2], y2[1::2] = y, y[:-1]
-
- elif where=='mid':
- x2 = ma.zeros((2*len(x),), npy.float_)
- y2 = ma.zeros((2*len(y),), npy.float_)
-
- x2[1:-1:2] = 0.5*(x[:-1]+x[1:])
- x2[2::2] = 0.5*(x[:-1]+x[1:])
- x2[0], x2[-1] = x[0], x[-1]
-
- y2[0::2], y2[1::2] = y, y
-
- return x2, y2
-
 
 def _draw_steps_pre(self, renderer, gc, path, trans):
 vertices = self._xy
Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/patches.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -346,7 +346,7 @@
 
 left, right = self.convert_xunits((xy[0], xy[0] + width))
 bottom, top = self.convert_yunits((xy[1], xy[1] + height))
-	self._bbox = transforms.Bbox.from_lbrt(left, bottom, right, top)
+	self._bbox = transforms.Bbox.from_extents(left, bottom, right, top)
 	self._rect_transform = transforms.BboxTransform(
 	 transforms.Bbox.unit(), self._bbox)
 __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd
@@ -367,11 +367,11 @@
 
 def get_x(self):
 "Return the left coord of the rectangle"
- return self._bbox.xmin
+ return self._bbox.x0
 
 def get_y(self):
 "Return the bottom coord of the rectangle"
- return self._bbox.ymin
+ return self._bbox.y0
 
 def get_width(self):
 "Return the width of the rectangle"
@@ -405,7 +405,7 @@
 
 ACCEPTS: float
 """
- self._bbox.xmax = self._bbox.xmin + w
+ self._bbox.x1 = self._bbox.x0 + w
 
 def set_height(self, h):
 """
@@ -413,7 +413,7 @@
 
 ACCEPTS: float
 """
- self._bbox.ymax = self._bbox.ymin + h
+ self._bbox.y1 = self._bbox.y0 + h
 
 def set_bounds(self, *args):
 """
Modified: branches/transforms/lib/matplotlib/path.py
===================================================================
--- branches/transforms/lib/matplotlib/path.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/path.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -10,7 +10,8 @@
 from numpy import ma as ma
 
 from matplotlib._path import point_in_path, get_path_extents, \
- get_path_collection_extents, point_in_path_collection
+ point_in_path_collection
+import matplotlib._path as _path
 from matplotlib.cbook import simple_linear_interpolation
 
 KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0
@@ -199,7 +200,7 @@
 from transforms import Affine2D, Bbox
 if transform is None:
 transform = Affine2D()
- return Bbox.from_lbrt(*get_path_extents(self, transform))
+ return Bbox.from_extents(*get_path_extents(self, transform))
 
 def interpolated(self, steps):
 """
@@ -402,3 +403,6 @@
 """
 return cls.arc(theta1, theta2, True)
 wedge = classmethod(wedge)
+
+def get_path_collection_extents(*args):
+ return Bbox.from_extents(*_path.get_path_collection_extents(*args))
Modified: branches/transforms/lib/matplotlib/projections/polar.py
===================================================================
--- branches/transforms/lib/matplotlib/projections/polar.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/projections/polar.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -256,7 +256,7 @@
 return Circle((0.5, 0.5), 0.5)
 
 def set_rmax(self, rmax):
- self.viewLim.ymax = rmax
+ self.viewLim.y1 = rmax
 angle = self._r_label1_position.to_values()[4]
 self._r_label1_position.clear().translate(
 angle, rmax * self._rpad)
Modified: branches/transforms/lib/matplotlib/text.py
===================================================================
--- branches/transforms/lib/matplotlib/text.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/text.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -253,7 +253,7 @@
 xmin -= offsetx
 ymin -= offsety
 
- bbox = Bbox.from_lbwh(xmin, ymin, width, height)
+ bbox = Bbox.from_bounds(xmin, ymin, width, height)
 
 # now rotate the positions around the first x,y position
 xys = M.transform(offsetLayout)
@@ -407,7 +407,7 @@
 if not self.get_visible(): return Bbox.unit()
 if self._text == '':
 tx, ty = self._get_xy_display()
- return Bbox.from_lbwh(tx,ty,0,0)
+ return Bbox.from_bounds(tx,ty,0,0)
 
 if renderer is not None:
 self._renderer = renderer
Modified: branches/transforms/lib/matplotlib/transforms.py
===================================================================
--- branches/transforms/lib/matplotlib/transforms.py	2007年10月24日 18:49:08 UTC (rev 3996)
+++ branches/transforms/lib/matplotlib/transforms.py	2007年10月24日 19:22:00 UTC (rev 3997)
@@ -196,28 +196,46 @@
 def __array__(self, *args, **kwargs):
 return self.get_points()
 
+ def _get_x0(self):
+ return self.get_points()[0, 0]
+ x0 = property(_get_x0)
+ 
+ def _get_y0(self):
+ return self.get_points()[0, 1]
+ y0 = property(_get_y0)
+
+ def _get_x1(self):
+ return self.get_points()[1, 0]
+ x1 = property(_get_x1)
+
+ def _get_y1(self):
+ return self.get_points()[1, 1]
+ y1 = property(_get_y1)
+
 def _get_xmin(self):
- return self.get_points()[0, 0]
+ return min(self.get_points()[:, 0])
 xmin = property(_get_xmin)
- 
+
 def _get_ymin(self):
- return self.get_points()[0, 1]
+ return min(self.get_points()[:, 1])
 ymin = property(_get_ymin)
 
 def _get_xmax(self):
- return self.get_points()[1, 0]
+ return max(self.get_points()[:, 0])
 xmax = property(_get_xmax)
 
 def _get_ymax(self):
- return self.get_points()[1, 1]
+ return max(self.get_points()[:, 1])
 ymax = property(_get_ymax)
-
+ 
 def _get_min(self):
- return self.get_points()[0]
+ return [min(self.get_points()[:, 0]),
+ min(self.get_points()[:, 1])]
 min = property(_get_min)
 
 def _get_max(self):
- return self.get_points()[1]
+ return [max(self.get_points()[:, 0]),
+ max(self.get_points()[:, 1])]
 max = property(_get_max)
 
 def _get_intervalx(self):
@@ -244,35 +262,35 @@
 size = property(_get_size)
 
 def _get_bounds(self):
- ((xmin, ymin), (xmax, ymax)) = self.get_points()
- return (xmin, ymin, xmax - xmin, ymax - ymin)
+ ((x0, y0), (x1, y1)) = self.get_points()
+ return (x0, y0, x1 - x0, y1 - y0)
 bounds = property(_get_bounds)
 
- def _get_lbrt(self):
+ def _get_extents(self):
 return self.get_points().flatten().copy()
- lbrt = property(_get_lbrt)
+ extents = property(_get_extents)
 
 def get_points(self):
 return NotImplementedError()
 
 def containsx(self, x):
- xmin, xmax = self.intervalx
- return ((xmin < xmax
- and (x >= xmin and x <= xmax))
- or (x >= xmax and x <= xmin))
+ x0, x1 = self.intervalx
+ return ((x0 < x1
+ and (x >= x0 and x <= x1))
+ or (x >= x1 and x <= x0))
 
 def containsy(self, y):
- ymin, ymax = self.intervaly
- return ((ymin < ymax
- and (y >= ymin and y <= ymax))
- or (y >= ymax and y <= ymin))
+ y0, y1 = self.intervaly
+ return ((y0 < y1
+ and (y >= y0 and y <= y1))
+ or (y >= y1 and y <= y0))
 
 def contains(self, x, y):
 return self.containsx(x) and self.containsy(y)
 
 def overlaps(self, other):
- ax1, ay1, ax2, ay2 = self._get_lbrt()
- bx1, by1, bx2, by2 = other._get_lbrt()
+ ax1, ay1, ax2, ay2 = self._get_extents()
+ bx1, by1, bx2, by2 = other._get_extents()
 
 if ax2 < ax1:
 ax2, ax1 = ax1, ax2
@@ -289,24 +307,24 @@
 (by1 > ay2))
 
 def fully_containsx(self, x):
- xmin, xmax = self.intervalx
- return ((xmin < xmax
- and (x > xmin and x < xmax))
- or (x > xmax and x < xmin))
+ x0, x1 = self.intervalx
+ return ((x0 < x1
+ and (x > x0 and x < x1))
+ or (x > x1 and x < x0))
 
 def fully_containsy(self, y):
- ymin, ymax = self.intervaly
- return ((ymin < ymax
- and (x > ymin and x < ymax))
- or (x > ymax and x < ymin))
+ y0, y1 = self.intervaly
+ return ((y0 < y1
+ and (x > y0 and x < y1))
+ or (x > y1 and x < y0))
 
 def fully_contains(self, x, y):
 return self.fully_containsx(x) \
 and self.fully_containsy(y)
 
 def fully_overlaps(self, other):
- ax1, ay1, ax2, ay2 = self._get_lbrt()
- bx1, by1, bx2, by2 = other._get_lbrt()
+ ax1, ay1, ax2, ay2 = self._get_extents()
+ bx1, by1, bx2, by2 = other._get_extents()
 
 if ax2 < ax1:
 ax2, ax1 = ax1, ax2
@@ -354,7 +372,7 @@
 or b) a string: C for centered, S for bottom-center, SE for
 bottom-left, E for left, etc.
 
- Optional arg container is the lbwh box within which the BBox
+ Optional arg container is the box within which the BBox
 is positioned; it defaults to the initial BBox.
 """
 if container is None:
@@ -413,10 +431,10 @@
 """
 boxes = []
 xf = [0] + list(args) + [1]
- l, b, r, t = self.lbrt
- w = r - l
+ x0, y0, x1, y1 = self._get_extents()
+ w = x1 - x0
 for xf0, xf1 in zip(xf[:-1], xf[1:]):
- boxes.append(Bbox([[l + xf0 * w, b], [l + xf1 * w, t]]))
+ boxes.append(Bbox([[x0 + xf0 * w, y0], [x0 + xf1 * w, y1]]))
 return boxes
 
 def splity(self, *args):
@@ -429,10 +447,10 @@
 """
 boxes = []
 yf = [0] + list(args) + [1]
- l, b, r, t = self.lbrt
- h = t - b
+ x0, y0, x1, y1 = self._get_extents()
+ h = y1 - y0
 for yf0, yf1 in zip(yf[:-1], yf[1:]):
- boxes.append(Bbox([[l, b + yf0 * h], [r, b + yf1 * h]]))
+ boxes.append(Bbox([[x0, y0 + yf0 * h], [x1, y0 + yf1 * h]]))
 return boxes
 
 def count_contains(self, vertices):
@@ -444,12 +462,12 @@
 if len(vertices) == 0:
 return 0
 vertices = npy.asarray(vertices)
- xmin, ymin, xmax, ymax = self._get_lbrt()
- dxmin = npy.sign(vertices[:, 0] - xmin)
- dymin = npy.sign(vertices[:, 1] - ymin)
- dxmax = npy.sign(vertices[:, 0] - xmax)
- dymax = npy.sign(vertices[:, 1] - ymax)
- inside = (abs(dxmin + dxmax) + abs(dymin + dymax)) <= 2
+ x0, y0, x1, y1 = self._get_extents()
+ dx0 = npy.sign(vertices[:, 0] - x0)
+ dy0 = npy.sign(vertices[:, 1] - y0)
+ dx1 = npy.sign(vertices[:, 0] - x1)
+ dy1 = npy.sign(vertices[:, 1] - y1)
+ inside = (abs(dx0 + dx1) + abs(dy0 + dy1)) <= 2
 return N.sum(inside)
 
 def count_overlaps(self, bboxes):
@@ -458,7 +476,7 @@
 
 bboxes is a sequence of Bbox objects
 """
- ax1, ay1, ax2, ay2 = self._get_lbrt()
+ ax1, ay1, ax2, ay2 = self._get_extents()
 if ax2 < ax1:
 ax2, ax1 = ax1, ax2
 if ay2 < ay1:
@@ -466,7 +484,7 @@
 
 count = 0
 for bbox in bboxes:
- # bx1, by1, bx2, by2 = bbox._get_lbrt() ... inlined...
+ # bx1, by1, bx2, by2 = bbox._get_extents() ... inlined...
 bx1, by1, bx2, by2 = bbox.get_points().flatten()
 if bx2 < bx1:
 bx2, bx1 = bx1, bx2
@@ -534,21 +552,21 @@
 if len(bboxes) == 1:
 return bboxes[0]
 
- xmin = npy.inf
- ymin = npy.inf
- xmax = -npy.inf
- ymax = -npy.inf
+ x0 = npy.inf
+ y0 = npy.inf
+ x1 = -npy.inf
+ y1 = -npy.inf
 
 for bbox in bboxes:
 points = bbox.get_points()
 xs = points[:, 0]
 ys = points[:, 1]
- xmin = min(xmin, npy.min(xs))
- ymin = min(ymin, npy.min(ys))
- xmax = max(xmax, npy.max(xs))
- ymax = max(ymax, npy.max(ys))
+ x0 = min(x0, npy.min(xs))
+ y0 = min(y0, npy.min(ys))
+ x1 = max(x1, npy.max(xs))
+ y1 = max(y1, npy.max(ys))
 
- return Bbox.from_lbrt(xmin, ymin, xmax, ymax)
+ return Bbox.from_extents(x0, y0, x1, y1)
 union = staticmethod(union)
 
 
@@ -557,10 +575,10 @@
 """
 Create a new bounding box.
 
- points: a 2x2 numpy array of the form [[xmin, ymin], [xmax, ymax]]
+ points: a 2x2 numpy array of the form [[x0, y0], [x1, y1]]
 
 If you need to create Bbox from another form of data, consider the
- class methods unit, from_lbwh and from_lbrt.
+ class methods unit, from_bounds and from_extents.
 """
 BboxBase.__init__(self)
 self._points = npy.asarray(points, npy.float_)
@@ -572,19 +590,19 @@
 """
 Create a new unit BBox from (0, 0) to (1, 1).
 """
- return Bbox.from_lbrt(0., 0., 1., 1.)
+ return Bbox.from_extents(0., 0., 1., 1.)
 unit = staticmethod(unit)
 
 #@staticmethod
- def from_lbwh(left, bottom, width, height):
+ def from_bounds(left, bottom, width, height):
 """
 Create a new Bbox from left, bottom, width and height.
 """
- return Bbox.from_lbrt(left, bottom, left + width, bottom + height)
- from_lbwh = staticmethod(from_lbwh)
+ return Bbox.from_extents(left, bottom, left + width, bottom + height)
+ from_bounds = staticmethod(from_bounds)
 
 #@staticmethod
- def from_lbrt(*args):
+ def from_extents(*args):
 """
 Create a new Bbox from left, bottom, right and top.
 
@@ -592,7 +610,7 @@
 """
 points = npy.array(args, dtype=npy.float_).reshape(2, 2)
 return Bbox(points)
- from_lbrt = staticmethod(from_lbrt)
+ from_extents = staticmethod(from_extents)
 
 def __repr__(self):
 return 'Bbox(%s)' % repr(self._points)
@@ -648,11 +666,12 @@
 npy.float_)
 self._minpos = minpos
 else:
+ x0, y0, x1, y1 = self._get_extents()
 	 points = npy.array(
-		[[min(x.min(), self.xmin),
- min(y.min(), self.ymin)],
-		 [max(x.max(), self.xmax),
- max(y.max(), self.ymax)]],
+		[[min(x.min(), x0, x1),
+ min(y.min(), y0, y1)],
+		 [max(x.max(), x0, x1),
+ max(y.max(), y0, y1)]],
 		 npy.float_)
 self._minpos = npy.minimum(minpos, self._minpos)
 
@@ -672,25 +691,25 @@
 """
 return self.update_from_data(xy[:, 0], xy[:, 1], ignore)
 
- def _set_xmin(self, val):
+ def _set_x0(self, val):
 self._points[0, 0] = val
 self.invalidate()
- xmin = property(BboxBase._get_xmin, _set_xmin)
+ x0 = property(BboxBase._get_x0, _set_x0)
 
- def _set_ymin(self, val):
+ def _set_y0(self, val):
 self._points[0, 1] = val
 self.invalidate()
- ymin = property(BboxBase._get_ymin, _set_ymin)
+ y0 = property(BboxBase._get_y0, _set_y0)
 
- def _set_xmax(self, val):
+ def _set_x1(self, val):
 self._points[1, 0] = val
 self.invalidate()
- xmax = property(BboxBase._get_xmax, _set_xmax)
+ x1 = property(BboxBase._get_x1, _set_x1)
 
- def _set_ymax(self, val):
+ def _set_y1(self, val):
 self._points[1, 1] = val
 self.invalidate()
- ymax = property(BboxBase._get_ymax, _set_ymax)
+ y1 = property(BboxBase._get_y1, _set_y1)
 
 def _set_min(self, val):
 self._points[0] = val
@@ -735,7 +754,7 @@
 def get_points(self):
 """
 Set the points of the bounding box directly as a numpy array
- of the form: [[xmin, ymin], [xmax, ymax]].
+ of the form: [[x0, y0], [x1, y1]].
 """
 self._invalid = 0
 return self._points
@@ -743,7 +762,7 @@
 def set_points(self, points):
 """
 Set the points of the bounding box directly from a numpy array
- of the form: [[xmin, ymin], [xmax, ymax]]. No error checking
+ of the form: [[x0, y0], [x1, y1]]. No error checking
 is performed, as this method is mainly for internal use.
 """
 if npy.any(self._points != points):
@@ -2137,11 +2156,11 @@
 from random import random
 import timeit
 
- bbox = Bbox.from_lbrt(10., 15., 20., 25.)
- assert bbox.xmin == 10
- assert bbox.ymin == 15
- assert bbox.xmax == 20
- assert bbox.ymax == 25
+ bbox = Bbox.from_extents(10., 15., 20., 25.)
+ assert bbox.x0 == 10
+ assert bbox.y0 == 15
+ assert bbox.x1 == 20
+ assert bbox.y1 == 25
 
 assert npy.all(bbox.min == [10, 15])
 assert npy.all(bbox.max == [20, 25])
@@ -2160,18 +2179,18 @@
 
 assert bbox.bounds == (11, 16, 10, 10)
 
- bbox.xmin = 12
- bbox.ymin = 17
- bbox.xmax = 22
- bbox.ymax = 27
+ bbox.x0 = 12
+ bbox.y0 = 17
+ bbox.x1 = 22
+ bbox.y1 = 27
 
 assert bbox.bounds == (12, 17, 10, 10)
 
- bbox = Bbox.from_lbwh(10, 11, 12, 13)
+ bbox = Bbox.from_bounds(10, 11, 12, 13)
 assert bbox.bounds == (10, 11, 12, 13)
 
 bbox_copy = copy.deepcopy(bbox)
- assert (bbox.lbrt == bbox_copy.lbrt).all()
+ assert (bbox.extents == bbox_copy.extents).all()
 bbox_copy.max = (14, 15)
 assert bbox.bounds == (10, 11, 12, 13)
 assert bbox_copy.bounds == (10, 11, 4, 4)
@@ -2180,7 +2199,7 @@
 bbox2 = Bbox([[30., 35.], [40., 45.]])
 trans = BboxTransform(bbox1, bbox2)
 bbox3 = bbox1.transformed(trans)
- assert (bbox3.lbrt == bbox2.lbrt).all()
+ assert (bbox3.extents == bbox2.extents).all()
 
 translation = Affine2D().translate(10, 20)
 assert translation.to_values() == (1, 0, 0, 1, 10, 20)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 18:49:11
Revision: 3996
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3996&view=rev
Author: mdboom
Date: 2007年10月24日 11:49:08 -0700 (2007年10月24日)
Log Message:
-----------
Initial pass of Gtk, Qt, Qt4, Fltk and Wx GUI backends. Lots more
examples passing.
Modified Paths:
--------------
 branches/transforms/PASSED_DEMOS
 branches/transforms/examples/dynamic_demo_wx.py
 branches/transforms/examples/embedding_in_gtk.py
 branches/transforms/examples/embedding_in_gtk2.py
 branches/transforms/examples/embedding_in_gtk3.py
 branches/transforms/examples/embedding_in_tk.py
 branches/transforms/examples/embedding_in_tk2.py
 branches/transforms/examples/embedding_in_wx.py
 branches/transforms/lib/matplotlib/axes.py
 branches/transforms/lib/matplotlib/backends/backend_fltkagg.py
 branches/transforms/lib/matplotlib/backends/backend_gdk.py
 branches/transforms/lib/matplotlib/backends/backend_gtk.py
 branches/transforms/lib/matplotlib/backends/backend_qt.py
 branches/transforms/lib/matplotlib/backends/backend_qt4.py
 branches/transforms/lib/matplotlib/backends/backend_qt4agg.py
 branches/transforms/lib/matplotlib/backends/backend_qtagg.py
 branches/transforms/lib/matplotlib/backends/backend_wx.py
 branches/transforms/lib/matplotlib/backends/backend_wxagg.py
 branches/transforms/lib/matplotlib/backends/tkagg.py
 branches/transforms/lib/matplotlib/lines.py
 branches/transforms/setupext.py
 branches/transforms/src/_backend_agg.h
 branches/transforms/src/_gtkagg.cpp
 branches/transforms/src/_tkagg.cpp
Modified: branches/transforms/PASSED_DEMOS
===================================================================
--- branches/transforms/PASSED_DEMOS	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/PASSED_DEMOS	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -2,14 +2,14 @@
 agg_buffer_to_array.py O
 agg_oo.py O
 agg_resize.py [BROKEN IN TRUNK]
-agg_test.py
+agg_test.py		???
 alignment_test.py O
-animation_blit_fltk.py
-animation_blit.py
-animation_blit_qt4.py
-animation_blit_qt.py
-animation_blit_tk.py
-animation_blit_wx.py
+animation_blit_fltk.py [terminate called after throwing an instance of 'Swig::DirectorMethodException']
+animation_blit.py	O
+animation_blit_qt4.py	O
+animation_blit_qt.py	O
+animation_blit_tk.py	O
+animation_blit_wx.py	O
 anim.py O [BUT SLOWER]
 annotation_demo.py O
 anscombe.py		O
@@ -56,24 +56,24 @@
 date_demo_rrule.py	O
 date_index_formatter.py O
 dynamic_collection.py O
-dynamic_demo.py		[GTK]
-dynamic_demo_wx.py	[WX]
-dynamic_image_gtkagg.py
-dynamic_image_wxagg2.py
-dynamic_image_wxagg.py
+dynamic_demo.py		O
+dynamic_demo_wx.py	[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
+dynamic_image_gtkagg.py O
+dynamic_image_wxagg2.py O
+dynamic_image_wxagg.py	
 ellipse_demo.py		O
 ellipse_rotated.py	O
-embedding_in_gtk2.py
-embedding_in_gtk3.py
-embedding_in_gtk.py
-embedding_in_qt4.py
-embedding_in_qt.py
-embedding_in_tk2.py
-embedding_in_tk.py
-embedding_in_wx2.py
-embedding_in_wx3.py
-embedding_in_wx4.py
-embedding_in_wx.py
+embedding_in_gtk2.py	[REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED]
+embedding_in_gtk3.py	O
+embedding_in_gtk.py	[REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED]
+embedding_in_qt4.py	O
+embedding_in_qt.py	O
+embedding_in_tk2.py	O
+embedding_in_tk.py	O
+embedding_in_wx2.py	[IDENTICAL BUG IN TRUNK -- Y-AXIS VALUES ARE TRUNCATED]
+embedding_in_wx3.py	O
+embedding_in_wx4.py	O
+embedding_in_wx.py	[REQUIRES NON-AGG WX RENDERER, WHICH IS NOT YET IMPLEMENTED]
 errorbar_demo.py	O
 errorbar_limits.py	O	
 figimage_demo.py	O
@@ -91,20 +91,20 @@
 font_table_ttf.py	[N/A]
 ftface_props.py		[N/A]
 ganged_plots.py		O
-glyph_to_path.py	[Requires PIL]
+glyph_to_path.py	O
 gradient_bar.py		O
-gtk_spreadsheet.py		
+gtk_spreadsheet.py	[REQUIRES NON-AGG GDK RENDERER, WHICH IS NOT YET IMPLEMENTED]	
 hatch_demo.py		O
 histogram_demo_canvasagg.py [???]
 histogram_demo.py	O
 image_demo2.py		O
-image_demo3.py		[Requires PIL]
+image_demo3.py		O
 image_demo.py		O
 image_interp.py		O
 image_masked.py		O [Whew!]
 image_origin.py		O
 image_slices_viewer.py [BROKEN ON TRUNK]
-__init__.py
+__init__.py		[N/A]
 integral_demo.py	O
 interactive2.py		[N/A]
 interactive.py		[N/A]
@@ -119,7 +119,7 @@
 legend_scatter.py	O
 line_collection2.py	O
 line_collection.py	O
-lineprops_dialog_gtk.py
+lineprops_dialog_gtk.py	O
 line_styles.py		O
 load_converter.py	O
 loadrec.py		O
@@ -132,7 +132,7 @@
 masked_demo.py		O
 mathtext_demo.py	O
 mathtext_examples.py	O
-mathtext_wx.py
+mathtext_wx.py		O
 matplotlib_icon.py	[N/A]
 matshow.py		O
 movie_demo.py		O
Modified: branches/transforms/examples/dynamic_demo_wx.py
===================================================================
--- branches/transforms/examples/dynamic_demo_wx.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/dynamic_demo_wx.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -62,7 +62,6 @@
 FigureManager, NavigationToolbar2Wx
 
 from matplotlib.figure import Figure
-from matplotlib.axes import Subplot
 import numpy
 from wx import *
 
Modified: branches/transforms/examples/embedding_in_gtk.py
===================================================================
--- branches/transforms/examples/embedding_in_gtk.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_gtk.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -6,7 +6,6 @@
 
 import gtk
 
-from matplotlib.axes import Subplot
 from matplotlib.figure import Figure
 from numpy import arange, sin, pi
 
Modified: branches/transforms/examples/embedding_in_gtk2.py
===================================================================
--- branches/transforms/examples/embedding_in_gtk2.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_gtk2.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -5,7 +5,6 @@
 """
 import gtk
 
-from matplotlib.axes import Subplot
 from matplotlib.figure import Figure
 from numpy import arange, sin, pi
 
Modified: branches/transforms/examples/embedding_in_gtk3.py
===================================================================
--- branches/transforms/examples/embedding_in_gtk3.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_gtk3.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -5,7 +5,6 @@
 
 import gtk
 
-from matplotlib.axes import Subplot
 from matplotlib.figure import Figure
 from numpy import arange, sin, pi
 
Modified: branches/transforms/examples/embedding_in_tk.py
===================================================================
--- branches/transforms/examples/embedding_in_tk.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_tk.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -3,7 +3,6 @@
 matplotlib.use('TkAgg')
 
 from numpy import arange, sin, pi
-from matplotlib.axes import Subplot
 from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
 from matplotlib.figure import Figure
 
Modified: branches/transforms/examples/embedding_in_tk2.py
===================================================================
--- branches/transforms/examples/embedding_in_tk2.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_tk2.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -3,7 +3,6 @@
 matplotlib.use('TkAgg')
 
 from numpy import arange, sin, pi
-from matplotlib.axes import Subplot
 from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
 from matplotlib.figure import Figure
 
Modified: branches/transforms/examples/embedding_in_wx.py
===================================================================
--- branches/transforms/examples/embedding_in_wx.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/examples/embedding_in_wx.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -43,7 +43,6 @@
 FigureManager
 
 from matplotlib.figure import Figure
-from matplotlib.axes import Subplot
 import numpy
 from wx import *
 
Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/axes.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -1538,7 +1538,8 @@
 		if other is not self:
 		 other.set_xlim(self.viewLim.intervalx, emit=False)
 
- self.figure.canvas.draw_idle()
+ if self.figure.canvas is not None:
+ self.figure.canvas.draw_idle()
 
 return xmin, xmax
 
@@ -1697,7 +1698,8 @@
 		if other is not self:
 		 other.set_ylim(self.viewLim.ymin, self.viewLim.ymax, emit=False)
 
- self.figure.canvas.draw_idle()
+ if self.figure.canvas is not None:
+ self.figure.canvas.draw_idle()
 return ymin, ymax
 
 def get_yscale(self):
@@ -3036,39 +3038,13 @@
 '''
 
 where = kwargs.pop('where', 'pre')
+ if where not in ('pre', 'post', 'mid'):
+ raise ValueError("'where' argument to step must be 'pre', 'post' or 'mid'")
+ kwargs['linestyle'] = 'steps-' + where
+ 
+ return self.plot(x, y, *args, **kwargs)
 
- if not cbook.iterable(x):
- x = ma.array([x], dtype=npy.float_)
- if not cbook.iterable(y):
- y = ma.array([y], dtype=npy.float_)
 
- if where=='pre':
- x2 = ma.zeros((2*len(x)-1,), npy.float_)
- y2 = ma.zeros((2*len(y)-1,), npy.float_)
-
- x2[0::2], x2[1::2] = x, x[:-1]
- y2[0::2], y2[1:-1:2] = y, y[1:]
-
- elif where=='post':
- x2 = ma.zeros((2*len(x)-1,), npy.float_)
- y2 = ma.zeros((2*len(y)-1,), npy.float_)
-
- x2[::2], x2[1:-1:2] = x, x[1:]
- y2[0::2], y2[1::2] = y, y[:-1]
-
- elif where=='mid':
- x2 = ma.zeros((2*len(x),), npy.float_)
- y2 = ma.zeros((2*len(y),), npy.float_)
-
- x2[1:-1:2] = 0.5*(x[:-1]+x[1:])
- x2[2::2] = 0.5*(x[:-1]+x[1:])
- x2[0], x2[-1] = x[0], x[-1]
-
- y2[0::2], y2[1::2] = y, y
-
- return self.plot(x2, y2, *args, **kwargs)
-
-
 def bar(self, left, height, width=0.8, bottom=None,
 color=None, edgecolor=None, linewidth=None,
 yerr=None, xerr=None, ecolor=None, capsize=3,
Modified: branches/transforms/lib/matplotlib/backends/backend_fltkagg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_fltkagg.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_fltkagg.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -140,16 +140,16 @@
 self._oldsize =newsize
 self._source.resize(newsize)
 self._source.draw()
- t1,t2,w,h = self._source.figure.bbox.get_bounds()
+ t1,t2,w,h = self._source.figure.bbox.bounds
 Fltk.fl_draw_image(self._source.buffer_rgba(0,0),0,0,int(w),int(h),4,0)
 self.redraw()
 
 def blit(self,bbox=None):
 if bbox is None:
- t1,t2,w,h = self._source.figure.bbox.get_bounds()
+ t1,t2,w,h = self._source.figure.bbox.bounds
 else:
- t1o,t2o,wo,ho = self._source.figure.bbox.get_bounds()
- t1,t2,w,h = bbox.get_bounds()
+ t1o,t2o,wo,ho = self._source.figure.bbox.bounds
+ t1,t2,w,h = bbox.bounds
 x,y=int(t1),int(t2)
 Fltk.fl_draw_image(self._source.buffer_rgba(x,y),x,y,int(w),int(h),4,int(wo)*4)
 #self.redraw()
@@ -222,7 +222,7 @@
 class FigureCanvasFltkAgg(FigureCanvasAgg):
 def __init__(self, figure):
 FigureCanvasAgg.__init__(self,figure)
- t1,t2,w,h = self.figure.bbox.get_bounds()
+ t1,t2,w,h = self.figure.bbox.bounds
 w, h = int(w), int(h)
 self.canvas=FltkCanvas(0, 0, w, h, "canvas",self)
 #self.draw()
@@ -263,7 +263,7 @@
 def __init__(self, canvas, num, window):
 FigureManagerBase.__init__(self, canvas, num)
 #Fltk container window
- t1,t2,w,h = canvas.figure.bbox.get_bounds()
+ t1,t2,w,h = canvas.figure.bbox.bounds
 w, h = int(w), int(h)
 self.window = window
 self.window.size(w,h+30)
@@ -405,7 +405,7 @@
 Fltk.Fl_File_Icon.load_system_icons()
 self._fc = Fltk.Fl_File_Chooser( ".", "*", Fltk.Fl_File_Chooser.CREATE, "Save Figure" )
 self._fc.hide()
- t1,t2,w,h = canvas.figure.bbox.get_bounds()
+ t1,t2,w,h = canvas.figure.bbox.bounds
 w, h = int(w), int(h)
 self._group = Fltk.Fl_Pack(0,h+2,1000,26)
 self._group.type(Fltk.FL_HORIZONTAL)
@@ -591,7 +591,7 @@
 Fltk.Fl_File_Icon.load_system_icons()
 self._fc = Fltk.Fl_File_Chooser( ".", "*", Fltk.Fl_File_Chooser.CREATE, "Save Figure" )
 self._fc.hide()
- t1,t2,w,h = self.canvas.figure.bbox.get_bounds()
+ t1,t2,w,h = self.canvas.figure.bbox.bounds
 w, h = int(w), int(h)
 self._group = Fltk.Fl_Pack(0,h+2,1000,26)
 self._group.type(Fltk.FL_HORIZONTAL)
Modified: branches/transforms/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_gdk.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_gdk.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -353,7 +353,7 @@
 
 
 def points_to_pixels(self, points):
- return points/72.0 * self.dpi.get()
+ return points/72.0 * self.dpi
 
 
 class GraphicsContextGDK(GraphicsContextBase):
Modified: branches/transforms/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_gtk.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_gtk.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -249,7 +249,7 @@
 return # empty fig
 
 # resize the figure (in inches)
- dpi = self.figure.dpi.get()
+ dpi = self.figure.dpi
 self.figure.set_size_inches (w/dpi, h/dpi)
 self._need_redraw = True
 
Modified: branches/transforms/lib/matplotlib/backends/backend_qt.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_qt.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_qt.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -110,14 +110,14 @@
 def mouseMoveEvent( self, event ):
 x = event.x()
 # flipy so y=0 is bottom of canvas
- y = self.figure.bbox.height() - event.y()
+ y = self.figure.bbox.height - event.y()
 FigureCanvasBase.motion_notify_event( self, x, y )
 if DEBUG: print 'mouse move'
 
 def mouseReleaseEvent( self, event ):
 x = event.x()
 # flipy so y=0 is bottom of canvas
- y = self.figure.bbox.height() - event.y()
+ y = self.figure.bbox.height - event.y()
 button = self.buttond[event.button()]
 FigureCanvasBase.button_release_event( self, x, y, button )
 if DEBUG: print 'button released'
@@ -139,7 +139,7 @@
 w = event.size().width()
 h = event.size().height()
 if DEBUG: print "FigureCanvasQt.resizeEvent(", w, ",", h, ")"
- dpival = self.figure.dpi.get()
+ dpival = self.figure.dpi
 winch = w/dpival
 hinch = h/dpival
 self.figure.set_size_inches( winch, hinch )
@@ -150,7 +150,7 @@
 qt.QWidget.resize( self, w, h )
 
 # Resize the figure by converting pixels to inches.
- pixelPerInch = self.figure.dpi.get()
+ pixelPerInch = self.figure.dpi
 wInch = w / pixelPerInch
 hInch = h / pixelPerInch
 self.figure.set_size_inches( wInch, hInch )
@@ -367,7 +367,7 @@
 qt.QApplication.setOverrideCursor( qt.QCursor( cursord[cursor] ) )
 
 def draw_rubberband( self, event, x0, y0, x1, y1 ):
- height = self.canvas.figure.bbox.height()
+ height = self.canvas.figure.bbox.height
 y1 = height - y1
 y0 = height - y0
 
@@ -384,8 +384,8 @@
 
 toolfig = Figure(figsize=(6,3))
 toolfig.subplots_adjust(top=0.9)
- w = int (toolfig.bbox.width())
- h = int (toolfig.bbox.height())
+ w = int (toolfig.bbox.width)
+ h = int (toolfig.bbox.height)
 
 canvas = self._get_canvas(toolfig)
 tool = SubplotTool(self.canvas.figure, toolfig)
Modified: branches/transforms/lib/matplotlib/backends/backend_qt4.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_qt4.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_qt4.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -101,7 +101,7 @@
 def mousePressEvent( self, event ):
 x = event.pos().x()
 # flipy so y=0 is bottom of canvas
- y = self.figure.bbox.height() - event.pos().y()
+ y = self.figure.bbox.height - event.pos().y()
 button = self.buttond[event.button()]
 FigureCanvasBase.button_press_event( self, x, y, button )
 if DEBUG: print 'button pressed:', event.button()
@@ -109,14 +109,14 @@
 def mouseMoveEvent( self, event ):
 x = event.x()
 # flipy so y=0 is bottom of canvas
- y = self.figure.bbox.height() - event.y()
+ y = self.figure.bbox.height - event.y()
 FigureCanvasBase.motion_notify_event( self, x, y )
 #if DEBUG: print 'mouse move'
 
 def mouseReleaseEvent( self, event ):
 x = event.x()
 # flipy so y=0 is bottom of canvas
- y = self.figure.bbox.height() - event.y()
+ y = self.figure.bbox.height - event.y()
 button = self.buttond[event.button()]
 FigureCanvasBase.button_release_event( self, x, y, button )
 if DEBUG: print 'button released'
@@ -138,7 +138,7 @@
 w = event.size().width()
 h = event.size().height()
 if DEBUG: print "FigureCanvasQtAgg.resizeEvent(", w, ",", h, ")"
- dpival = self.figure.dpi.get()
+ dpival = self.figure.dpi
 winch = w/dpival
 hinch = h/dpival
 self.figure.set_size_inches( winch, hinch )
@@ -149,7 +149,7 @@
 QtGui.QWidget.resize( self, w, h )
 
 # Resize the figure by converting pixels to inches.
- pixelPerInch = self.figure.dpi.get()
+ pixelPerInch = self.figure.dpi
 wInch = w / pixelPerInch
 hInch = h / pixelPerInch
 self.figure.set_size_inches( wInch, hInch )
Modified: branches/transforms/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_qt4agg.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_qt4agg.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -112,8 +112,8 @@
 # we are blitting here
 else:
 bbox = self.replot
- w, h = int(bbox.width()), int(bbox.height())
- l, t = bbox.ll().x().get(), bbox.ur().y().get()
+ l, b, w, h = bbox.bounds
+ t = b + h
 reg = self.copy_from_bbox(bbox)
 stringBuffer = reg.to_string()
 qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32)
@@ -140,8 +140,8 @@
 """
 
 self.replot = bbox
- w, h = int(bbox.width()), int(bbox.height())
- l, t = bbox.ll().x().get(), bbox.ur().y().get()
+ l, b, w, h = bbox.bounds
+ t = b + h
 self.update(l, self.renderer.height-t, w, h)
 
 def print_figure(self, *args, **kwargs):
Modified: branches/transforms/lib/matplotlib/backends/backend_qtagg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_qtagg.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_qtagg.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -115,8 +115,8 @@
 # we are blitting here
 else:
 bbox = self.replot
- w, h = int(bbox.width()), int(bbox.height())
- l, t = bbox.ll().x().get(), bbox.ur().y().get()
+ l, b, w, h = bbox.bounds
+ t = b + h
 reg = self.copy_from_bbox(bbox)
 stringBuffer = reg.to_string()
 qImage = qt.QImage(stringBuffer, w, h, 32, None, 0, qt.QImage.IgnoreEndian)
Modified: branches/transforms/lib/matplotlib/backends/backend_wx.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_wx.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_wx.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -459,7 +459,7 @@
 convert point measures to pixes using dpi and the pixels per
 inch of the display
 """
- return points*(PIXELS_PER_INCH/72.0*self.dpi.get()/72.0)
+ return points*(PIXELS_PER_INCH/72.0*self.dpi/72.0)
 
 class GraphicsContextWx(GraphicsContextBase, wx.MemoryDC):
 """
@@ -735,7 +735,7 @@
 FigureCanvasBase.__init__(self, figure)
 # Set preferred window size hint - helps the sizer (if one is
 # connected)
- l,b,w,h = figure.bbox.get_bounds()
+ l,b,w,h = figure.bbox.bounds
 w = int(math.ceil(w))
 h = int(math.ceil(h))
 
@@ -981,6 +981,7 @@
 drawDC.BeginDrawing()
 drawDC.DrawBitmap(self.bitmap, 0, 0)
 drawDC.EndDrawing()
+ wx.GetApp().Yield()
 
 filetypes = FigureCanvasBase.filetypes.copy()
 filetypes['bmp'] = 'Windows bitmap'
@@ -1092,7 +1093,7 @@
 if not self._isConfigured:
 self._isConfigured = True
 
- dpival = self.figure.dpi.get()
+ dpival = self.figure.dpi
 winch = self._width/dpival
 hinch = self._height/dpival
 self.figure.set_size_inches(winch, hinch)
@@ -1132,7 +1133,7 @@
 def _onRightButtonDown(self, evt):
 """Start measuring on an axis."""
 x = evt.GetX()
- y = self.figure.bbox.height() - evt.GetY()
+ y = self.figure.bbox.height - evt.GetY()
 evt.Skip()
 self.CaptureMouse()
 FigureCanvasBase.button_press_event(self, x, y, 3, guiEvent=evt)
@@ -1141,7 +1142,7 @@
 def _onRightButtonUp(self, evt):
 """End measuring on an axis."""
 x = evt.GetX()
- y = self.figure.bbox.height() - evt.GetY()
+ y = self.figure.bbox.height - evt.GetY()
 evt.Skip()
 if self.HasCapture(): self.ReleaseMouse()
 FigureCanvasBase.button_release_event(self, x, y, 3, guiEvent=evt)
@@ -1149,7 +1150,7 @@
 def _onLeftButtonDown(self, evt):
 """Start measuring on an axis."""
 x = evt.GetX()
- y = self.figure.bbox.height() - evt.GetY()
+ y = self.figure.bbox.height - evt.GetY()
 evt.Skip()
 self.CaptureMouse()
 FigureCanvasBase.button_press_event(self, x, y, 1, guiEvent=evt)
@@ -1157,7 +1158,7 @@
 def _onLeftButtonUp(self, evt):
 """End measuring on an axis."""
 x = evt.GetX()
- y = self.figure.bbox.height() - evt.GetY()
+ y = self.figure.bbox.height - evt.GetY()
 #print 'release button', 1
 evt.Skip()
 if self.HasCapture(): self.ReleaseMouse()
@@ -1171,7 +1172,7 @@
 """Start measuring on an axis."""
 
 x = evt.GetX()
- y = self.figure.bbox.height() - evt.GetY()
+ y = self.figure.bbox.height - evt.GetY()
 evt.Skip()
 FigureCanvasBase.motion_notify_event(self, x, y, guiEvent=evt)
 
@@ -1274,7 +1275,7 @@
 pos = wx.DefaultPosition
 else:
 pos =wx.Point(20,20)
- l,b,w,h = fig.bbox.get_bounds()
+ l,b,w,h = fig.bbox.bounds
 wx.Frame.__init__(self, parent=None, id=-1, pos=pos,
 title="Figure %d" % num,
 size=(w,h))
@@ -1730,7 +1731,7 @@
 
 dc.ResetBoundingBox()
 dc.BeginDrawing()
- height = self.canvas.figure.bbox.height()
+ height = self.canvas.figure.bbox.height
 y1 = height - y1
 y0 = height - y0
 
@@ -2036,7 +2037,7 @@
 # so that we can temporarily set them to the dpi of
 # the printer, and the bg color to white
 bgcolor = self.canvas.figure.get_facecolor()
- fig_dpi = self.canvas.figure.dpi.get()
+ fig_dpi = self.canvas.figure.dpi
 
 # draw the bitmap, scaled appropriately
 vscale = float(ppw) / fig_dpi
Modified: branches/transforms/lib/matplotlib/backends/backend_wxagg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_wxagg.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/backend_wxagg.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -19,7 +19,6 @@
 import wx
 import matplotlib
 from matplotlib.figure import Figure
-from matplotlib.transforms import Bbox, Point, Value
 
 from backend_agg import FigureCanvasAgg
 import backend_wx
@@ -74,7 +73,7 @@
 self.gui_repaint()
 return
 
- l, b, w, h = bbox.get_bounds()
+ l, b, w, h = bbox.bounds
 r = l + w
 t = b + h
 x = int(l)
Modified: branches/transforms/lib/matplotlib/backends/tkagg.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/tkagg.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/backends/tkagg.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -4,15 +4,19 @@
 def blit(photoimage, aggimage, bbox=None, colormode=1):
 tk = photoimage.tk
 
+ if bbox is not None:
+ bbox_array = bbox.__array__()
+ else:
+ bbox_array = None
 try:
- tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox))
+ tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
 except Tk.TclError, v:
 try:
 try:
 _tkagg.tkinit(tk.interpaddr(), 1)
 except AttributeError:
 _tkagg.tkinit(id(tk), 0)
- tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox))
+ tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
 except (ImportError, AttributeError, Tk.TclError):
 raise
 
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -113,14 +113,17 @@
 
 class Line2D(Artist):
 lineStyles = _lineStyles = { # hidden names deprecated
- '-' : '_draw_solid',
- '--' : '_draw_dashed',
- '-.' : '_draw_dash_dot',
- ':' : '_draw_dotted',
- 'steps': '_draw_steps',
- 'None' : '_draw_nothing',
- ' ' : '_draw_nothing',
- '' : '_draw_nothing',
+ '-' : '_draw_solid',
+ '--' : '_draw_dashed',
+ '-.' : '_draw_dash_dot',
+ ':' : '_draw_dotted',
+ 'steps' : '_draw_steps_pre',
+ 'steps-mid' : '_draw_steps_mid',
+ 'steps-pre' : '_draw_steps_pre',
+ 'steps-post' : '_draw_steps_post',
+ 'None' : '_draw_nothing',
+ ' ' : '_draw_nothing',
+ '' : '_draw_nothing',
 }
 
 markers = _markers = { # hidden names deprecated
@@ -208,7 +211,7 @@
 data: (npy.array xdata, npy.array ydata)
 figure: a matplotlib.figure.Figure instance
 label: any string
- linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ]
+ linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
 linewidth or lw: float value in points
 lod: [True | False]
 marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4'
@@ -566,7 +569,10 @@
 """
 Set the linestyle of the line
 
- ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' | ' ' | '' ]
+ 'steps' is equivalent to 'steps-pre' and is maintained for
+ backward-compatibility.
+ 
+ ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ]
 """
 if linestyle not in self._lineStyles:
 verbose.report('Unrecognized line style %s, %s' %
@@ -668,11 +674,75 @@
 	renderer.draw_path(gc, path, trans)
 
 
- def _draw_steps(self, renderer, gc, path, trans):
- # MGDTODO: Implement me
- raise NotImplementedError("'steps' linestyle should be returning soon...")
+ def _step(self, x, y, where):
+ if not cbook.iterable(x):
+ x = ma.array([x], dtype=npy.float_)
+ if not cbook.iterable(y):
+ y = ma.array([y], dtype=npy.float_)
+
+ if where=='pre':
+ x2 = ma.zeros((2*len(x)-1,), npy.float_)
+ y2 = ma.zeros((2*len(y)-1,), npy.float_)
+
+ x2[0::2], x2[1::2] = x, x[:-1]
+ y2[0::2], y2[1:-1:2] = y, y[1:]
+
+ elif where=='post':
+ x2 = ma.zeros((2*len(x)-1,), npy.float_)
+ y2 = ma.zeros((2*len(y)-1,), npy.float_)
+
+ x2[::2], x2[1:-1:2] = x, x[1:]
+ y2[0::2], y2[1::2] = y, y[:-1]
+
+ elif where=='mid':
+ x2 = ma.zeros((2*len(x),), npy.float_)
+ y2 = ma.zeros((2*len(y),), npy.float_)
+
+ x2[1:-1:2] = 0.5*(x[:-1]+x[1:])
+ x2[2::2] = 0.5*(x[:-1]+x[1:])
+ x2[0], x2[-1] = x[0], x[-1]
+
+ y2[0::2], y2[1::2] = y, y
+
+ return x2, y2
+
+ 
+ def _draw_steps_pre(self, renderer, gc, path, trans):
+ vertices = self._xy
+ steps = ma.zeros((2*len(vertices)-1, 2), npy.float_)
+
+ steps[0::2, 0], steps[1::2, 0] = vertices[:, 0], vertices[:-1, 0]
+ steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1]
+
+ path = Path(steps, closed=False)
+ self._draw_solid(renderer, gc, path, trans)
+
+
+ def _draw_steps_post(self, renderer, gc, path, trans):
+ vertices = self._xy
+ steps = ma.zeros((2*len(vertices)-1, 2), npy.float_)
+
+ steps[::2, 0], steps[1:-1:2, 0] = vertices[:, 0], vertices[1:, 0]
+ steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1]
+
+ path = Path(steps, closed=False)
+ self._draw_solid(renderer, gc, path, trans)
+
 
+ def _draw_steps_mid(self, renderer, gc, path, trans):
+ vertices = self._xy
+ steps = ma.zeros((2*len(vertices), 2), npy.float_)
 
+ steps[1:-1:2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0])
+ steps[2::2, 0] = 0.5 * (vertices[:-1, 0] + vertices[1:, 0])
+ steps[0, 0] = vertices[0, 0]
+ steps[-1, 0] = vertices[-1, 0]
+ steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1]
+
+ path = Path(steps, closed=False)
+ self._draw_solid(renderer, gc, path, trans)
+ 
+
 def _draw_dashed(self, renderer, gc, path, trans):
 gc.set_linestyle('dashed')
 if self._dashSeq is not None:
@@ -922,7 +992,7 @@
 		 [-1.0, 1.0], [1.0, -1.0]],
 		 [Path.MOVETO, Path.LINETO,
 		 Path.MOVETO, Path.LINETO])
- def _draw_x(self, renderer, gc, xt, yt):
+ def _draw_x(self, renderer, gc, path, path_trans):
 offset = 0.5*renderer.points_to_pixels(self._markersize)
 	transform = Affine2D().scale(offset)
 	renderer.draw_markers(gc, self._x_path, transform,
Modified: branches/transforms/setupext.py
===================================================================
--- branches/transforms/setupext.py	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/setupext.py	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -813,7 +813,8 @@
 add_agg_flags(module)
 add_ft2font_flags(module)
 add_pygtk_flags(module)
-
+ add_numpy_flags(module)
+ 
 ext_modules.append(module)
 BUILT_GTKAGG = True
 
Modified: branches/transforms/src/_backend_agg.h
===================================================================
--- branches/transforms/src/_backend_agg.h	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/src/_backend_agg.h	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -233,6 +233,7 @@
 : Py::ExtensionModule<_backend_agg_module>( "_backend_agg" )
 {
 RendererAgg::init_type();
+ BufferRegion::init_type();
 
 add_keyword_method("RendererAgg", &_backend_agg_module::new_renderer,
 		 "RendererAgg(width, height, dpi)");
Modified: branches/transforms/src/_gtkagg.cpp
===================================================================
--- branches/transforms/src/_gtkagg.cpp	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/src/_gtkagg.cpp	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -12,6 +12,8 @@
 
 #include "agg_basics.h"
 #include "_backend_agg.h"
+#define PY_ARRAY_TYPES_PREFIX NumPy
+#include "numpy/arrayobject.h"
 
 // the extension module
 class _gtkagg_module : public Py::ExtensionModule<_gtkagg_module>
@@ -69,27 +71,30 @@
 else {
 //bbox is not None; copy the image in the bbox
 // MGDTODO: Use PyArray rather than buffer interface here
-
 PyObject* clipbox = args[2].ptr();
- const void* clipbox_buffer;
- Py_ssize_t clipbox_buffer_len;
- if (!PyObject_CheckReadBuffer(clipbox))
-	throw Py::TypeError
-	 ("Argument 3 to agg_to_gtk_drawable must be a Bbox object.");
+ PyArrayObject* bbox = NULL;
+ double l, b, r, t;
 
- if (PyObject_AsReadBuffer(clipbox, &clipbox_buffer, &clipbox_buffer_len))
-	throw Py::Exception();
+ try {
+	bbox = (PyArrayObject*) PyArray_FromObject(clipbox, PyArray_DOUBLE, 2, 2); 
+	
+	if (!bbox || bbox->nd != 2 || bbox->dimensions[0] != 2 || bbox->dimensions[1] != 2) {
+	 throw Py::TypeError
+	 ("Argument 3 to agg_to_gtk_drawable must be a Bbox object.");
+	}
+	
+	l = *(double*)PyArray_GETPTR2(bbox, 0, 0);
+	b = *(double*)PyArray_GETPTR2(bbox, 0, 1);
+	r = *(double*)PyArray_GETPTR2(bbox, 1, 0);
+	t = *(double*)PyArray_GETPTR2(bbox, 1, 1);
 
- if (clipbox_buffer_len != sizeof(double) * 4)
-	throw Py::TypeError
-	 ("Argument 3 to agg_to_gtk_drawable must be a Bbox object.");
-
- double* clipbox_values = (double*)clipbox_buffer;
- double l = clipbox_values[0];
- double b = clipbox_values[1];
- double r = clipbox_values[2];
- double t = clipbox_values[3];
-
+	Py_XDECREF(bbox);
+	bbox = NULL;
+ } catch (...) {
+	Py_XDECREF(bbox);
+	bbox = NULL;
+	throw;
+ }
 //std::cout << b << " "
 //		<< t << " ";
 
@@ -146,6 +151,7 @@
 {
 init_pygobject();
 init_pygtk();
+ import_array();
 //suppress unused warning by creating in two lines
 static _gtkagg_module* _gtkagg = NULL;
 _gtkagg = new _gtkagg_module;
Modified: branches/transforms/src/_tkagg.cpp
===================================================================
--- branches/transforms/src/_tkagg.cpp	2007年10月24日 18:12:19 UTC (rev 3995)
+++ branches/transforms/src/_tkagg.cpp	2007年10月24日 18:49:08 UTC (rev 3996)
@@ -86,28 +86,28 @@
 /* check for bbox/blitting */
 bboxo = (PyObject*)atol(argv[4]);
 if (bboxo != Py_None) {
- printf("bbox passed in");
-
- const void* bbox_buffer;
- Py_ssize_t bbox_buffer_len;
- if (!PyObject_CheckReadBuffer(bboxo))
-	throw Py::TypeError
-	 ("Argument 5 to PyAggImagePhoto must be a Bbox object.");
-
- if (PyObject_AsReadBuffer(bboxo, &bbox_buffer, &bbox_buffer_len))
-	throw Py::Exception();
-
- if (bbox_buffer_len != sizeof(double) * 4)
-	throw Py::TypeError
-	 ("Argument 3 to agg_to_gtk_drawable must be a Bbox object.");
-
 has_bbox = true;
+ PyArrayObject* bbox = NULL;
+ try {
+	bbox = (PyArrayObject*) PyArray_FromObject(bboxo, PyArray_DOUBLE, 2, 2); 
+	
+	if (!bbox || bbox->nd != 2 || bbox->dimensions[0] != 2 || bbox->dimensions[1] != 2) {
+	 throw Py::TypeError
+	 ("Argument 3 to agg_to_gtk_drawable must be a Bbox object.");
+	}
+	
+	l = *(double*)PyArray_GETPTR2(bbox, 0, 0);
+	b = *(double*)PyArray_GETPTR2(bbox, 0, 1);
+	r = *(double*)PyArray_GETPTR2(bbox, 1, 0);
+	t = *(double*)PyArray_GETPTR2(bbox, 1, 1);
 
- double* bbox_values = (double*)bbox_buffer;
- l = bbox_values[0];
- b = bbox_values[1];
- r = bbox_values[2];
- t = bbox_values[3];
+	Py_XDECREF(bbox);
+	bbox = NULL;
+ } catch (...) {
+	Py_XDECREF(bbox);
+	bbox = NULL;
+	throw;
+ }
 
 destx = (int)l;
 desty = srcheight-(int)t;
@@ -228,5 +228,7 @@
 extern "C"
 DL_EXPORT(void) init_tkagg(void)
 {
- Py_InitModule("_tkagg", functions);
+ import_array();
+
+ Py_InitModule("_tkagg", functions);
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 18:12:29
Revision: 3995
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3995&view=rev
Author: mdboom
Date: 2007年10月24日 11:12:19 -0700 (2007年10月24日)
Log Message:
-----------
Fix masked array plotting again.
Modified Paths:
--------------
 branches/transforms/lib/matplotlib/lines.py
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月24日 18:01:26 UTC (rev 3994)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月24日 18:12:19 UTC (rev 3995)
@@ -378,8 +378,10 @@
 else:
 x, y = args
 
- x = npy.asarray(x)
- y = npy.asarray(y)
+ if not ma.isMaskedArray(x):
+ x = npy.asarray(x)
+ if not ma.isMaskedArray(y):
+ y = npy.asarray(y)
 if ((x.shape != self._xorig.shape or npy.any(x != self._xorig)) or
 (y.shape != self._yorig.shape or npy.any(y != self._yorig))):
 self._xorig = x
@@ -666,6 +668,11 @@
 	renderer.draw_path(gc, path, trans)
 
 
+ def _draw_steps(self, renderer, gc, path, trans):
+ # MGDTODO: Implement me
+ raise NotImplementedError("'steps' linestyle should be returning soon...")
+ 
+
 def _draw_dashed(self, renderer, gc, path, trans):
 gc.set_linestyle('dashed')
 if self._dashSeq is not None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 18:01:28
Revision: 3994
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3994&view=rev
Author: mdboom
Date: 2007年10月24日 11:01:26 -0700 (2007年10月24日)
Log Message:
-----------
Removing a limits change that shouldn't have been committed.
Modified Paths:
--------------
 branches/transforms/examples/simple_plot.py
Modified: branches/transforms/examples/simple_plot.py
===================================================================
--- branches/transforms/examples/simple_plot.py	2007年10月24日 17:11:00 UTC (rev 3993)
+++ branches/transforms/examples/simple_plot.py	2007年10月24日 18:01:26 UTC (rev 3994)
@@ -17,6 +17,4 @@
 #savefig('simple_plot.png')
 savefig('simple_plot')
 
-axes().set_xlim(5, -5)
-
 show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 17:11:12
Revision: 3993
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3993&view=rev
Author: mdboom
Date: 2007年10月24日 10:11:00 -0700 (2007年10月24日)
Log Message:
-----------
Forgot to svn add these files in last commit.
Added Paths:
-----------
 branches/transforms/src/_path.cpp
 branches/transforms/src/agg_py_transforms.h
Added: branches/transforms/src/_path.cpp
===================================================================
--- branches/transforms/src/_path.cpp	 (rev 0)
+++ branches/transforms/src/_path.cpp	2007年10月24日 17:11:00 UTC (rev 3993)
@@ -0,0 +1,384 @@
+#include "agg_py_path_iterator.h"
+#include "agg_py_transforms.h"
+
+#include "CXX/Extensions.hxx"
+
+#include "agg_conv_curve.h"
+#include "agg_conv_stroke.h"
+#include "agg_conv_transform.h"
+#include "agg_path_storage.h"
+#include "agg_trans_affine.h"
+
+// the extension module
+class _path_module : public Py::ExtensionModule<_path_module>
+{
+public:
+ _path_module()
+ : Py::ExtensionModule<_path_module>( "_path" )
+ {
+ add_varargs_method("point_in_path", &_path_module::point_in_path,
+		 "point_in_path(x, y, path, trans)");
+ add_varargs_method("point_on_path", &_path_module::point_on_path,
+		 "point_on_path(x, y, r, path, trans)");
+ add_varargs_method("get_path_extents", &_path_module::get_path_extents,
+		 "get_path_extents(path, trans)");
+ add_varargs_method("get_path_collection_extents", &_path_module::get_path_collection_extents,
+		 "get_path_collection_extents(trans, paths, transforms, offsets, offsetTrans)");
+ add_varargs_method("point_in_path_collection", &_path_module::point_in_path_collection,
+		 "point_in_path_collection(x, y, r, trans, paths, transforms, offsets, offsetTrans, filled)");
+
+ initialize("Helper functions for paths");
+ }
+
+ virtual ~_path_module() {}
+
+private:
+
+ Py::Object point_in_path(const Py::Tuple& args);
+ Py::Object point_on_path(const Py::Tuple& args);
+ Py::Object get_path_extents(const Py::Tuple& args);
+ Py::Object get_path_collection_extents(const Py::Tuple& args);
+ Py::Object point_in_path_collection(const Py::Tuple& args);
+};
+
+//
+// The following function was found in the Agg 2.3 examples (interactive_polygon.cpp).
+// It has been generalized to work on (possibly curved) polylines, rather than
+// just polygons. The original comments have been kept intact.
+// -- Michael Droettboom 2007年10月02日
+//
+//======= Crossings Multiply algorithm of InsideTest ======================== 
+//
+// By Eric Haines, 3D/Eye Inc, er...@ey...
+//
+// This version is usually somewhat faster than the original published in
+// Graphics Gems IV; by turning the division for testing the X axis crossing
+// into a tricky multiplication test this part of the test became faster,
+// which had the additional effect of making the test for "both to left or
+// both to right" a bit slower for triangles than simply computing the
+// intersection each time. The main increase is in triangle testing speed,
+// which was about 15% faster; all other polygon complexities were pretty much
+// the same as before. On machines where division is very expensive (not the
+// case on the HP 9000 series on which I tested) this test should be much
+// faster overall than the old code. Your mileage may (in fact, will) vary,
+// depending on the machine and the test data, but in general I believe this
+// code is both shorter and faster. This test was inspired by unpublished
+// Graphics Gems submitted by Joseph Samosky and Mark Haigh-Hutchinson.
+// Related work by Samosky is in:
+//
+// Samosky, Joseph, "SectionView: A system for interactively specifying and
+// visualizing sections through three-dimensional medical image data",
+// M.S. Thesis, Department of Electrical Engineering and Computer Science,
+// Massachusetts Institute of Technology, 1993.
+//
+// Shoot a test ray along +X axis. The strategy is to compare vertex Y values
+// to the testing point's Y and quickly discard edges which are entirely to one
+// side of the test ray. Note that CONVEX and WINDING code can be added as
+// for the CrossingsTest() code; it is left out here for clarity.
+//
+// Input 2D polygon _pgon_ with _numverts_ number of vertices and test point
+// _point_, returns 1 if inside, 0 if outside.
+template<class T>
+bool point_in_path_impl(double tx, double ty, T& path) {
+ int yflag0, yflag1, inside_flag;
+ double vtx0, vty0, vtx1, vty1, sx, sy;
+ double x, y;
+
+ path.rewind(0);
+ unsigned code = path.vertex(&x, &y);
+ if (code == agg::path_cmd_stop)
+ return false;
+
+ while (true) {
+ sx = vtx0 = x;
+ sy = vty0 = y;
+
+ // get test bit for above/below X axis
+ yflag0 = (vty0 >= ty);
+
+ vtx1 = x;
+ vty1 = x;
+
+ inside_flag = 0;
+ while (true) {
+ code = path.vertex(&x, &y);
+
+ // The following cases denote the beginning on a new subpath
+ if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) {
+	x = sx; y = sy;
+ } else if (code == agg::path_cmd_move_to)
+	break;
+ 
+ yflag1 = (vty1 >= ty);
+ // Check if endpoints straddle (are on opposite sides) of X axis
+ // (i.e. the Y's differ); if so, +X ray could intersect this edge.
+ // The old test also checked whether the endpoints are both to the
+ // right or to the left of the test point. However, given the faster
+ // intersection point computation used below, this test was found to
+ // be a break-even proposition for most polygons and a loser for
+ // triangles (where 50% or more of the edges which survive this test
+ // will cross quadrants and so have to have the X intersection computed
+ // anyway). I credit Joseph Samosky with inspiring me to try dropping
+ // the "both left or both right" part of my code.
+ if (yflag0 != yflag1) {
+	// Check intersection of pgon segment with +X ray.
+	// Note if >= point's X; if so, the ray hits it.
+	// The division operation is avoided for the ">=" test by checking
+	// the sign of the first vertex wrto the test point; idea inspired
+	// by Joseph Samosky's and Mark Haigh-Hutchinson's different
+	// polygon inclusion tests.
+	if ( ((vty1-ty) * (vtx0-vtx1) >=
+	 (vtx1-tx) * (vty0-vty1)) == yflag1 ) {
+	 inside_flag ^= 1;
+	}
+ }
+
+ // Move to the next pair of vertices, retaining info as possible.
+ yflag0 = yflag1;
+ vtx0 = vtx1;
+ vty0 = vty1;
+	
+ vtx1 = x;
+ vty1 = y;
+
+ if (code == agg::path_cmd_stop || 
+	 (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
+	break;
+ }
+
+ if (inside_flag != 0)
+ return true;
+
+ if (code == agg::path_cmd_stop)
+ return false;
+ }
+
+ return false;
+}
+
+bool point_in_path(double x, double y, PathIterator& path, agg::trans_affine& trans) {
+ typedef agg::conv_transform<PathIterator> transformed_path_t;
+ typedef agg::conv_curve<transformed_path_t> curve_t;
+ 
+ transformed_path_t trans_path(path, trans);
+ curve_t curved_path(trans_path);
+ return point_in_path_impl(x, y, curved_path);
+}
+
+bool point_on_path(double x, double y, double r, PathIterator& path, agg::trans_affine& trans) {
+ typedef agg::conv_transform<PathIterator> transformed_path_t;
+ typedef agg::conv_curve<transformed_path_t> curve_t;
+ typedef agg::conv_stroke<curve_t> stroke_t;
+
+ transformed_path_t trans_path(path, trans);
+ curve_t curved_path(trans_path);
+ stroke_t stroked_path(curved_path);
+ stroked_path.width(r * 2.0);
+ return point_in_path_impl(x, y, stroked_path);
+}
+
+Py::Object _path_module::point_in_path(const Py::Tuple& args) {
+ args.verify_length(4);
+ 
+ double x = Py::Float(args[0]);
+ double y = Py::Float(args[1]);
+ PathIterator path(args[2]);
+ agg::trans_affine trans = py_to_agg_transformation_matrix(args[3]);
+
+ if (::point_in_path(x, y, path, trans))
+ return Py::Int(1);
+ return Py::Int(0);
+}
+
+Py::Object _path_module::point_on_path(const Py::Tuple& args) {
+ args.verify_length(5);
+ 
+ double x = Py::Float(args[0]);
+ double y = Py::Float(args[1]);
+ double r = Py::Float(args[2]);
+ PathIterator path(args[3]);
+ agg::trans_affine trans = py_to_agg_transformation_matrix(args[4]);
+
+ if (::point_on_path(x, y, r, path, trans))
+ return Py::Int(1);
+ return Py::Int(0);
+}
+
+void get_path_extents(PathIterator& path, agg::trans_affine& trans, 
+		 double* x0, double* y0, double* x1, double* y1) {
+ typedef agg::conv_transform<PathIterator> transformed_path_t;
+ typedef agg::conv_curve<transformed_path_t> curve_t;
+ double x, y;
+ unsigned code;
+
+ transformed_path_t tpath(path, trans);
+ curve_t curved_path(tpath);
+
+ curved_path.rewind(0);
+
+ while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop) {
+ if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
+ continue;
+ if (x < *x0) *x0 = x;
+ if (y < *y0) *y0 = y;
+ if (x > *x1) *x1 = x;
+ if (y > *y1) *y1 = y;
+ }
+}
+
+Py::Object _path_module::get_path_extents(const Py::Tuple& args) {
+ args.verify_length(2);
+ 
+ PathIterator path(args[0]);
+ agg::trans_affine trans = py_to_agg_transformation_matrix(args[1]);
+
+ double x0 = std::numeric_limits<double>::infinity();
+ double y0 = std::numeric_limits<double>::infinity();
+ double x1 = -std::numeric_limits<double>::infinity();
+ double y1 = -std::numeric_limits<double>::infinity();
+
+ ::get_path_extents(path, trans, &x0, &y0, &x1, &y1);
+
+ Py::Tuple result(4);
+ result[0] = Py::Float(x0);
+ result[1] = Py::Float(y0);
+ result[2] = Py::Float(x1);
+ result[3] = Py::Float(y1);
+ return result;
+}
+
+Py::Object _path_module::get_path_collection_extents(const Py::Tuple& args) {
+ args.verify_length(5);
+
+ //segments, trans, clipbox, colors, linewidths, antialiaseds
+ agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[0]);
+ Py::SeqBase<Py::Object> paths		 = args[1];
+ Py::SeqBase<Py::Object> transforms_obj = args[2];
+ Py::Object offsets_obj = args[3];
+ agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[4], false);
+
+ PyArrayObject* offsets = NULL;
+ double x0, y0, x1, y1;
+
+ try {
+ offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2);
+ if (!offsets || offsets->dimensions[1] != 2)
+ throw Py::ValueError("Offsets array must be Nx2");
+
+ size_t Npaths = paths.length();
+ size_t Noffsets = offsets->dimensions[0];
+ size_t N	 = std::max(Npaths, Noffsets);
+ size_t Ntransforms = std::min(transforms_obj.length(), N);
+ size_t i;
+
+ // Convert all of the transforms up front
+ typedef std::vector<agg::trans_affine> transforms_t;
+ transforms_t transforms;
+ transforms.reserve(Ntransforms);
+ for (i = 0; i < Ntransforms; ++i) {
+ agg::trans_affine trans = py_to_agg_transformation_matrix
+	(transforms_obj[i], false);
+ trans *= master_transform;
+ transforms.push_back(trans);
+ }
+ 
+ // The offset each of those and collect the mins/maxs
+ x0 = std::numeric_limits<double>::infinity();
+ y0 = std::numeric_limits<double>::infinity();
+ x1 = -std::numeric_limits<double>::infinity();
+ y1 = -std::numeric_limits<double>::infinity();
+ for (i = 0; i < N; ++i) {
+ PathIterator path(paths[i % Npaths]);
+ 
+ double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
+ double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
+ offset_trans.transform(&xo, &yo);
+ agg::trans_affine_translation transOffset(xo, yo);
+ agg::trans_affine trans = transforms[i % Ntransforms];
+ trans *= transOffset;
+
+ ::get_path_extents(path, trans, &x0, &y0, &x1, &y1);
+ }
+ } catch (...) {
+ Py_XDECREF(offsets);
+ throw;
+ }
+
+ Py_XDECREF(offsets);
+
+ Py::Tuple result(4);
+ result[0] = Py::Float(x0);
+ result[1] = Py::Float(y0);
+ result[2] = Py::Float(x1);
+ result[3] = Py::Float(y1);
+ return result;
+}
+
+Py::Object _path_module::point_in_path_collection(const Py::Tuple& args) {
+ args.verify_length(9);
+
+ //segments, trans, clipbox, colors, linewidths, antialiaseds
+ double		 x		 = Py::Float(args[0]);
+ double		 y		 = Py::Float(args[1]);
+ double radius = Py::Float(args[2]);
+ agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[3]);
+ Py::SeqBase<Py::Object> paths		 = args[4];
+ Py::SeqBase<Py::Object> transforms_obj = args[5];
+ Py::SeqBase<Py::Object> offsets_obj = args[6];
+ agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7]);
+ bool filled = Py::Int(args[8]);
+ 
+ PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2);
+ if (!offsets || offsets->dimensions[1] != 2)
+ throw Py::ValueError("Offsets array must be Nx2");
+
+ size_t Npaths	 = paths.length();
+ size_t Noffsets = offsets->dimensions[0];
+ size_t N	 = std::max(Npaths, Noffsets);
+ size_t Ntransforms = std::min(transforms_obj.length(), N);
+ size_t i;
+
+ // Convert all of the transforms up front
+ typedef std::vector<agg::trans_affine> transforms_t;
+ transforms_t transforms;
+ transforms.reserve(Ntransforms);
+ for (i = 0; i < Ntransforms; ++i) {
+ agg::trans_affine trans = py_to_agg_transformation_matrix
+ (transforms_obj[i], false);
+ trans *= master_transform;
+ transforms.push_back(trans);
+ }
+
+ Py::List result;
+
+ for (i = 0; i < N; ++i) {
+ PathIterator path(paths[i % Npaths]);
+ 
+ double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
+ double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
+ offset_trans.transform(&xo, &yo);
+ agg::trans_affine_translation transOffset(xo, yo);
+ agg::trans_affine trans = transforms[i % Ntransforms];
+ trans *= transOffset;
+
+ if (filled) {
+ if (::point_in_path(x, y, path, trans))
+	result.append(Py::Int((int)i));
+ } else {
+ if (::point_on_path(x, y, radius, path, trans))
+	result.append(Py::Int((int)i));
+ }
+ }
+
+ return result;
+}
+
+extern "C"
+DL_EXPORT(void)
+ init_path(void)
+{
+ import_array();
+ 
+ static _path_module* _path = NULL;
+ _path = new _path_module;
+};
Added: branches/transforms/src/agg_py_transforms.h
===================================================================
--- branches/transforms/src/agg_py_transforms.h	 (rev 0)
+++ branches/transforms/src/agg_py_transforms.h	2007年10月24日 17:11:00 UTC (rev 3993)
@@ -0,0 +1,58 @@
+#ifndef __AGG_PY_TRANSFORMS_H__
+#define __AGG_PY_TRANSFORMS_H__
+
+#define PY_ARRAY_TYPES_PREFIX NumPy
+#include "numpy/arrayobject.h"
+
+#include "CXX/Objects.hxx"
+#include "agg_trans_affine.h"
+
+
+/** A helper function to convert from a Numpy affine transformation matrix
+ * to an agg::trans_affine.
+ */
+agg::trans_affine py_to_agg_transformation_matrix(const Py::Object& obj, bool errors = true) {
+ PyArrayObject* matrix = NULL;
+ 
+ try {
+ if (obj.ptr() == Py_None)
+ throw std::exception();
+ matrix = (PyArrayObject*) PyArray_FromObject(obj.ptr(), PyArray_DOUBLE, 2, 2);
+ if (!matrix)
+ throw std::exception();
+ if (matrix->nd == 2 || matrix->dimensions[0] == 3 || matrix->dimensions[1] == 3) {
+ size_t stride0 = matrix->strides[0];
+ size_t stride1 = matrix->strides[1];
+ char* row0 = matrix->data;
+ char* row1 = row0 + stride0;
+ 
+ double a = *(double*)(row0);
+ row0 += stride1;
+ double c = *(double*)(row0);
+ row0 += stride1;
+ double e = *(double*)(row0);
+ 
+ double b = *(double*)(row1);
+ row1 += stride1;
+ double d = *(double*)(row1);
+ row1 += stride1;
+ double f = *(double*)(row1);
+ 
+ Py_XDECREF(matrix);
+ 
+ return agg::trans_affine(a, b, c, d, e, f);
+ }
+
+ throw std::exception();
+ } catch (...) {
+ if (errors) {
+ Py_XDECREF(matrix);
+ throw Py::TypeError("Invalid affine transformation matrix");
+ }
+ }
+
+ Py_XDECREF(matrix);
+ return agg::trans_affine();
+}
+
+#endif // __AGG_PY_TRANSFORMS_H__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月24日 16:17:52
Revision: 3992
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3992&view=rev
Author: mdboom
Date: 2007年10月24日 09:03:49 -0700 (2007年10月24日)
Log Message:
-----------
Separated path utilities from backend_agg
Modified Paths:
--------------
 branches/transforms/lib/matplotlib/backends/backend_pdf.py
 branches/transforms/lib/matplotlib/collections.py
 branches/transforms/lib/matplotlib/path.py
 branches/transforms/setup.py
 branches/transforms/setupext.py
 branches/transforms/src/_backend_agg.cpp
 branches/transforms/src/_backend_agg.h
 branches/transforms/src/agg_py_path_iterator.h
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -35,8 +35,6 @@
 from matplotlib.transforms import Bbox, BboxBase
 from matplotlib.path import Path
 from matplotlib import ttconv
-# MGDTODO: Move this stuff
-from matplotlib.backends._backend_agg import get_path_extents
 
 # Overview
 #
@@ -1034,8 +1032,7 @@
 def writeMarkers(self):
 for tup in self.markers.values():
 name, object, path, trans, fillp, lw = tup
- a, b, c, d = get_path_extents(path, trans)
- bbox = Bbox.from_lbrt(*get_path_extents(path, trans))
+ bbox = Bbox.from_lbrt(*path.get_extents(trans))
 bbox = bbox.padded(lw * 0.5)
 self.beginStream(
 object.id, None,
Modified: branches/transforms/lib/matplotlib/collections.py
===================================================================
--- branches/transforms/lib/matplotlib/collections.py	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/lib/matplotlib/collections.py	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -19,13 +19,6 @@
 import matplotlib.nxutils as nxutils
 import matplotlib.path as path
 
-# MGDTODO: Move this stuff
-from matplotlib.backends._backend_agg import get_path_collection_extents, \
- point_in_path_collection
-
-# MGDTODO: Treat facecolors and edgecolors as numpy arrays always
-# and then update draw_path_collection to use the array interface
-
 class Collection(artist.Artist, cm.ScalarMappable):
 """
 Base class for Collections. Must be subclassed to be usable.
@@ -133,7 +126,7 @@
 return self._transforms
 
 def get_datalim(self, transData):
- result = transforms.Bbox.from_lbrt(*get_path_collection_extents(
+ result = transforms.Bbox.from_lbrt(*path.get_path_collection_extents(
 self.get_transform().frozen(),
 self.get_paths(),
 self.get_transforms(),
@@ -201,7 +194,7 @@
 transform = transform.get_affine()
 
 # MGDTODO: Don't pick when outside of clip path / clip box
- ind = point_in_path_collection(
+ ind = path.point_in_path_collection(
 mouseevent.x, mouseevent.y, self._pickradius,
 transform.frozen(), paths, self.get_transforms(),
 npy.asarray(self._offsets, npy.float_),
Modified: branches/transforms/lib/matplotlib/path.py
===================================================================
--- branches/transforms/lib/matplotlib/path.py	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/lib/matplotlib/path.py	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -9,7 +9,8 @@
 import numpy as npy
 from numpy import ma as ma
 
-from matplotlib.backends._backend_agg import point_in_path, get_path_extents
+from matplotlib._path import point_in_path, get_path_extents, \
+ get_path_collection_extents, point_in_path_collection
 from matplotlib.cbook import simple_linear_interpolation
 
 KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0
Modified: branches/transforms/setup.py
===================================================================
--- branches/transforms/setup.py	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/setup.py	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -19,6 +19,11 @@
 # whatever array packages you have installed.
 BUILD_IMAGE = 1
 
+# Build the path utilities module. This module depends on some parts
+# of Agg, but is separate from _backend_agg, since it is used even when
+# the Agg renderer is not.
+BUILD_PATH = 1
+
 # Build the antigrain geometry toolkit. Agg makes heavy use of
 # templates, so it probably requires a fairly recent compiler to build
 # it. It makes very nice antialiased output and also supports alpha
@@ -77,7 +82,7 @@
 import glob
 from distutils.core import setup
 from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
- build_ft2font, build_image, build_windowing, \
+ build_ft2font, build_image, build_windowing, build_path, \
 build_contour, build_nxutils, build_enthought, build_swigagg, build_gdk, \
 build_subprocess, build_ttconv, print_line, print_status, print_message, \
 print_raw, check_for_freetype, check_for_libpng, check_for_gtk, check_for_tk, \
@@ -260,6 +265,9 @@
 if BUILD_IMAGE:
 build_image(ext_modules, packages)
 
+if BUILD_PATH:
+ build_path(ext_modules, packages)
+ 
 for mod in ext_modules:
 if VERBOSE:
 mod.extra_compile_args.append('-DVERBOSE')
Modified: branches/transforms/setupext.py
===================================================================
--- branches/transforms/setupext.py	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/setupext.py	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -90,6 +90,7 @@
 BUILT_ENTHOUGHT = False
 BUILT_CONTOUR = False
 BUILT_GDK = False
+BUILT_PATH = False
 
 AGG_VERSION = 'agg23'
 
@@ -897,6 +898,37 @@
 
 BUILT_AGG = True
 
+def build_path(ext_modules, packages):
+ global BUILT_PATH
+ if BUILT_PATH: return # only build it if you you haven't already
+
+ agg = (
+ 'agg_curves.cpp',
+ 'agg_bezier_arc.cpp',
+ 'agg_path_storage.cpp',
+ 'agg_trans_affine.cpp',
+ 'agg_vcgen_stroke.cpp',
+ )
+
+ deps = ['%s/src/%s'%(AGG_VERSION, name) for name in agg]
+ deps.extend(glob.glob('CXX/*.cxx'))
+ deps.extend(glob.glob('CXX/*.c'))
+
+ temp_copy('src/_path.cpp', 'src/path.cpp')
+ deps.extend(['src/path.cpp'])
+ module = Extension(
+ 'matplotlib._path',
+ deps,
+ include_dirs=numpy_inc_dirs,
+ )
+
+ add_numpy_flags(module)
+
+ add_agg_flags(module)
+ ext_modules.append(module)
+
+ BUILT_PATH = True
+ 
 def build_image(ext_modules, packages):
 global BUILT_IMAGE
 if BUILT_IMAGE: return # only build it if you you haven't already
Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/src/_backend_agg.cpp	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -30,6 +30,7 @@
 
 #define PY_ARRAY_TYPES_PREFIX NumPy
 #include "numpy/arrayobject.h"
+#include "agg_py_transforms.h"
 
 #ifndef M_PI
 #define M_PI 3.14159265358979323846
@@ -41,53 +42,7 @@
 #define M_PI_2 1.57079632679489661923
 #endif
 
-/** A helper function to convert from a Numpy affine transformation matrix
- * to an agg::trans_affine.
- */
-agg::trans_affine py_to_agg_transformation_matrix(const Py::Object& obj, bool errors=true) {
- PyArrayObject* matrix = NULL;
- 
- try {
- if (obj.ptr() == Py_None)
- throw Py::Exception();
- matrix = (PyArrayObject*) PyArray_FromObject(obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!matrix)
- throw Py::Exception();
- if (matrix->nd == 2 || matrix->dimensions[0] == 3 || matrix->dimensions[1] == 3) {
- size_t stride0 = matrix->strides[0];
- size_t stride1 = matrix->strides[1];
- char* row0 = matrix->data;
- char* row1 = row0 + stride0;
- 
- double a = *(double*)(row0);
- row0 += stride1;
- double c = *(double*)(row0);
- row0 += stride1;
- double e = *(double*)(row0);
- 
- double b = *(double*)(row1);
- row1 += stride1;
- double d = *(double*)(row1);
- row1 += stride1;
- double f = *(double*)(row1);
- 
- Py_XDECREF(matrix);
- 
- return agg::trans_affine(a, b, c, d, e, f);
- }
 
- throw Py::Exception();
- } catch (...) {
- if (errors) {
- Py_XDECREF(matrix);
- throw Py::TypeError("Invalid affine transformation matrix");
- }
- }
-
- Py_XDECREF(matrix);
- return agg::trans_affine();
-}
-
 /*
 Convert dashes from the Python representation as nested sequences to
 the C++ representation as a std::vector<std::pair<double, double> >
@@ -1392,338 +1347,6 @@
 
 }
 
-//
-// The following code was found in the Agg 2.3 examples (interactive_polygon.cpp).
-// It has been generalized to work on (possibly curved) polylines, rather than
-// just polygons. The original comments have been kept intact.
-// -- Michael Droettboom 2007年10月02日
-//
-//======= Crossings Multiply algorithm of InsideTest ======================== 
-//
-// By Eric Haines, 3D/Eye Inc, er...@ey...
-//
-// This version is usually somewhat faster than the original published in
-// Graphics Gems IV; by turning the division for testing the X axis crossing
-// into a tricky multiplication test this part of the test became faster,
-// which had the additional effect of making the test for "both to left or
-// both to right" a bit slower for triangles than simply computing the
-// intersection each time. The main increase is in triangle testing speed,
-// which was about 15% faster; all other polygon complexities were pretty much
-// the same as before. On machines where division is very expensive (not the
-// case on the HP 9000 series on which I tested) this test should be much
-// faster overall than the old code. Your mileage may (in fact, will) vary,
-// depending on the machine and the test data, but in general I believe this
-// code is both shorter and faster. This test was inspired by unpublished
-// Graphics Gems submitted by Joseph Samosky and Mark Haigh-Hutchinson.
-// Related work by Samosky is in:
-//
-// Samosky, Joseph, "SectionView: A system for interactively specifying and
-// visualizing sections through three-dimensional medical image data",
-// M.S. Thesis, Department of Electrical Engineering and Computer Science,
-// Massachusetts Institute of Technology, 1993.
-//
-// Shoot a test ray along +X axis. The strategy is to compare vertex Y values
-// to the testing point's Y and quickly discard edges which are entirely to one
-// side of the test ray. Note that CONVEX and WINDING code can be added as
-// for the CrossingsTest() code; it is left out here for clarity.
-//
-// Input 2D polygon _pgon_ with _numverts_ number of vertices and test point
-// _point_, returns 1 if inside, 0 if outside.
-template<class T>
-bool point_in_path_impl(double tx, double ty, T& path) {
- int yflag0, yflag1, inside_flag;
- double vtx0, vty0, vtx1, vty1, sx, sy;
- double x, y;
-
- path.rewind(0);
- unsigned code = path.vertex(&x, &y);
- if (code == agg::path_cmd_stop)
- return false;
-
- while (true) {
- sx = vtx0 = x;
- sy = vty0 = y;
-
- // get test bit for above/below X axis
- yflag0 = (vty0 >= ty);
-
- vtx1 = x;
- vty1 = x;
-
- inside_flag = 0;
- while (true) {
- code = path.vertex(&x, &y);
-
- // The following cases denote the beginning on a new subpath
- if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) {
-	x = sx; y = sy;
- } else if (code == agg::path_cmd_move_to)
-	break;
- 
- yflag1 = (vty1 >= ty);
- // Check if endpoints straddle (are on opposite sides) of X axis
- // (i.e. the Y's differ); if so, +X ray could intersect this edge.
- // The old test also checked whether the endpoints are both to the
- // right or to the left of the test point. However, given the faster
- // intersection point computation used below, this test was found to
- // be a break-even proposition for most polygons and a loser for
- // triangles (where 50% or more of the edges which survive this test
- // will cross quadrants and so have to have the X intersection computed
- // anyway). I credit Joseph Samosky with inspiring me to try dropping
- // the "both left or both right" part of my code.
- if (yflag0 != yflag1) {
-	// Check intersection of pgon segment with +X ray.
-	// Note if >= point's X; if so, the ray hits it.
-	// The division operation is avoided for the ">=" test by checking
-	// the sign of the first vertex wrto the test point; idea inspired
-	// by Joseph Samosky's and Mark Haigh-Hutchinson's different
-	// polygon inclusion tests.
-	if ( ((vty1-ty) * (vtx0-vtx1) >=
-	 (vtx1-tx) * (vty0-vty1)) == yflag1 ) {
-	 inside_flag ^= 1;
-	}
- }
-
- // Move to the next pair of vertices, retaining info as possible.
- yflag0 = yflag1;
- vtx0 = vtx1;
- vty0 = vty1;
-	
- vtx1 = x;
- vty1 = y;
-
- if (code == agg::path_cmd_stop || 
-	 (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
-	break;
- }
-
- if (inside_flag != 0)
- return true;
-
- if (code == agg::path_cmd_stop)
- return false;
- }
-
- return false;
-}
-
-bool point_in_path(double x, double y, PathIterator& path, agg::trans_affine& trans) {
- typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef agg::conv_curve<transformed_path_t> curve_t;
- 
- transformed_path_t trans_path(path, trans);
- curve_t curved_path(trans_path);
- return point_in_path_impl(x, y, curved_path);
-}
-
-bool point_on_path(double x, double y, double r, PathIterator& path, agg::trans_affine& trans) {
- typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef agg::conv_curve<transformed_path_t> curve_t;
- typedef agg::conv_stroke<curve_t> stroke_t;
-
- transformed_path_t trans_path(path, trans);
- curve_t curved_path(trans_path);
- stroke_t stroked_path(curved_path);
- stroked_path.width(r * 2.0);
- return point_in_path_impl(x, y, stroked_path);
-}
-
-Py::Object _backend_agg_module::point_in_path(const Py::Tuple& args) {
- args.verify_length(4);
- 
- double x = Py::Float(args[0]);
- double y = Py::Float(args[1]);
- PathIterator path(args[2]);
- agg::trans_affine trans = py_to_agg_transformation_matrix(args[3]);
-
- if (::point_in_path(x, y, path, trans))
- return Py::Int(1);
- return Py::Int(0);
-}
-
-Py::Object _backend_agg_module::point_on_path(const Py::Tuple& args) {
- args.verify_length(5);
- 
- double x = Py::Float(args[0]);
- double y = Py::Float(args[1]);
- double r = Py::Float(args[2]);
- PathIterator path(args[3]);
- agg::trans_affine trans = py_to_agg_transformation_matrix(args[4]);
-
- if (::point_on_path(x, y, r, path, trans))
- return Py::Int(1);
- return Py::Int(0);
-}
-
-void get_path_extents(PathIterator& path, agg::trans_affine& trans, 
-		 double* x0, double* y0, double* x1, double* y1) {
- typedef agg::conv_transform<PathIterator> transformed_path_t;
- typedef agg::conv_curve<transformed_path_t> curve_t;
- double x, y;
- unsigned code;
-
- transformed_path_t tpath(path, trans);
- curve_t curved_path(tpath);
-
- curved_path.rewind(0);
-
- while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop) {
- if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
- continue;
- if (x < *x0) *x0 = x;
- if (y < *y0) *y0 = y;
- if (x > *x1) *x1 = x;
- if (y > *y1) *y1 = y;
- }
-}
-
-Py::Object _backend_agg_module::get_path_extents(const Py::Tuple& args) {
- args.verify_length(2);
- 
- PathIterator path(args[0]);
- agg::trans_affine trans = py_to_agg_transformation_matrix(args[1]);
-
- double x0 = std::numeric_limits<double>::infinity();
- double y0 = std::numeric_limits<double>::infinity();
- double x1 = -std::numeric_limits<double>::infinity();
- double y1 = -std::numeric_limits<double>::infinity();
-
- ::get_path_extents(path, trans, &x0, &y0, &x1, &y1);
-
- Py::Tuple result(4);
- result[0] = Py::Float(x0);
- result[1] = Py::Float(y0);
- result[2] = Py::Float(x1);
- result[3] = Py::Float(y1);
- return result;
-}
-
-Py::Object _backend_agg_module::get_path_collection_extents(const Py::Tuple& args) {
- args.verify_length(5);
-
- //segments, trans, clipbox, colors, linewidths, antialiaseds
- agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[0]);
- Py::SeqBase<Py::Object> paths		 = args[1];
- Py::SeqBase<Py::Object> transforms_obj = args[2];
- Py::Object offsets_obj = args[3];
- agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[4], false);
-
- PyArrayObject* offsets = NULL;
- double x0, y0, x1, y1;
-
- try {
- offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!offsets || offsets->dimensions[1] != 2)
- throw Py::ValueError("Offsets array must be Nx2");
-
- size_t Npaths = paths.length();
- size_t Noffsets = offsets->dimensions[0];
- size_t N	 = std::max(Npaths, Noffsets);
- size_t Ntransforms = std::min(transforms_obj.length(), N);
- size_t i;
-
- // Convert all of the transforms up front
- typedef std::vector<agg::trans_affine> transforms_t;
- transforms_t transforms;
- transforms.reserve(Ntransforms);
- for (i = 0; i < Ntransforms; ++i) {
- agg::trans_affine trans = py_to_agg_transformation_matrix
-	(transforms_obj[i], false);
- trans *= master_transform;
- transforms.push_back(trans);
- }
- 
- // The offset each of those and collect the mins/maxs
- x0 = std::numeric_limits<double>::infinity();
- y0 = std::numeric_limits<double>::infinity();
- x1 = -std::numeric_limits<double>::infinity();
- y1 = -std::numeric_limits<double>::infinity();
- for (i = 0; i < N; ++i) {
- PathIterator path(paths[i % Npaths]);
- 
- double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
- double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
- offset_trans.transform(&xo, &yo);
- agg::trans_affine_translation transOffset(xo, yo);
- agg::trans_affine trans = transforms[i % Ntransforms];
- trans *= transOffset;
-
- ::get_path_extents(path, trans, &x0, &y0, &x1, &y1);
- }
- } catch (...) {
- Py_XDECREF(offsets);
- throw;
- }
-
- Py_XDECREF(offsets);
-
- Py::Tuple result(4);
- result[0] = Py::Float(x0);
- result[1] = Py::Float(y0);
- result[2] = Py::Float(x1);
- result[3] = Py::Float(y1);
- return result;
-}
-
-Py::Object _backend_agg_module::point_in_path_collection(const Py::Tuple& args) {
- args.verify_length(9);
-
- //segments, trans, clipbox, colors, linewidths, antialiaseds
- double		 x		 = Py::Float(args[0]);
- double		 y		 = Py::Float(args[1]);
- double radius = Py::Float(args[2]);
- agg::trans_affine	 master_transform = py_to_agg_transformation_matrix(args[3]);
- Py::SeqBase<Py::Object> paths		 = args[4];
- Py::SeqBase<Py::Object> transforms_obj = args[5];
- Py::SeqBase<Py::Object> offsets_obj = args[6];
- agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7]);
- bool filled = Py::Int(args[8]);
- 
- PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2);
- if (!offsets || offsets->dimensions[1] != 2)
- throw Py::ValueError("Offsets array must be Nx2");
-
- size_t Npaths	 = paths.length();
- size_t Noffsets = offsets->dimensions[0];
- size_t N	 = std::max(Npaths, Noffsets);
- size_t Ntransforms = std::min(transforms_obj.length(), N);
- size_t i;
-
- // Convert all of the transforms up front
- typedef std::vector<agg::trans_affine> transforms_t;
- transforms_t transforms;
- transforms.reserve(Ntransforms);
- for (i = 0; i < Ntransforms; ++i) {
- agg::trans_affine trans = py_to_agg_transformation_matrix
- (transforms_obj[i], false);
- trans *= master_transform;
- transforms.push_back(trans);
- }
-
- Py::List result;
-
- for (i = 0; i < N; ++i) {
- PathIterator path(paths[i % Npaths]);
- 
- double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0);
- double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1);
- offset_trans.transform(&xo, &yo);
- agg::trans_affine_translation transOffset(xo, yo);
- agg::trans_affine trans = transforms[i % Ntransforms];
- trans *= transOffset;
-
- if (filled) {
- if (::point_in_path(x, y, path, trans))
-	result.append(Py::Int((int)i));
- } else {
- if (::point_on_path(x, y, radius, path, trans))
-	result.append(Py::Int((int)i));
- }
- }
-
- return result;
-}
-
 /* ------------ module methods ------------- */
 Py::Object _backend_agg_module::new_renderer (const Py::Tuple &args,
 					 const Py::Dict &kws)
Modified: branches/transforms/src/_backend_agg.h
===================================================================
--- branches/transforms/src/_backend_agg.h	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/src/_backend_agg.h	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -236,17 +236,6 @@
 
 add_keyword_method("RendererAgg", &_backend_agg_module::new_renderer,
 		 "RendererAgg(width, height, dpi)");
- add_varargs_method("point_in_path", &_backend_agg_module::point_in_path,
-		 "point_in_path(x, y, path, trans)");
- add_varargs_method("point_on_path", &_backend_agg_module::point_on_path,
-		 "point_on_path(x, y, r, path, trans)");
- add_varargs_method("get_path_extents", &_backend_agg_module::get_path_extents,
-		 "get_path_extents(path, trans)");
- add_varargs_method("get_path_collection_extents", &_backend_agg_module::get_path_collection_extents,
-		 "get_path_collection_extents(trans, paths, transforms, offsets, offsetTrans)");
- add_varargs_method("point_in_path_collection", &_backend_agg_module::point_in_path_collection,
-		 "point_in_path_collection(x, y, r, trans, paths, transforms, offsets, offsetTrans, filled)");
-
 initialize( "The agg rendering backend" );
 }
 
@@ -255,11 +244,6 @@
 private:
 
 Py::Object new_renderer (const Py::Tuple &args, const Py::Dict &kws);
- Py::Object point_in_path(const Py::Tuple& args);
- Py::Object point_on_path(const Py::Tuple& args);
- Py::Object get_path_extents(const Py::Tuple& args);
- Py::Object get_path_collection_extents(const Py::Tuple& args);
- Py::Object point_in_path_collection(const Py::Tuple& args);
 };
 
 
Modified: branches/transforms/src/agg_py_path_iterator.h
===================================================================
--- branches/transforms/src/agg_py_path_iterator.h	2007年10月23日 21:25:24 UTC (rev 3991)
+++ branches/transforms/src/agg_py_path_iterator.h	2007年10月24日 16:03:49 UTC (rev 3992)
@@ -1,5 +1,10 @@
+#ifndef __AGG_PY_PATH_ITERATOR_H__
+#define __AGG_PY_PATH_ITERATOR_H__
+
+#include "CXX/Objects.hxx"
 #define PY_ARRAY_TYPES_PREFIX NumPy
 #include "numpy/arrayobject.h"
+#include "agg_path_storage.h"
 
 class PathIterator {
 PyArrayObject* vertices;
@@ -66,3 +71,5 @@
 agg::path_cmd_curve3,
 agg::path_cmd_curve4,
 agg::path_cmd_end_poly | agg::path_flags_close};
+
+#endif // __AGG_PY_PATH_ITERATOR_H__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2007年10月23日 21:25:28
Revision: 3991
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3991&view=rev
Author: efiring
Date: 2007年10月23日 14:25:24 -0700 (2007年10月23日)
Log Message:
-----------
Bugfix: save colorbar axis label so it won't get lost
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/colorbar.py
Modified: trunk/matplotlib/lib/matplotlib/colorbar.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colorbar.py	2007年10月23日 19:48:14 UTC (rev 3990)
+++ trunk/matplotlib/lib/matplotlib/colorbar.py	2007年10月23日 21:25:24 UTC (rev 3991)
@@ -155,6 +155,7 @@
 self.filled = filled
 self.solids = None
 self.lines = None
+ self.set_label('')
 if cbook.iterable(ticks):
 self.locator = ticker.FixedLocator(ticks, nbins=len(ticks))
 else:
@@ -183,6 +184,7 @@
 self._config_axes(X, Y)
 if self.filled:
 self._add_solids(X, Y, C)
+ self._set_label()
 
 def _config_axes(self, X, Y):
 '''
@@ -220,12 +222,18 @@
 ax.set_xticklabels(ticklabels)
 ax.xaxis.get_major_formatter().set_offset_string(offset_string)
 
- def set_label(self, label, **kw):
+ def _set_label(self):
 if self.orientation == 'vertical':
- self.ax.set_ylabel(label, **kw)
+ self.ax.set_ylabel(self._label, **self._labelkw)
 else:
- self.ax.set_xlabel(label, **kw)
+ self.ax.set_xlabel(self._label, **self._labelkw)
 
+ def set_label(self, label, **kw):
+ self._label = label
+ self._labelkw = kw
+ self._set_label()
+
+
 def _outline(self, X, Y):
 '''
 Return x, y arrays of colorbar bounding polygon,
@@ -556,6 +564,10 @@
 is changed.
 '''
 cm.ScalarMappable.notify(self, mappable)
+ # We are using an ugly brute-force method: clearing and
+ # redrawing the whole thing. The problem is that if any
+ # properties have been changed by methods other than the
+ # colorbar methods, those changes will be lost.
 self.ax.cla()
 self.draw_all()
 #if self.vmin != self.norm.vmin or self.vmax != self.norm.vmax:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月23日 19:48:30
Revision: 3990
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3990&view=rev
Author: mdboom
Date: 2007年10月23日 12:48:14 -0700 (2007年10月23日)
Log Message:
-----------
Fix bug affecting legend_auto.py
Modified Paths:
--------------
 branches/transforms/src/_backend_agg.cpp
Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp	2007年10月23日 19:47:43 UTC (rev 3989)
+++ branches/transforms/src/_backend_agg.cpp	2007年10月23日 19:48:14 UTC (rev 3990)
@@ -1568,12 +1568,12 @@
 curved_path.rewind(0);
 
 while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop) {
+ if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
+ continue;
 if (x < *x0) *x0 = x;
 if (y < *y0) *y0 = y;
 if (x > *x1) *x1 = x;
 if (y > *y1) *y1 = y;
- if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
- continue;
 }
 }
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 3989
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3989&view=rev
Author: mdboom
Date: 2007年10月23日 12:47:43 -0700 (2007年10月23日)
Log Message:
-----------
Fix bug in clipping rectangle in PDF
Modified Paths:
--------------
 branches/transforms/lib/matplotlib/backends/backend_pdf.py
Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月23日 19:20:21 UTC (rev 3988)
+++ branches/transforms/lib/matplotlib/backends/backend_pdf.py	2007年10月23日 19:47:43 UTC (rev 3989)
@@ -32,7 +32,7 @@
 from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE, \
 LOAD_NO_HINTING, KERNING_UNFITTED
 from matplotlib.mathtext import MathTextParser
-from matplotlib.transforms import Bbox
+from matplotlib.transforms import Bbox, BboxBase
 from matplotlib.path import Path
 from matplotlib import ttconv
 # MGDTODO: Move this stuff
@@ -172,11 +172,8 @@
 return pdfRepr(r)
 
 # A bounding box
- elif isinstance(obj, Bbox):
- r = ["["]
- r.extend([pdfRepr(val) for val in obj.lbrt])
- r.append("]")
- return fill(r)
+ elif isinstance(obj, BboxBase):
+ return fill([pdfRepr(val) for val in obj.bounds])
 
 else:
 raise TypeError, \
@@ -1043,7 +1040,7 @@
 self.beginStream(
 object.id, None,
 {'Type': Name('XObject'), 'Subtype': Name('Form'),
- 'BBox': bbox })
+ 'BBox': list(bbox.lbrt) })
 self.writePath(path, trans)
 if fillp:
 self.output(Op.fill_stroke)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月23日 19:20:27
Revision: 3988
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3988&view=rev
Author: mdboom
Date: 2007年10月23日 12:20:21 -0700 (2007年10月23日)
Log Message:
-----------
Reduce tendency to use aliased drawing.
Modified Paths:
--------------
 branches/transforms/src/_backend_agg.cpp
Modified: branches/transforms/src/_backend_agg.cpp
===================================================================
--- branches/transforms/src/_backend_agg.cpp	2007年10月23日 19:16:11 UTC (rev 3987)
+++ branches/transforms/src/_backend_agg.cpp	2007年10月23日 19:20:21 UTC (rev 3988)
@@ -434,7 +434,7 @@
 }
 
 trans.transform(&x1, &y1);
- if (!(fabs(x0 - x1) < 0.1 || fabs(y0 - y1) < 0.1)) {
+ if (!(fabs(x0 - x1) < 0.001 || fabs(y0 - y1) < 0.001)) {
 path.rewind(0);
 return false;
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <md...@us...> - 2007年10月23日 19:16:19
Revision: 3987
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3987&view=rev
Author: mdboom
Date: 2007年10月23日 12:16:11 -0700 (2007年10月23日)
Log Message:
-----------
Fix bugs in log_demo.py
Modified Paths:
--------------
 branches/transforms/lib/matplotlib/lines.py
Modified: branches/transforms/lib/matplotlib/lines.py
===================================================================
--- branches/transforms/lib/matplotlib/lines.py	2007年10月23日 16:54:51 UTC (rev 3986)
+++ branches/transforms/lib/matplotlib/lines.py	2007年10月23日 19:16:11 UTC (rev 3987)
@@ -284,7 +284,6 @@
 self._xorig = npy.asarray([])
 self._yorig = npy.asarray([])
 self.set_data(xdata, ydata)
- self._logcache = None
 
 def contains(self, mouseevent):
 """Test whether the mouse event occurred on the line. The pick radius determines
@@ -386,6 +385,8 @@
 self._xorig = x
 self._yorig = y
 self.recache()
+ else:
+ self._transformed_path = TransformedPath(self._path, self.get_transform())
 
 def recache(self):
 #if self.axes is None: print 'recache no axes'
@@ -418,7 +419,6 @@
 self._xy = npy.concatenate((x, y), 1)
 	self._x = self._xy[:, 0] # just a view
 	self._y = self._xy[:, 1] # just a view
- self._logcache = None
 
 # Masked arrays are now handled by the Path class itself
 self._path = Path(self._xy, closed=False)
@@ -632,9 +632,7 @@
 ACCEPTS: npy.array
 """
 x = npy.asarray(x)
- if x.shape != self._xorig.shape or npy.any(x != self._xorig):
- self._xorig = x
- self.recache()
+ self.set_data(x, self._yorig)
 
 def set_ydata(self, y):
 """
@@ -643,9 +641,7 @@
 ACCEPTS: npy.array
 """
 y = npy.asarray(y)
- if y.shape != self._yorig.shape or npy.any(y != self._yorig):
- self._yorig = y
- self.recache()
+ self.set_data(self._xorig, y)
 
 def set_dashes(self, seq):
 """
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 5455

<< < 1 .. 198 199 200 201 202 .. 219 > >> (Page 200 of 219)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /