Revision: 4000 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4000&view=rev Author: mdboom Date: 2007-10-25 07:07:44 -0700 (Thu, 25 Oct 2007)
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) + [EMAIL PROTECTED] 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. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins