From: <md...@us...> - 2007-10-29 15:21:55
|
Revision: 4053 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4053&view=rev Author: mdboom Date: 2007-10-29 08:21:49 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Lots of minor bug fixes. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/lib/matplotlib/artist.py 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_svg.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/colors.py branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/widgets.py Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/PASSED_DEMOS 2007-10-29 15:21:49 UTC (rev 4053) @@ -208,3 +208,5 @@ xcorr_demo.py O zoom_window.py O zorder_demo.py O + +MGDTODO: units directory \ No newline at end of file Modified: branches/transforms/lib/matplotlib/artist.py =================================================================== --- branches/transforms/lib/matplotlib/artist.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/artist.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -2,6 +2,7 @@ import re, warnings from cbook import iterable, flatten from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath +from path import Path ## Note, matplotlib artists use the doc strings for set and get # methods to enable the introspection methods of setp and getp. Every @@ -285,25 +286,48 @@ def set_clip_path(self, path, transform=None): """ - Set the artist's clip path + Set the artist's clip path, which may be: - ACCEPTS: a Path instance and a Transform instance, or a Patch instance + a) a Patch (or subclass) instance + + b) a Path instance, in which cas aoptional transform may + be provided, which will be applied to the path before using it + for clipping. + + c) None, to remove the clipping path + + For efficiency, if the path happens to be an axis-aligned + rectangle, this method will set the clipping box to the + corresponding rectangle and set the clipping path to None. + + ACCEPTS: a Path instance and a Transform instance, a Patch + instance, or None """ from patches import Patch, Rectangle + + success = False if transform is None: if isinstance(path, Rectangle): self.clipbox = TransformedBbox(Bbox.unit(), path.get_transform()) + success = True elif isinstance(path, Patch): self._clippath = TransformedPath( path.get_path(), path.get_transform()) - elif path is None: - self._clippath = None - else: - raise TypeError("Invalid arguments to set_clip_path") - else: + success = True + + if path is None: + self._clippath = None + success = True + elif isinstance(path, Path): self._clippath = TransformedPath(path, transform) - self._clipon = self.clipbox is not None or path is not None + success = True + + if not success: + print type(path), type(transform) + raise TypeError("Invalid arguments to set_clip_path") + + self._clipon = self.clipbox is not None or self._clippath is not None self.pchanged() def get_alpha(self): @@ -334,6 +358,10 @@ return self._clippath def get_transformed_clip_path_and_affine(self): + ''' + Return the clip path with the non-affine part of its transformation applied, + and the remaining affine part of its transformation. + ''' if self._clippath is not None: return self._clippath.get_transformed_path_and_affine() return None, None Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/axes.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -494,9 +494,6 @@ self.set_label(label) self.set_figure(fig) - self._invertedx = False - self._invertedy = False - # this call may differ for non-sep axes, eg polar self._init_axis() @@ -553,7 +550,8 @@ def _set_lim_and_transforms(self): """ set the dataLim and viewLim BBox attributes and the - transData and transAxes Transformation attributes + transScale, transData, transLimits and transAxes + transformations. """ self.dataLim = mtransforms.Bbox.unit() self.viewLim = mtransforms.Bbox.unit() @@ -579,27 +577,105 @@ self.axes.transAxes, self.axes.transData) def get_xaxis_transform(self): + """ + Get the transformation used for drawing x-axis labels, ticks + and gridlines. The x-direction is in data coordinates and the + y-direction is in axis coordinates. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return self._xaxis_transform def get_xaxis_text1_transform(self, pad_pixels): + """ + Get the transformation used for drawing x-axis labels, which + will add the given number of pad_pixels between the axes and + the label. The x-direction is in data coordinates and the + y-direction is in axis coordinates. Returns a 3-tuple of the + form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._xaxis_transform + mtransforms.Affine2D().translate(0, -1 * pad_pixels), "top", "center") def get_xaxis_text2_transform(self, pad_pixels): + """ + Get the transformation used for drawing the secondary x-axis + labels, which will add the given number of pad_pixels between + the axes and the label. The x-direction is in data + coordinates and the y-direction is in axis coordinates. + Returns a 3-tuple of the form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._xaxis_transform + mtransforms.Affine2D().translate(0, pad_pixels), "bottom", "center") def get_yaxis_transform(self): + """ + Get the transformation used for drawing y-axis labels, ticks + and gridlines. The x-direction is in axis coordinates and the + y-direction is in data coordinates. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return self._yaxis_transform def get_yaxis_text1_transform(self, pad_pixels): + """ + Get the transformation used for drawing y-axis labels, which + will add the given number of pad_pixels between the axes and + the label. The x-direction is in axis coordinates and the + y-direction is in data coordinates. Returns a 3-tuple of the + form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._yaxis_transform + mtransforms.Affine2D().translate(-1 * pad_pixels, 0), "center", "right") def get_yaxis_text2_transform(self, pad_pixels): + """ + Get the transformation used for drawing the secondary y-axis + labels, which will add the given number of pad_pixels between + the axes and the label. The x-direction is in axis + coordinates and the y-direction is in data coordinates. + Returns a 3-tuple of the form: + + (transform, valign, halign) + + where valign and halign are requested alignments for the text. + + This transformation is primarily used by the Axis class, and + is meant to be overridden by new kinds of projections that may + need to place axis elements in different locations. + """ return (self._yaxis_transform + mtransforms.Affine2D().translate(pad_pixels, 0), "center", "left") @@ -610,11 +686,11 @@ self.xaxis.get_transform(), self.yaxis.get_transform())) def get_position(self, original=False): - 'Return the axes rectangle left, bottom, width, height' + 'Return the a copy of the axes rectangle as a Bbox' if original: - return self._originalPosition + return self._originalPosition.frozen() else: - return self._position + return self._position.frozen() def set_position(self, pos, which='both'): @@ -639,7 +715,6 @@ if which in ('both', 'original'): self._originalPosition.set(pos) - def _set_artist_props(self, a): 'set the boilerplate props for artists added to axes' a.set_figure(self.figure) @@ -648,6 +723,16 @@ a.axes = self def get_axes_patch(self): + """ + Returns the patch used to draw the background of the axes. It + is also used as the clipping path for any data elements on the + axes. + + In the standard axes, this is a rectangle, but in other + projections it may not be. + + Intended to be overridden by new projection types. + """ return mpatches.Rectangle((0.0, 0.0), 1.0, 1.0) def cla(self): @@ -806,6 +891,12 @@ ', '.join(mtransforms.BBox.coefs.keys())) def get_data_ratio(self): + """ + Returns the aspect ratio of the raw data. + + This method is intended to be overridden by new projection + types. + """ xmin,xmax = self.get_xbound() xsize = max(math.fabs(xmax-xmin), 1e-30) ymin,ymax = self.get_ybound() @@ -1032,6 +1123,7 @@ a.set_axes(self) self.artists.append(a) self._set_artist_props(a) + # MGDTODO: We may not want to do this -- the old trunk didn't a.set_clip_path(self.axesPatch) a._remove_method = lambda h: self.artists.remove(h) @@ -1074,19 +1166,20 @@ self._update_patch_limits(p) self.patches.append(p) p._remove_method = lambda h: self.patches.remove(h) - + def _update_patch_limits(self, p): 'update the datalimits for patch p' - xys = self._get_verts_in_data_coords( - p.get_data_transform(), - p.get_patch_transform().transform(p.get_path().vertices)) - self.update_datalim(xys) + vertices = p.get_patch_transform().transform(p.get_path().vertices) + if p.get_data_transform() != self.transData: + transform = p.get_data_transform() + self.transData.inverted() + xys = transform.transform(vertices) + self.update_datalim(vertices) - def add_table(self, tab): 'Add a table instance to the list of axes tables' self._set_artist_props(tab) self.tables.append(tab) + # MGDTODO: We may not want to do this (the old version in trunk didn't) tab.set_clip_path(self.axesPatch) tab._remove_method = lambda h: self.tables.remove(h) @@ -1105,8 +1198,6 @@ # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata - # MGDTODO: This isn't always the most efficient way to do this... in - # some cases things should use update_datalim_bounds if not ma.isMaskedArray(xys): xys = npy.asarray(xys) self.update_datalim_numerix(xys[:, 0], xys[:, 1]) @@ -1117,7 +1208,6 @@ # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata - ## self.dataLim.update_numerix(x, y, -1) self.dataLim.update_from_data(x, y, self.ignore_existing_data_limits) self.ignore_existing_data_limits = False @@ -1125,16 +1215,6 @@ '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: - return xys - # data is not in axis data units. We must transform it to - # display and then back to data to get it in data units - #xys = trans.seq_xy_tups(xys) - #return [ self.transData.inverse_xy_tup(xy) for xy in xys] - xys = trans.transform(npy.asarray(xys)) - return self.transData.inverted().transform(xys) - def _process_unit_info(self, xdata=None, ydata=None, kwargs=None): 'look for unit kwargs and update the axis instances as necessary' @@ -1162,7 +1242,7 @@ self.yaxis.set_units(yunits) def in_axes(self, mouseevent): - 'return True is the point xwin, ywin (display coords) are in the Axes' + 'return True if the given mouseevent (in display coords) is in the Axes' return self.axesPatch.contains(mouseevent)[0] def get_autoscale_on(self): @@ -1268,11 +1348,11 @@ if self.axison and self._frameon: artists.append(self.axesFrame) - dsu = [ (a.zorder, a) for a in artists + dsu = [ (a.zorder, i, a) for i, a in enumerate(artists) if not a.get_animated() ] dsu.sort() - for zorder, a in dsu: + for zorder, i, a in dsu: a.draw(renderer) renderer.close_group('axes') @@ -1474,16 +1554,10 @@ self.set_xlim(upper, lower) def get_xlim(self): - """Get the x-axis range [xmin, xmax] - - NOTE: The returned values are always [xmin, xmax] such that - xmin < xmax; regardless of whether or not the axes are inverted. """ - bound1, bound2 = self.viewLim.intervalx - if ( self._invertedx ): - return bound2, bound1 - else: - return bound1, bound2 + Get the x-axis range [xmin, xmax] + """ + return self.viewLim.intervalx def set_xlim(self, xmin=None, xmax=None, emit=True, **kwargs): """ @@ -1637,16 +1711,10 @@ self.set_ylim(upper, lower) def get_ylim(self): - """Get the y-axis range [xmin, xmax] - - NOTE: The returned values are always [ymin, ymax] such that - ymin < ymax; regardless of whether or not the axes are inverted. """ - bound1, bound2 = self.viewLim.intervaly - if ( self._invertedy ): - return bound2, bound1 - else: - return bound1, bound2 + Get the y-axis range [xmin, xmax] + """ + return self.viewLim.intervaly def set_ylim(self, ymin=None, ymax=None, emit=True, **kwargs): """ @@ -1812,8 +1880,10 @@ def format_coord(self, x, y): 'return a format string formatting the x, y coord' - if x is None or y is None: - return '' + if x is None: + x = '???' + if y is None: + y = '???' xs = self.format_xdata(x) ys = self.format_ydata(y) return 'x=%s, y=%s'%(xs,ys) @@ -1855,6 +1925,17 @@ self._navigate_mode = b def start_pan(self, x, y, button): + """ + Called when a pan operation has started. + + x, y are the mouse coordinates in display coords. + button is the mouse button number: + 1: LEFT + 2: MIDDLE + 3: RIGHT + + Intended to be overridden by new projection types. + """ self._pan_start = cbook.Bunch( lim = self.viewLim.frozen(), trans = self.transData.frozen(), @@ -1864,9 +1945,29 @@ ) def end_pan(self): + """ + Called when a pan operation completes (when the mouse button + is up.) + + Intended to be overridden by new projection types. + """ del self._pan_start def drag_pan(self, button, key, x, y): + """ + Called when the mouse moves during a pan operation. + + button is the mouse button number: + 1: LEFT + 2: MIDDLE + 3: RIGHT + + key is a "shift" key + + x, y are the mouse coordinates in display coords. + + Intended to be overridden by new projection types. + """ def format_deltas(key, dx, dy): if key=='control': if(abs(dx)>abs(dy)): @@ -2223,7 +2324,7 @@ %(Annotation)s """ a = mtext.Annotation(*args, **kwargs) - a.set_transform(mtransforms.Affine2D()) + a.set_transform(mtransforms.IdentityTransform()) self._set_artist_props(a) if kwargs.has_key('clip_on'): a.set_clip_path(self.axesPatch) self.texts.append(a) @@ -4035,9 +4136,9 @@ if len(sh) == 1 and sh[0] == len(x): colors = None # use cmap, norm after collection is created else: - colors = mcolors.colorConverter.to_rgba_list(c, alpha) + colors = mcolors.colorConverter.to_rgba_array(c, alpha) else: - colors = mcolors.colorConverter.to_rgba_list(c, alpha) + colors = mcolors.colorConverter.to_rgba_array(c, alpha) if not iterable(s): scales = (s,) @@ -4137,7 +4238,7 @@ offsets = zip(x,y), transOffset = self.transData, ) - collection.set_transform(mtransforms.Affine2D()) + collection.set_transform(mtransforms.IdentityTransform()) collection.set_alpha(alpha) collection.update(kwargs) @@ -4198,6 +4299,9 @@ quiverkey.__doc__ = mquiver.QuiverKey.quiverkey_doc def quiver(self, *args, **kw): + """ + MGDTODO: Document me + """ q = mquiver.Quiver(self, *args, **kw) self.add_collection(q, False) self.update_datalim_numerix(q.X, q.Y) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/axis.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -14,7 +14,7 @@ from font_manager import FontProperties from text import Text, TextWithDash from transforms import Affine2D, Bbox, blended_transform_factory, \ - interval_contains + IdentityTransform, interval_contains from patches import bbox_artist from scale import scale_factory @@ -113,6 +113,7 @@ self.tick1line.set_clip_path(clippath, transform) self.tick2line.set_clip_path(clippath, transform) self.gridline.set_clip_path(clippath, transform) + set_clip_path.__doc__ = Artist.set_clip_path.__doc__ def contains(self, mouseevent): """Test whether the mouse event occured in the Tick marks. @@ -1015,7 +1016,7 @@ horizontalalignment='center', ) label.set_transform( blended_transform_factory( - self.axes.transAxes, Affine2D() )) + self.axes.transAxes, IdentityTransform() )) self._set_artist_props(label) self.label_position='bottom' @@ -1030,7 +1031,7 @@ horizontalalignment='right', ) offsetText.set_transform( blended_transform_factory( - self.axes.transAxes, Affine2D() )) + self.axes.transAxes, IdentityTransform() )) self._set_artist_props(offsetText) self.offset_text_position='bottom' return offsetText @@ -1092,11 +1093,11 @@ def set_ticks_position(self, position): """ - Set the ticks position (top, bottom, both or default) - both sets the ticks to appear on both positions, but - does not change the tick labels. - default resets the tick positions to the default: - ticks on both positions, labels at bottom. + Set the ticks position (top, bottom, both, default or none) + both sets the ticks to appear on both positions, but does not + change the tick labels. default resets the tick positions to + the default: ticks on both positions, labels at bottom. none + can be used if you don't want any ticks. ACCEPTS: [ 'top' | 'bottom' | 'both' | 'default' | 'none' ] """ @@ -1225,7 +1226,7 @@ rotation='vertical', ) label.set_transform( blended_transform_factory( - Affine2D(), self.axes.transAxes) ) + IdentityTransform(), self.axes.transAxes) ) self._set_artist_props(label) self.label_position='left' @@ -1240,7 +1241,7 @@ horizontalalignment = 'left', ) offsetText.set_transform(blended_transform_factory( - self.axes.transAxes, Affine2D()) ) + self.axes.transAxes, IdentityTransform()) ) self._set_artist_props(offsetText) self.offset_text_position='left' return offsetText Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -73,7 +73,7 @@ offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds): path, transform = path_id - transform = transform.frozen().translate(xo, yo) + transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo) self.draw_path(gc, path, transform, rgbFace) def _iter_collection_raw_paths(self, master_transform, paths, all_transforms): @@ -200,6 +200,27 @@ """ return False + def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!'): + raise NotImplementedError + + def draw_text(self, gc, x, y, s, prop, angle, ismath=False): + """ + Draw the text.Text instance s at x,y (display coords) with font + properties instance prop at angle in degrees, using GraphicsContext gc + + **backend implementers note** + + When you are trying to determine if you have gotten your bounding box + right (which is what enables the text layout/alignment to work + properly), it helps to change the line in text.py + + if 0: bbox_artist(self, renderer) + + to if 1, and then the actual bounding box will be blotted along with + your text. + """ + raise NotImplementedError + def flipy(self): """return true if y small numbers are top for renderer Is used for drawing text (text.py) and images (image.py) only @@ -386,7 +407,8 @@ def set_clip_path(self, path): """ - Set the clip path and transformation + Set the clip path and transformation. Path should be a + transforms.TransformedPath instance. """ assert path is None or isinstance(path, transforms.TransformedPath) self._clippath = path Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -205,7 +205,7 @@ 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) + transform = Affine2D(transform.get_matrix()).scale(1.0, -1.0) d = self._convert_path(path, transform) write('<path id="%s" d="%s"/>\n' % (name, d)) path_codes.append(name) Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -83,12 +83,12 @@ if antialiaseds is None: antialiaseds = (mpl.rcParams['patch.antialiased'],) self.set_linestyles(linestyles) - self._facecolors = _colors.colorConverter.to_rgba_list(facecolors) + self._facecolors = _colors.colorConverter.to_rgba_array(facecolors) if edgecolors == 'None': self._edgecolors = self._facecolors linewidths = (0,) else: - self._edgecolors = _colors.colorConverter.to_rgba_list(edgecolors) + self._edgecolors = _colors.colorConverter.to_rgba_array(edgecolors) self._linewidths = self._get_value(linewidths) self._antialiaseds = self._get_value(antialiaseds) @@ -268,7 +268,7 @@ ACCEPTS: matplotlib color arg or sequence of rgba tuples """ - self._facecolors = _colors.colorConverter.to_rgba_list(c, self._alpha) + self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha) set_facecolors = set_facecolor @@ -284,7 +284,7 @@ self._linewidths = (0.0,) self._edgecolors = npy.array([]) else: - self._edgecolors = _colors.colorConverter.to_rgba_list(c) + self._edgecolors = _colors.colorConverter.to_rgba_array(c) set_edgecolors = set_edgecolor def set_alpha(self, alpha): @@ -581,7 +581,7 @@ if antialiaseds is None: antialiaseds = (mpl.rcParams['lines.antialiased'],) self.set_linestyles(linestyles) - colors = _colors.colorConverter.to_rgba_list(colors) + colors = _colors.colorConverter.to_rgba_array(colors) Collection.__init__( self, @@ -633,7 +633,7 @@ ACCEPTS: matplotlib color arg or sequence of rgba tuples """ - self._edgecolors = _colors.colorConverter.to_rgba_list(c) + self._edgecolors = _colors.colorConverter.to_rgba_array(c) def color(self, c): """ Modified: branches/transforms/lib/matplotlib/colors.py =================================================================== --- branches/transforms/lib/matplotlib/colors.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/colors.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -307,12 +307,13 @@ except (TypeError, ValueError), exc: raise ValueError('to_rgba: Invalid rgba arg "%s"\n%s' % (str(arg), exc)) - def to_rgba_list(self, c, alpha=None): + def to_rgba_array(self, c, alpha=None): """ - Returns a list of rgba tuples. + Returns an Numpy array of rgba tuples. Accepts a single mpl color spec or a sequence of specs. - If the sequence is a list, the list items are changed in place. + If the sequence is a list or array, the items are changed in place, + but an array copy is still returned. """ try: result = [self.to_rgba(c, alpha)] @@ -320,7 +321,7 @@ # If c is a list it must be maintained as the same list # with modified items so that items can be appended to # it. This is needed for examples/dynamic_collections.py. - if not isinstance(c, list): # specific; don't need duck-typing + if not isinstance(c, (list, npy.ndarray)): # specific; don't need duck-typing c = list(c) for i, cc in enumerate(c): c[i] = self.to_rgba(cc, alpha) # change in place Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/legend.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -363,15 +363,6 @@ bbox.update_from_data_xy(averts, True) bboxes.append(bbox) - for handle in ax.collections: - if isinstance(handle, LineCollection): - hlines = handle.get_lines() - trans = handle.get_transform() - for line in hlines: - tline = trans.seq_xy_tups(line) - aline = [inv(v) for v in tline] - lines.append(aline) - return [vertices, bboxes, lines] def draw_frame(self, b): Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/lines.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -71,6 +71,45 @@ 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', @@ -276,7 +315,6 @@ else: pixels = self.figure.dpi/72. * self.pickradius - path, transform = self._transformed_path.get_transformed_path_and_affine() if self._linestyle == 'None': # If no line, return the nearby point(s) d = npy.sqrt((xt-mouseevent.x)**2 + (yt-mouseevent.y)**2) @@ -320,7 +358,7 @@ # correct for marker size, if any if self._marker is not None: ms = (self._markersize / 72.0 * self.figure.dpi) * 0.5 - bbox = Bbox(bbox.get_points() + [[-ms, -ms], [ms, ms]]) + bbox = bbox.padded(ms) return bbox def set_axes(self, ax): @@ -399,7 +437,7 @@ """ set the Transformation instance used by this artist - ACCEPTS: a matplotlib.transform transformation instance + ACCEPTS: a matplotlib.transforms.Transform instance """ Artist.set_transform(self, t) self._transformed_path = TransformedPath(self._path, self.get_transform()) Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/patches.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -82,7 +82,7 @@ Returns T/F, {} """ - # This is a general version of contains should work on any + # This is a general version of contains that should work on any # patch with a path. However, patches that have a faster # algebraic solution to hit-testing should override this # method. @@ -290,8 +290,8 @@ Patch.__init__(self) self.patch = patch self.props = props - self.ox, self.oy = ox, oy - self._shadow_transform = transforms.Affine2D().translate(self.ox, self.oy) + self._ox, self._oy = ox, oy + self._update_transform() self._update() __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd @@ -308,7 +308,22 @@ self.set_facecolor((r,g,b,0.5)) self.set_edgecolor((r,g,b,0.5)) - + + def _update_transform(self): + self._shadow_transform = transforms.Affine2D().translate(self._ox, self._oy) + + def _get_ox(self): + return self._ox + def _set_ox(self, ox): + self._ox = ox + self._update_transform() + + def _get_oy(self): + return self._oy + def _set_oy(self, oy): + self._oy = oy + self._update_transform() + def get_path(self): return self.patch.get_path() Modified: branches/transforms/lib/matplotlib/widgets.py =================================================================== --- branches/transforms/lib/matplotlib/widgets.py 2007-10-29 15:20:13 UTC (rev 4052) +++ branches/transforms/lib/matplotlib/widgets.py 2007-10-29 15:21:49 UTC (rev 4053) @@ -849,7 +849,7 @@ self.prev = (0, 0) if self.direction == 'horizontal': - trans = (self.ax.transData, self.ax.transAxes) + trans = blended_transform_factory(self.ax.transData, self.ax.transAxes) w,h = 0,1 else: trans = blended_transform_factory(self.ax.transAxes, self.ax.transData) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 16:55:57
|
Revision: 4054 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4054&view=rev Author: mdboom Date: 2007-10-29 09:55:53 -0700 (Mon, 29 Oct 2007) Log Message: ----------- More examples working. Modified Paths: -------------- branches/transforms/PASSED_DEMOS branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/ticker.py Modified: branches/transforms/PASSED_DEMOS =================================================================== --- branches/transforms/PASSED_DEMOS 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/PASSED_DEMOS 2007-10-29 16:55:53 UTC (rev 4054) @@ -209,4 +209,20 @@ zoom_window.py O zorder_demo.py O -MGDTODO: units directory \ No newline at end of file + +units directory ----- + +annotate_with_units.py O +artist_tests.py O +bar_demo2.py O +bar_unit_demo.py [BROKEN IN TRUNK] +basic_units.py [N/A] +date_converter.py O +date_support.py [N/A] +ellipse_with_units.py [BROKEN IN TRUNK] +evans_test2.py O +evans_test.py O +__init__.py [N/A] +radian_demo.py O +units_sample.py O +units_scatter.py Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/lib/matplotlib/collections.py 2007-10-29 16:55:53 UTC (rev 4054) @@ -16,7 +16,7 @@ import matplotlib.transforms as transforms import matplotlib.artist as artist import matplotlib.backend_bases as backend_bases -import matplotlib.path as path +import matplotlib.path as mpath class Collection(artist.Artist, cm.ScalarMappable): """ @@ -136,7 +136,7 @@ offsets = transOffset.transform_non_affine(offsets) transOffset = transOffset.get_affine() - result = path.get_path_collection_extents( + result = mpath.get_path_collection_extents( transform.frozen(), paths, self.get_transforms(), npy.asarray(offsets, npy.float_), transOffset.frozen()) result = result.inverse_transformed(transData) @@ -154,15 +154,19 @@ paths = [] for path in self._paths: vertices = path.vertices - xs, ys = zip(*segment) + xs, ys = vertices[:, 0], vertices[:, 1] xs = self.convert_xunits(xs) ys = self.convert_yunits(ys) - paths.append(path.Path(zip(xs, ys), path.codes)) + paths.append(mpath.Path(zip(xs, ys), path.codes)) if self._offsets is not None: xs = self.convert_xunits(self._offsets[:0]) ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - + if len(offsets) == 0: + offsets = npy.zeros((1, 2)) + else: + offsets = npy.asarray(offsets, npy.float_) + self.update_scalarmappable() clippath, clippath_trans = self.get_transformed_clip_path_and_affine() @@ -179,7 +183,7 @@ renderer.draw_path_collection( transform.frozen(), self.clipbox, clippath, clippath_trans, paths, self.get_transforms(), - npy.asarray(offsets, npy.float_), transOffset, + offsets, transOffset, self._facecolors, self._edgecolors, self._linewidths, self._linestyles, self._antialiaseds) renderer.close_group(self.__class__.__name__) @@ -198,7 +202,7 @@ paths = [transform.transform_path_non_affine(path) for path in paths] transform = transform.get_affine() - ind = path.point_in_path_collection( + ind = mpath.point_in_path_collection( mouseevent.x, mouseevent.y, self._pickradius, transform.frozen(), paths, self.get_transforms(), npy.asarray(self._offsets, npy.float_), @@ -372,7 +376,7 @@ (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on. """ def __init__(self, meshWidth, meshHeight, coordinates, showedges): - Path = path.Path + Path = mpath.Path Collection.__init__(self) self._meshWidth = meshWidth @@ -426,7 +430,7 @@ def set_verts(self, verts): '''This allows one to delay initialization of the vertices.''' - self._paths = [path.Path(v, closed=True) for v in verts] + self._paths = [mpath.Path(v, closed=True) for v in verts] def get_paths(self): return self._paths @@ -450,7 +454,7 @@ __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd class RegularPolyCollection(Collection): - _path_generator = path.Path.unit_regular_polygon + _path_generator = mpath.Path.unit_regular_polygon def __init__(self, dpi, @@ -510,11 +514,11 @@ class StarPolygonCollection(RegularPolyCollection): - _path_generator = path.Path.unit_regular_star + _path_generator = mpath.Path.unit_regular_star class AsteriskPolygonCollection(RegularPolyCollection): - _path_generator = path.Path.unit_regular_asterisk + _path_generator = mpath.Path.unit_regular_asterisk class LineCollection(Collection, cm.ScalarMappable): @@ -604,10 +608,10 @@ def set_segments(self, segments): if segments is None: return - segments = [npy.asarray(seg, npy.float_) for seg in segments] + segments = [npy.asarray([[y.get_value() for y in x] for x in seg], npy.float_) for seg in segments] if self._uniform_offsets is not None: segments = self._add_offsets(segments) - self._paths = [path.Path(seg, closed=False) for seg in segments] + self._paths = [mpath.Path(seg, closed=False) for seg in segments] set_verts = set_segments # for compatibility with PolyCollection Modified: branches/transforms/lib/matplotlib/ticker.py =================================================================== --- branches/transforms/lib/matplotlib/ticker.py 2007-10-29 15:21:49 UTC (rev 4053) +++ branches/transforms/lib/matplotlib/ticker.py 2007-10-29 16:55:53 UTC (rev 4054) @@ -615,7 +615,7 @@ def __call__(self): 'Return the locations of the ticks' - dmin, dmax = self.dataInterval.get_bounds() + dmin, dmax = self.axis.get_data_interval() return npy.arange(dmin + self.offset, dmax+1, self._base) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 17:31:40
|
Revision: 4055 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4055&view=rev Author: mdboom Date: 2007-10-29 10:31:24 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Massive CHANGELOG and API_CHANGES entries about this refactoring. Modified Paths: -------------- branches/transforms/API_CHANGES branches/transforms/CHANGELOG Modified: branches/transforms/API_CHANGES =================================================================== --- branches/transforms/API_CHANGES 2007-10-29 16:55:53 UTC (rev 4054) +++ branches/transforms/API_CHANGES 2007-10-29 17:31:24 UTC (rev 4055) @@ -1,3 +1,174 @@ +TRANSFORMS REFACTORING + + The primary goal of this refactoring was to make it easier to + extend matplotlib to support new kinds of projections. This is + primarily an internal improvement, and the possible user-visible + changes it allows are yet to come. + + See transforms.py for a description of the design of the new + transformation framework. + + The view intervals are now stored only in one place -- in the Axes + instance, not in the formatter instances as well. This means + formatters must get their limits from their Axis, which in turn + looks up its limits from the Axes. If a Locator is used + temporarily and not assigned to an Axis or Axes, (e.g. in + contour.py), a dummy axis must be created to store its bounds. + Call Locator.create_dummy_axis() to do so. + + The functionality of Pbox has been merged with Bbox. Its methods + now all return copies rather than modifying in place. + + The following lists many of the simple changes necessary to update + code from the old transformation framework to the new one. In + particular, methods that return a copy are named with a verb in + the past tense, whereas methods that alter an object in place are + named with a very in the present tense. + + transforms.py + Bbox.get_bounds() Bbox.bounds + + Bbox.width() Bbox.width + + Bbox.height() Bbox.height + + Bbox.intervalx().get_bounds() Bbox.intervalx + Bbox.intervalx().set_bounds() + [Bbox.intervalx is now a property.] + + Bbox.intervaly().get_bounds() Bbox.intervaly + Bbox.intervaly().set_bounds() + [Bbox.intervaly is now a property.] + + Bbox.xmin() Bbox.x0 or Bbox.xmin + Bbox.ymin() Bbox.y0 or Bbox.ymin + Bbox.xmax() Bbox.x1 or Bbox.xmax + Bbox.ymax() Bbox.y1 or Bbox.ymax + [The Bbox is bound by the points (x0, y0) to (x1, y1) and + there is no defined order to these points, that is, x0 is not + necessarily the left edge of the box. To get the left edge of + the Bbox, use the read-only property xmin.] + + Bbox.overlaps(bboxes) Bbox.count_overlaps(bboxes) + + bbox_all(bboxes) Bbox.union(bboxes) + [Bbox.union is a staticmethod.] + + lbwh_to_bbox(l, b, w, h) Bbox.from_bounds(x0, y0, w, h) + + inverse_transform_bbox(trans, bbox) bbox.inverse_transformed(trans) + + Interval.contains_open(v) interval_contains_open(tuple, v) + Interval.contains(v) interval_contains_open(tuple, v) + + identity_transform() IdentityTransform() + + blend_xy_sep_transform(xtrans, ytrans) blended_transform_factory(xtrans, ytrans) + + scale_transform(xs, ys) Affine2D().scale(xs[, ys]) + + get_bbox_transform(boxin, boxout) BboxTransform(boxin, boxout) or + BboxTransformFrom(boxin) or + BboxTransformTo(boxout) + + Transform.seq_xy_tup(points) Transform.transform(points) + + Transform.inverse_xy_tup(points) Transform.inverted().transform(points) + + axes.py + Axes.get_position() Axes.get_position() + [Axes.get_position() used to return a list of points, not it + returns a transforms.Bbox instance.] + + Axes.set_position() Axes.set_position() + [Axes.set_position() now accepts either four scalars or a + transforms Bbox instance.] + + [also returns a Bbox] + Axes.toggle_log_lineary() Axes.set_yscale() + [Since the recfactoring allows for more than two scale types + ('log' or 'linear'), it no longer makes sense to have a + toggle. Axes.toggle_log_lineary() has been removed.] + + Axes.hlines(linestyle=) Axes.hlines(linestyles=) + Axes.vlines(linestyle=) Axes.vlines(linestyles=) + [The kwarg 'linestyle' has been replaced with 'linestyles', + which accepts either a single linestyle or a list of + linestyles to use.] + + Subplot class is gone -- now there is only SubplotBase. + + The Polar class has moved to projections/polar.py + + artist.py + Artist.set_clip_path(path) Artist.set_clip_path(path, transform) + [set_clip_path now accepts a path.Path instance and a + transformation that will be applied to the path immediately + before clipping.] + + collections.py + linestyle linestyles + [Linestyles are now treated like all other collection + attributes -- a single value or multiple values may be + provided.] + + colors.py + ColorConvertor.to_rgba_list(c) ColorConvertor.to_rgba_array(c) + [ColorConvertor.to_rgba_array(c) returns an Nx4 Numpy array of + RGBA color quadruples.] + + contour.py + Contour._segments Contour.get_paths() + [Contour.get_paths() now returns a list of path.Path instances.] + + figure.py + Figure.dpi.get()/set() Figure.dpi (a property) + + patches.py + get_verts() get_path() + [Patch.get_path() returns a path.Path instance.] + + backend_bases.py + GraphicsContext.set_clip_rectangle(tuple) GraphicsContext.set_clip_rectangle(bbox) + + GraphicsContext.get_clip_path() GraphicsContext.get_clip_path() + [GraphicsContext.get_clip_path() returns a tuple of the form + (path, affine_transform), where path is a path.Path instance + and affine_transform is a transforms.Affine2D instance.] + + GraphicsContext.set_clip_path(clippath) GraphicsContext.set_clip_path(clippath) + [Now accepts only an instance of transforms.TransformedPath.] + + RendererBase class: + **new methods** ---> + draw_path(self, gc, path, transform, rgbFace) + + draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace) + + draw_path_collection(self, master_transform, cliprect, clippath, + clippath_trans, paths, all_transforms, offsets, + offsetTrans, facecolors, edgecolors, linewidths, + linestyles, antialiaseds) [optional] + + + **changed methods** ---> + draw_image(self, x, y, im, bbox) draw_image(self, x, y, im, bbox, + clippath, clippath_trans) + + **removed methods** ---> + draw_arc + draw_line_collection + draw_line + draw_lines + draw_point + draw_quad_mesh + draw_poly_collection + draw_polygon + draw_rectangle + draw_regpoly_collection + +END OF TRANSFORMS REFACTORING + 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 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-10-29 16:55:53 UTC (rev 4054) +++ branches/transforms/CHANGELOG 2007-10-29 17:31:24 UTC (rev 4055) @@ -1,3 +1,73 @@ +2007-10-29 TRANSFORMS REFACTORING + + The primary goal of this refactoring was to make it easier + to extend matplotlib to support new kinds of projections. + This is primarily an internal improvement, and the possible + user-visible changes it allows are yet to come. + + The transformation framework was completely rewritten in + Python (with Numpy). This will make it easier to add news + kinds of transformations without writing C/C++ code. + + Transforms are composed into a 'transform tree', made of + transforms whose value depends on other transforms (their + children). When the contents of children change, their + parents are automatically updated to reflect those changes. + To do this an "invalidation" method is used: when children + change, all of their ancestors are marked as "invalid". + When the value of a transform is accessed at a later time, + its value is recomputed only if it is invalid, otherwise a + cached value may be used. This prevents unnecessary + recomputations of transforms, and contributes to better + interactive performance. + + The framework can be used for both affine and non-affine + transformations. However, for speed, we want use the + backend renderers to perform affine transformations + whenever possible. Therefore, it is possible to perform + just the affine or non-affine part of a transformation on a + set of data. The affine is always assumed to occur after + the non-affine. For any transform: + + full transform == non-affine + affine + + Much of the drawing has been refactored in terms of + compound paths. Therefore, many methods have been removed + from the backend interface and replaced with a a handful to + draw compound paths. This will make updating the backends + easier, since there is less to update. It also should make + the backends more consistent in terms of functionality. + + User visible changes: + + - POLAR PLOTS: Polar plots are now interactively zoomable, + and the r-axis labels can be interactively rotated. + Straight line segments are now interpolated to follow the + curve of the r-axis. + + - Non-rectangular clipping works in more backends and with + more types of objects. + + - Sharing an axis across figures is now done in exactly + the same way as sharing an axis between two axes in the + same figure: + + fig1 = figure() + fig2 = figure() + + ax1 = fig1.add_subplot(111) + ax2 = fig2.add_subplot(111, sharex=ax1, sharey=ax1) + + - linestyles now include steps-pre, steps-post and + steps-mid. The old step still works and is equivalent to + step-pre. + + - Multiple line styles may be provided to a collection. + + See API_CHANGES for more low-level information about this + refactoring. + + 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-10-29 18:23:41
|
Revision: 4059 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4059&view=rev Author: mdboom Date: 2007-10-29 11:23:24 -0700 (Mon, 29 Oct 2007) Log Message: ----------- Merged revisions 4001-4058 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4020 | mdboom | 2007-10-26 14:44:16 -0400 (Fri, 26 Oct 2007) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-3806" from https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/transforms ........ r4039 | jdh2358 | 2007-10-28 11:18:02 -0400 (Sun, 28 Oct 2007) | 1 line added time series to specgram ........ r4046 | mdboom | 2007-10-29 10:30:51 -0400 (Mon, 29 Oct 2007) | 3 lines Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. ........ r4047 | mdboom | 2007-10-29 10:44:18 -0400 (Mon, 29 Oct 2007) | 4 lines Fixing bug in font rendering -- the patented freetype hinter appears to be unable to deal with the non-square hinting grid hack. [Forgot this file]. ........ r4057 | mdboom | 2007-10-29 13:47:10 -0400 (Mon, 29 Oct 2007) | 2 lines Improve the code coverage of backend_driver.py ........ Modified Paths: -------------- branches/transforms/examples/specgram_demo.py branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/src/ft2font.cpp Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4000 + /trunk/matplotlib:1-4058 Modified: branches/transforms/examples/specgram_demo.py =================================================================== --- branches/transforms/examples/specgram_demo.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/examples/specgram_demo.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -21,6 +21,9 @@ # the frequency vector, bins are the centers of the time bins in which # the power is computed, and im is the matplotlib.image.AxesImage # instance + +ax1 = subplot(211) +plot(t, x) +subplot(212, sharex=ax1) Pxx, freqs, bins, im = specgram(x, NFFT=NFFT, Fs=Fs, noverlap=900) -colorbar() show() Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -82,7 +82,7 @@ from matplotlib.cbook import enumerate, is_string_like, exception_to_str from matplotlib.figure import Figure from matplotlib.font_manager import findfont -from matplotlib.ft2font import FT2Font, LOAD_DEFAULT +from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT from matplotlib.mathtext import MathTextParser from matplotlib.path import Path from matplotlib.transforms import Affine2D, Bbox @@ -147,11 +147,11 @@ font = self._get_agg_font(prop) if font is None: return None if len(s) == 1 and ord(s) > 127: - font.load_char(ord(s), flags=LOAD_DEFAULT) + font.load_char(ord(s), flags=LOAD_FORCE_AUTOHINT) else: # We pass '0' for angle here, since it will be rotated (in raster # space) in the following call to draw_text_image). - font.set_text(s, 0, flags=LOAD_DEFAULT) + font.set_text(s, 0, flags=LOAD_FORCE_AUTOHINT) font.draw_glyphs_to_bitmap() #print x, y, int(x), int(y) @@ -181,7 +181,7 @@ self.mathtext_parser.parse(s, self.dpi, prop) return width, height, descent font = self._get_agg_font(prop) - font.set_text(s, 0.0, flags=LOAD_DEFAULT) # the width and height of unrotated string + font.set_text(s, 0.0, flags=LOAD_FORCE_AUTOHINT) # the width and height of unrotated string w, h = font.get_width_height() d = font.get_descent() w /= 64.0 # convert from subpixels Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-10-29 18:23:24 UTC (rev 4059) @@ -141,7 +141,7 @@ from matplotlib.afm import AFM from matplotlib.cbook import Bunch, get_realpath_and_stat, \ is_string_like -from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_DEFAULT, LOAD_NO_HINTING +from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING from matplotlib.font_manager import findfont, FontProperties from matplotlib._mathtext_data import latex_to_bakoma, \ latex_to_standard, tex2uni, tex2type1, uni2type1, \ @@ -304,7 +304,7 @@ self.fonts_object.get_used_characters()) def get_hinting_type(self): - return LOAD_DEFAULT + return LOAD_FORCE_AUTOHINT def MathtextBackendAgg(): return MathtextBackendBbox(MathtextBackendAggRender()) Modified: branches/transforms/src/ft2font.cpp =================================================================== --- branches/transforms/src/ft2font.cpp 2007-10-29 18:20:11 UTC (rev 4058) +++ branches/transforms/src/ft2font.cpp 2007-10-29 18:23:24 UTC (rev 4059) @@ -943,7 +943,7 @@ angle = angle/360.0*2*3.14159; - long flags = FT_LOAD_DEFAULT; + long flags = FT_LOAD_FORCE_AUTOHINT; if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); @@ -1054,7 +1054,7 @@ } char FT2Font::load_char__doc__[] = -"load_char(charcode, flags=LOAD_LOAD_DEFAULT)\n" +"load_char(charcode, flags=LOAD_FORCE_AUTOHINT)\n" "\n" "Load character with charcode in current fontfile and set glyph.\n" "The flags argument can be a bitwise-or of the LOAD_XXX constants.\n" @@ -1075,7 +1075,7 @@ //load a char using the unsigned long charcode args.verify_length(1); - long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_DEFAULT); + long charcode = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); if (kwargs.hasKey("flags")) flags = Py::Long(kwargs["flags"]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-06 20:02:18
|
Revision: 4135 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4135&view=rev Author: mdboom Date: 2007-11-06 12:02:07 -0800 (Tue, 06 Nov 2007) Log Message: ----------- Merged revisions 4059-4134 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4061 | jdh2358 | 2007-10-29 14:52:41 -0400 (Mon, 29 Oct 2007) | 2 lines fixed some examples bugs ........ r4062 | jdh2358 | 2007-10-29 15:00:25 -0400 (Mon, 29 Oct 2007) | 2 lines added cohere demo ........ r4072 | dsdale | 2007-10-31 15:43:54 -0400 (Wed, 31 Oct 2007) | 2 lines added STIX fonts ........ r4073 | dsdale | 2007-10-31 15:53:35 -0400 (Wed, 31 Oct 2007) | 2 lines add STIX license agreement ........ r4081 | efiring | 2007-11-01 03:21:00 -0400 (Thu, 01 Nov 2007) | 2 lines Made contour auto level generation work with log color scale ........ r4087 | dsdale | 2007-11-01 10:17:28 -0400 (Thu, 01 Nov 2007) | 2 lines install fonts/otf to mpl-data ........ r4088 | dsdale | 2007-11-01 10:32:52 -0400 (Thu, 01 Nov 2007) | 2 lines dont enable usetex in arrow_demo.py ........ r4092 | dsdale | 2007-11-01 12:56:33 -0400 (Thu, 01 Nov 2007) | 2 lines rm configtest.py from repository ........ r4093 | dsdale | 2007-11-01 12:57:26 -0400 (Thu, 01 Nov 2007) | 2 lines remove STIXFonts zip file ........ r4094 | dsdale | 2007-11-02 08:55:51 -0400 (Fri, 02 Nov 2007) | 2 lines improved ghostscript version checking ........ r4095 | jdh2358 | 2007-11-02 09:13:40 -0400 (Fri, 02 Nov 2007) | 2 lines added Manuel's contour linestyle patch ........ r4096 | dsdale | 2007-11-02 12:37:37 -0400 (Fri, 02 Nov 2007) | 3 lines commit patch 1599876, fixes to qt4agg backend and qt4 blitting demo. Thanks to Phil Thompson. ........ r4097 | jdh2358 | 2007-11-02 14:45:38 -0400 (Fri, 02 Nov 2007) | 2 lines fix unit changes for errorbar_limits code ........ r4106 | efiring | 2007-11-04 21:36:20 -0500 (Sun, 04 Nov 2007) | 2 lines Added easy access to minor tick properties (Pierre G-M) ........ r4107 | mdboom | 2007-11-05 10:45:00 -0500 (Mon, 05 Nov 2007) | 3 lines First pass at getting STIX fonts to work. Support .otf fonts in font_manager.py ........ r4110 | mdboom | 2007-11-05 12:30:08 -0500 (Mon, 05 Nov 2007) | 2 lines Make STIX fonts work. ........ r4112 | efiring | 2007-11-05 14:49:27 -0500 (Mon, 05 Nov 2007) | 2 lines Minor cleanup; removed old ipython hack. ........ r4113 | efiring | 2007-11-05 14:54:49 -0500 (Mon, 05 Nov 2007) | 2 lines make step_demo use npyma ........ r4114 | efiring | 2007-11-05 15:13:00 -0500 (Mon, 05 Nov 2007) | 2 lines Make safezip accept more args; quadmesh_demo cleanup ........ r4115 | mdboom | 2007-11-05 15:42:23 -0500 (Mon, 05 Nov 2007) | 2 lines Fix rcParams bug. ........ r4126 | mdboom | 2007-11-06 13:32:30 -0500 (Tue, 06 Nov 2007) | 3 lines Prevent errors when using OpenType CFF fonts. This means turning off subsetting on backend_pdf, and raising an exception in backend_ps. ........ r4130 | mdboom | 2007-11-06 14:38:29 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ r4131 | mdboom | 2007-11-06 14:38:57 -0500 (Tue, 06 Nov 2007) | 1 line Removing STIX otf fonts ........ r4132 | mdboom | 2007-11-06 14:39:23 -0500 (Tue, 06 Nov 2007) | 2 lines Converted STIX fonts from otf to ttf. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/examples/animation_blit_qt4.py branches/transforms/examples/arrow_demo.py branches/transforms/examples/backend_driver.py branches/transforms/examples/image_slices_viewer.py branches/transforms/examples/keypress_demo.py branches/transforms/examples/mathtext_examples.py branches/transforms/examples/quadmesh_demo.py branches/transforms/examples/step_demo.py branches/transforms/examples/units/bar_unit_demo.py branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/_mathtext_data.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backends/__init__.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/backends/backend_qt4agg.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/config/checkdep.py branches/transforms/lib/matplotlib/config/cutils.py branches/transforms/lib/matplotlib/config/mplconfig.py branches/transforms/lib/matplotlib/config/rcsetup.py branches/transforms/lib/matplotlib/contour.py branches/transforms/lib/matplotlib/font_manager.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/pyplot.py branches/transforms/lib/matplotlib/rcsetup.py branches/transforms/lib/matplotlib/text.py branches/transforms/matplotlibrc.template branches/transforms/setup.py Added Paths: ----------- branches/transforms/examples/cohere_demo.py branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/LICENSE_STIX branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneral.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXGeneralItalic.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUni.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXNonUniIta.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz1SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz2SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz3SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4Sym.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz4SymBol.ttf branches/transforms/lib/matplotlib/mpl-data/fonts/ttf/STIXSiz5Sym.ttf branches/transforms/license/LICENSE_STIX Removed Paths: ------------- branches/transforms/lib/matplotlib/config/configtest.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4058 + /trunk/matplotlib:1-4134 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/CHANGELOG 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,3 +1,9 @@ +2007-11-02 Commited Phil Thompson's patch 1599876, fixes to Qt4Agg + backend and qt4 blitting demo - DSD + +2007-10-31 Made log color scale easier to use with contourf; + automatic level generation now works. - EF + 2007-10-29 TRANSFORMS REFACTORING The primary goal of this refactoring was to make it easier @@ -66,7 +72,6 @@ See API_CHANGES for more low-level information about this refactoring. - 2007-10-24 Added ax kwarg to Figure.colorbar and pyplot.colorbar - EF Modified: branches/transforms/examples/animation_blit_qt4.py =================================================================== --- branches/transforms/examples/animation_blit_qt4.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/animation_blit_qt4.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -15,10 +15,14 @@ class BlitQT(QtCore.QObject): def __init__(self): - QtCore.QObject.__init__(self, None) - self.ax = p.subplot(111) self.canvas = self.ax.figure.canvas + + # By making this a child of the canvas we make sure that it is + # destroyed first and avoids a possible exception when the user clicks + # on the window's close box. + QtCore.QObject.__init__(self, self.canvas) + self.cnt = 0 # create the initial line @@ -26,9 +30,14 @@ self.line, = p.plot(self.x, npy.sin(self.x), animated=True, lw=2) self.background = None + self.old_size = 0, 0 def timerEvent(self, evt): - if self.background is None: + # See if the size has changed since last time round. + current_size = self.ax.bbox.width(), self.ax.bbox.height() + + if self.old_size != current_size: + self.old_size = current_size self.background = self.canvas.copy_from_bbox(self.ax.bbox) # restore the clean slate background Modified: branches/transforms/examples/arrow_demo.py =================================================================== --- branches/transforms/examples/arrow_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/arrow_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -11,7 +11,6 @@ """ from pylab import * -rc('text', usetex=True) rates_to_bases={'r1':'AT', 'r2':'TA', 'r3':'GA','r4':'AG','r5':'CA','r6':'AC', \ 'r7':'GT', 'r8':'TG', 'r9':'CT','r10':'TC','r11':'GC','r12':'CG'} numbered_bases_to_rates = dict([(v,k) for k, v in rates_to_bases.items()]) Modified: branches/transforms/examples/backend_driver.py =================================================================== --- branches/transforms/examples/backend_driver.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/backend_driver.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -32,9 +32,10 @@ 'barh_demo.py', 'color_demo.py', 'colorbar_only.py', + 'cohere_demo.py', 'contour_demo.py', 'contourf_demo.py', - 'csd_demo.py', + 'csd_demo.py', 'custom_ticker1.py', 'customize_rc.py', 'date_demo1.py', Copied: branches/transforms/examples/cohere_demo.py (from rev 4132, trunk/matplotlib/examples/cohere_demo.py) =================================================================== --- branches/transforms/examples/cohere_demo.py (rev 0) +++ branches/transforms/examples/cohere_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -0,0 +1,37 @@ +#!/usr/bin/env python +""" +Compute the coherence of two signals +""" +import numpy as n + +from pylab import figure, show + +dt = 0.01 +t = n.arange(0, 30, dt) +Nt = len(t) +nse1 = n.random.randn(Nt) # white noise 1 +nse2 = n.random.randn(Nt) # white noise 2 +r = n.exp(-t/0.05) + +cnse1 = n.convolve(nse1, r)*dt # colored noise 1 +cnse1 = cnse1[:Nt] +cnse2 = n.convolve(nse2, r)*dt # colored noise 2 +cnse2 = cnse2[:Nt] + +# two signals with a coherent part and a random part +s1 = 0.01*n.sin(2*n.pi*10*t) + cnse1 +s2 = 0.01*n.sin(2*n.pi*10*t) + cnse2 + +fig = figure() +ax = fig.add_subplot(211) +ax.plot(t, s1, 'b-', t, s2, 'g-') +ax.set_xlim(0,5) +ax.set_xlabel('time') +ax.set_ylabel('s1 and s2') + +ax = fig.add_subplot(212) +cxy, f = ax.cohere(s1, s2, 256, 1./dt) + +show() + + Modified: branches/transforms/examples/image_slices_viewer.py =================================================================== --- branches/transforms/examples/image_slices_viewer.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/image_slices_viewer.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -17,7 +17,7 @@ self.update() def onscroll(self, event): - + print event.button if event.button=='up': self.ind = numpy.clip(self.ind+1, 0, self.slices-1) else: Modified: branches/transforms/examples/keypress_demo.py =================================================================== --- branches/transforms/examples/keypress_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/keypress_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,21 +1,23 @@ #!/usr/bin/env python """ Show how to connect to keypress events - -Note, on the wx backend on some platforms (eg linux), you have to -first click on the figure before the keypress events are activated. -If you know how to fix this, please email us! """ -from pylab import * +import numpy as n +from pylab import figure, show def press(event): print 'press', event.key - if event.key=='g': - grid() - draw() + if event.key=='x': + visible = xl.get_visible() + xl.set_visible(not visible) + fig.canvas.draw() -connect('key_press_event', press) +fig = figure() +ax = fig.add_subplot(111) -title('press g to toggle grid') -plot(rand(12), rand(12), 'go') +fig.canvas.mpl_connect('key_press_event', press) + +ax.plot(n.random.rand(12), n.random.rand(12), 'go') +xl = ax.set_xlabel('easy come, easy go') + show() Modified: branches/transforms/examples/mathtext_examples.py =================================================================== --- branches/transforms/examples/mathtext_examples.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/mathtext_examples.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -48,7 +48,8 @@ r'$\mathcal{H} = \int d \tau \left(\epsilon E^2 + \mu H^2\right)$', r'$\widehat{abc}\widetilde{def}$', r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$', - r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$' + r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$', + ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * Modified: branches/transforms/examples/quadmesh_demo.py =================================================================== --- branches/transforms/examples/quadmesh_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/quadmesh_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -2,23 +2,26 @@ """ pcolormesh uses a QuadMesh, a faster generalization of pcolor, but with some restrictions. + +This demo illustrates a bug in quadmesh with masked data. """ -import numpy as nx -from pylab import figure,show +import numpy as npy +from matplotlib.pyplot import figure, show from matplotlib import cm, colors +from matplotlib.numerix import npyma as ma n = 56 -x = nx.linspace(-1.5,1.5,n) -X,Y = nx.meshgrid(x,x); -Qx = nx.cos(Y) - nx.cos(X) -Qz = nx.sin(Y) + nx.sin(X) +x = npy.linspace(-1.5,1.5,n) +X,Y = npy.meshgrid(x,x); +Qx = npy.cos(Y) - npy.cos(X) +Qz = npy.sin(Y) + npy.sin(X) Qx = (Qx + 1.1) -Z = nx.sqrt(X**2 + Y**2)/5; -Z = (Z - nx.amin(Z)) / (nx.amax(Z) - nx.amin(Z)) +Z = npy.sqrt(X**2 + Y**2)/5; +Z = (Z - Z.min()) / (Z.max() - Z.min()) # The color array can include masked values: -Zm = nx.ma.masked_where(nx.fabs(Qz) < 0.5*nx.amax(Qz), Z) +Zm = ma.masked_where(npy.fabs(Qz) < 0.5*npy.amax(Qz), Z) fig = figure() Modified: branches/transforms/examples/step_demo.py =================================================================== --- branches/transforms/examples/step_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/step_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,5 +1,6 @@ import numpy as npy -from pylab import * +from matplotlib.numerix import npyma as ma +from matplotlib.pyplot import step, legend, xlim, ylim, show x = npy.arange(1, 7, 0.4) y0 = npy.sin(x) @@ -13,7 +14,7 @@ y -= 0.5 step(x, y, where='post', label='post') -y = npy.ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) +y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5) step(x,y, label='masked (pre)') legend() @@ -22,3 +23,4 @@ ylim(-0.5, 4) show() + Modified: branches/transforms/examples/units/bar_unit_demo.py =================================================================== --- branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/examples/units/bar_unit_demo.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,15 +4,16 @@ N = 5 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm) -menStd = (20*cm, 30*cm, 32*cm, 10*cm, 20*cm) +menStd = ( 20*cm, 30*cm, 32*cm, 10*cm, 20*cm) fig = figure() ax = fig.add_subplot(111) ind = nx.arange(N) # the x locations for the groups -width = 0.35 # the width of the bars +width = 0.35 # the width of the bars p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd) + womenMeans = (145*cm, 149*cm, 172*cm, 165*cm, 200*cm) womenStd = (30*cm, 25*cm, 20*cm, 31*cm, 22*cm) p2 = ax.bar(ind+width, womenMeans, width, color='y', bottom=0*cm, yerr=womenStd) Modified: branches/transforms/lib/matplotlib/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -234,12 +234,11 @@ def checkdep_ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] + v = stdout.read()[:-1] vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' float(vtest) return vtest Modified: branches/transforms/lib/matplotlib/_mathtext_data.py =================================================================== --- branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1753,7 +1753,10 @@ uni2type1 = dict([(v,k) for k,v in type12uni.items()]) -tex2uni = {'doteq': 8784, +tex2uni = { +'widehat': 0x0302, +'widetilde': 0x0303, +'doteq': 8784, 'partial': 8706, 'gg': 8811, 'asymp': 8781, @@ -1883,7 +1886,7 @@ 'measeq': 8798, 'upharpoonleft': 8639, 'lq': 8216, -'Upsilon': 978, +'Upsilon': 933, 'subsetneq': 8842, 'greater': 62, 'supsetneq': 8843, @@ -2236,7 +2239,7 @@ 'combiningbreve' : 774, 'combiningoverline' : 772, 'combininggraveaccent' : 768, -'combiningacuteaccent' : 714, +'combiningacuteaccent' : 769, 'combiningdiaeresis' : 776, 'combiningtilde' : 771, 'combiningrightarrowabove' : 8407, Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1638,25 +1638,33 @@ self.xaxis.set_scale(value, **kwargs) self._update_transScale() - def get_xticks(self): + def get_xticks(self, minor=False): 'Return the x ticks as a list of locations' - return self.xaxis.get_ticklocs() + return self.xaxis.get_ticklocs(minor=minor) - def set_xticks(self, ticks): + def set_xticks(self, ticks, minor=False): """ Set the x ticks with list of ticks ACCEPTS: sequence of floats """ - return self.xaxis.set_ticks(ticks) + return self.xaxis.set_ticks(ticks, minor=minor) - def get_xticklabels(self): + def get_xmajorticklabels(self): 'Get the xtick labels as a list of Text instances' - return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels()) + return cbook.silent_list('Text xticklabel', self.xaxis.get_majorticklabels()) - def set_xticklabels(self, labels, fontdict=None, **kwargs): + def get_xminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_minorticklabels()) + + def get_xticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text xticklabel', self.xaxis.get_ticklabels(minor=minor)) + + def set_xticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_XTICKLABELS(labels, fontdict=None, **kwargs) + set_xticklabels(labels, fontdict=None, minor=False, **kwargs) Set the xtick labels with list of strings labels Return a list of axis text instances. @@ -1666,7 +1674,7 @@ ACCEPTS: sequence of strings """ - return self.xaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.xaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_xticklabels.__doc__ = cbook.dedent(set_xticklabels.__doc__) % martist.kwdocd def invert_yaxis(self): @@ -1791,25 +1799,33 @@ self.yaxis.set_scale(value, **kwargs) self._update_transScale() - def get_yticks(self): + def get_yticks(self, minor=False): 'Return the y ticks as a list of locations' - return self.yaxis.get_ticklocs() + return self.yaxis.get_ticklocs(minor=minor) - def set_yticks(self, ticks): + def set_yticks(self, ticks, minor=False): """ Set the y ticks with list of ticks ACCEPTS: sequence of floats """ - return self.yaxis.set_ticks(ticks) + return self.yaxis.set_ticks(ticks, minor=minor) - def get_yticklabels(self): - 'Get the ytick labels as a list of Text instances' - return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels()) + def get_ymajorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_majorticklabels()) - def set_yticklabels(self, labels, fontdict=None, **kwargs): + def get_yminorticklabels(self): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_minorticklabels()) + + def get_yticklabels(self, minor=False): + 'Get the xtick labels as a list of Text instances' + return cbook.silent_list('Text yticklabel', self.yaxis.get_ticklabels(minor=minor)) + + def set_yticklabels(self, labels, fontdict=None, minor=False, **kwargs): """ - SET_YTICKLABELS(labels, fontdict=None, **kwargs) + set_yticklabels(labels, fontdict=None, minor=False, **kwargs) Set the ytick labels with list of strings labels. Return a list of Text instances. @@ -1819,7 +1835,7 @@ ACCEPTS: sequence of strings """ - return self.yaxis.set_ticklabels(labels, fontdict, **kwargs) + return self.yaxis.set_ticklabels(labels, fontdict, minor=minor, **kwargs) set_yticklabels.__doc__ = cbook.dedent(set_yticklabels.__doc__) % martist.kwdocd def xaxis_date(self, tz=None): @@ -3314,22 +3330,7 @@ patches = [] - # lets do some conversions now - if self.xaxis is not None: - xconv = self.xaxis.converter - if xconv is not None: - units = self.xaxis.get_units() - left = xconv.convert( left, units ) - width = xconv.convert( width, units ) - if self.yaxis is not None: - yconv = self.yaxis.converter - if yconv is not None : - units = self.yaxis.get_units() - bottom = yconv.convert( bottom, units ) - height = yconv.convert( height, units ) - - if align == 'edge': pass elif align == 'center': @@ -3590,7 +3591,7 @@ texts = [] slices = [] autotexts = [] - for frac, label, expl in zip(x,labels, explode): + for frac, label, expl in cbook.safezip(x,labels, explode): x, y = center theta2 = theta1 + frac thetam = 2*math.pi*0.5*(theta1+theta2) @@ -3717,23 +3718,24 @@ a list of error bar cap lines, the third element is a list of line collections for the horizontal and vertical error ranges """ + self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs) if not self._hold: self.cla() - # make sure all the args are iterable arrays - if not iterable(x): x = npy.array([x]) - else: x = npy.asarray(x) + # make sure all the args are iterable; use lists not arrays to preserve units + if not iterable(x): + x = [x] - if not iterable(y): y = npy.array([y]) - else: y = npy.asarray(y) + if not iterable(y): + y = [y] if xerr is not None: - if not iterable(xerr): xerr = npy.array([xerr]) - else: xerr = npy.asarray(xerr) + if not iterable(xerr): + xerr = [xerr]*len(x) if yerr is not None: - if not iterable(yerr): yerr = npy.array([yerr]) - else: yerr = npy.asarray(yerr) + if not iterable(yerr): + yerr = [yerr]*len(y) l0 = None @@ -3749,7 +3751,9 @@ if 'lw' in kwargs: lines_kw['lw']=kwargs['lw'] - if not iterable(lolims): lolims = npy.array([lolims]*len(x), bool) + # arrays fine here, they are booleans and hence not units + if not iterable(lolims): + lolims = npy.asarray([lolims]*len(x), bool) else: lolims = npy.asarray(lolims, bool) if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) @@ -3761,6 +3765,18 @@ if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool) else: xuplims = npy.asarray(xuplims, bool) + def xywhere(xs, ys, mask): + """ + return xs[mask], ys[mask] where mask is True but xs and + ys are not arrays + """ + assert len(xs)==len(ys) + assert len(xs)==len(mask) + xs = [thisx for thisx, b in zip(xs, mask) if b] + ys = [thisy for thisy, b in zip(ys, mask) if b] + return xs, ys + + if capsize > 0: plot_kw = { 'ms':2*capsize, @@ -3771,51 +3787,68 @@ plot_kw['mew']=kwargs['mew'] if xerr is not None: - if len(xerr.shape) == 1: - left = x-xerr - right = x+xerr + if iterable(xerr) and len(xerr)==2: + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[0])] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[1])] else: - left = x-xerr[0] - right = x+xerr[1] + # using list comps rather than arrays to preserve units + left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] + right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr)] barcols.append( self.hlines(y, left, right, **lines_kw ) ) if capsize > 0: if xlolims.any(): - caplines.extend( self.plot(left[xlolims], y[xlolims], ls='None', marker=mlines.CARETLEFT, **plot_kw) ) + # can't use numpy logical indexing since left and + # y are lists + leftlo, ylo = xywhere(left, y, xlolims) + + caplines.extend( self.plot(leftlo, ylo, ls='None', marker=mlines.CARETLEFT, **plot_kw) ) xlolims = ~xlolims - caplines.extend( self.plot(left[xlolims], y[xlolims], 'k|', **plot_kw) ) + leftlo, ylo = xywhere(left, y, xlolims) + caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) ) else: caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) if xuplims.any(): - caplines.extend( self.plot(right[xuplims], y[xuplims], ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) + + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) xuplims = ~xuplims - caplines.extend( self.plot(right[xuplims], y[xuplims], 'k|', **plot_kw) ) + rightup, yup = xywhere(right, y, xuplims) + caplines.extend( self.plot(rightup, yup, 'k|', **plot_kw) ) else: caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) if yerr is not None: - if len(yerr.shape) == 1: - lower = y-yerr - upper = y+yerr + if iterable(yerr) and len(yerr)==2: + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[0])] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[1])] else: - lower = y-yerr[0] - upper = y+yerr[1] + # using list comps rather than arrays to preserve units + lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] + upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr)] barcols.append( self.vlines(x, lower, upper, **lines_kw) ) if capsize > 0: if lolims.any(): - caplines.extend( self.plot(x[lolims], lower[lolims], ls='None', marker=mlines.CARETDOWN, **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, ls='None', marker=mlines.CARETDOWN, **plot_kw) ) lolims = ~lolims - caplines.extend( self.plot(x[lolims], lower[lolims], 'k_', **plot_kw) ) + xlo, lowerlo = xywhere(x, lower, lolims) + caplines.extend( self.plot(xlo, lowerlo, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, lower, 'k_', **plot_kw) ) if uplims.any(): - caplines.extend( self.plot(x[uplims], upper[uplims], ls='None', marker=mlines.CARETUP, **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + + caplines.extend( self.plot(xup, upperup, ls='None', marker=mlines.CARETUP, **plot_kw) ) uplims = ~uplims - caplines.extend( self.plot(x[uplims], upper[uplims], 'k_', **plot_kw) ) + xup, upperup = xywhere(x, upper, uplims) + caplines.extend( self.plot(xup, upperup, 'k_', **plot_kw) ) else: caplines.extend( self.plot(x, upper, 'k_', **plot_kw) ) Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/axis.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -513,8 +513,8 @@ def get_children(self): children = [self.label] majorticks = self.get_major_ticks() - minorticks = self.get_minor_ticks() - + minorticks = self.get_minor_ticks() + children.extend(majorticks) children.extend(minorticks) return children @@ -669,24 +669,62 @@ 'Return the depth of the axis used by the picker' return self.pickradius - def get_ticklabels(self): - 'Return a list of Text instances for ticklabels' + def get_majorticklabels(self): + 'Return a list of Text instances for the major ticklabels' ticks = self.get_major_ticks() labels1 = [tick.label1 for tick in ticks if tick.label1On] labels2 = [tick.label2 for tick in ticks if tick.label2On] - return silent_list('Text ticklabel', labels1+labels2) + return silent_list('Text major ticklabel', labels1+labels2) - def get_ticklines(self): - 'Return the ticklines lines as a list of Line2D instance' + def get_minorticklabels(self): + 'Return a list of Text instances for the minor ticklabels' + ticks = self.get_minor_ticks() + labels1 = [tick.label1 for tick in ticks if tick.label1On] + labels2 = [tick.label2 for tick in ticks if tick.label2On] + return silent_list('Text minor ticklabel', labels1+labels2) + + def get_ticklabels(self, minor=False): + 'Return a list of Text instances for ticklabels' + if minor: + return self.get_minorticklabels() + return self.get_majorticklabels() + + def get_majorticklines(self): + 'Return the major tick lines as a list of Line2D instances' lines = [] - ticks = self.get_major_ticks() + ticks = self.get_major_ticks() for tick in ticks: lines.append(tick.tick1line) lines.append(tick.tick2line) return silent_list('Line2D ticklines', lines) - def get_ticklocs(self): + def get_minorticklines(self): + 'Return the minor tick lines as a list of Line2D instances' + lines = [] + ticks = self.get_minor_ticks() + for tick in ticks: + lines.append(tick.tick1line) + lines.append(tick.tick2line) + return silent_list('Line2D ticklines', lines) + + def get_ticklines(self, minor=False): + 'Return the tick lines as a list of Line2D instances' + if minor: + return self.get_minorticklines() + return self.get_majorticklines() + + def get_majorticklocs(self): + "Get the major tick locations in data coordinates as a numpy array" + return self.major.locator() + + def get_minorticklocs(self): + "Get the minor tick locations in data coordinates as a numpy array" + return self.minor.locator() + + def get_ticklocs(self, minor=False): "Get the tick locations in data coordinates as a numpy array" + if minor: + return self.minor.locator() return self.major.locator() def _get_tick(self, major): @@ -728,7 +766,6 @@ 'get the tick instances; grow as necessary' if numticks is None: numticks = len(self.get_major_locator()()) - if len(self.majorTicks) < numticks: # update the new tick label properties from the old for i in range(numticks - len(self.majorTicks)): @@ -934,23 +971,30 @@ def set_ticklabels(self, ticklabels, *args, **kwargs): """ Set the text values of the tick labels. Return a list of Text - instances. + instances. Use kwarg minor=True to select minor ticks. ACCEPTS: sequence of strings """ #ticklabels = [str(l) for l in ticklabels] + minor = kwargs.pop('minor', False) + if minor: + self.set_minor_formatter(FixedFormatter(ticklabels)) + ticks = self.get_minor_ticks() + else: + self.set_major_formatter( FixedFormatter(ticklabels) ) + ticks = self.get_major_ticks() self.set_major_formatter( FixedFormatter(ticklabels) ) ret = [] - for i, tick in enumerate(self.get_major_ticks()): + for i, tick in enumerate(ticks): if i<len(ticklabels): tick.label1.set_text(ticklabels[i]) ret.append(tick.label1) tick.label1.update(kwargs) return ret - def set_ticks(self, ticks): + def set_ticks(self, ticks, minor=False): """ Set the locations of the tick marks from sequence ticks @@ -958,10 +1002,14 @@ """ ### XXX if the user changes units, the information will be lost here ticks = self.convert_units(ticks) - self.set_major_locator( FixedLocator(ticks) ) if len(ticks): self.set_view_interval(min(ticks), max(ticks)) - return self.get_major_ticks(len(ticks)) + if minor: + self.set_minor_locator(FixedLocator(ticks)) + return self.get_minor_ticks(len(ticks)) + else: + self.set_major_locator( FixedLocator(ticks) ) + return self.get_major_ticks(len(ticks)) def _update_label_position(self, bboxes, bboxes2): """ Modified: branches/transforms/lib/matplotlib/backends/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/__init__.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,7 +6,7 @@ 'new_figure_manager', 'backend_version'] interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'FltkAgg', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', 'Aqt'] + 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg'] non_interactive_bk = ['Agg2', 'Agg', 'Cairo', 'EMF', 'GDK', 'Pdf', 'PS', 'SVG', 'Template'] all_backends = interactive_bk + non_interactive_bk @@ -50,7 +50,4 @@ return new_figure_manager, draw_if_interactive, show -# a hack to keep old versions of ipython working with mpl -if 'IPython.Shell' in sys.modules: - new_figure_manager, draw_if_interactive, show = pylab_setup() Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -9,6 +9,7 @@ import re import sys import time +import warnings import zlib import numpy as npy @@ -25,7 +26,7 @@ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM import matplotlib.type1font as type1font import matplotlib.dviread as dviread @@ -790,7 +791,8 @@ glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) # Why divided by 3.0 ??? Wish I knew... MGD widths.append((ccode, cvt(glyph.horiAdvance) / 3.0)) - cid_to_gid_map[ccode] = unichr(gind) + if ccode < 65536: + cid_to_gid_map[ccode] = unichr(gind) max_ccode = max(ccode, max_ccode) widths.sort() cid_to_gid_map = cid_to_gid_map[:max_ccode + 1] @@ -880,6 +882,15 @@ 'StemV' : 0 # ??? } + # The font subsetting to a Type 3 font does not work for + # OpenType (.otf) that embed a Postscript CFF font, so avoid that -- + # save as a (non-subsetted) Type 42 font instead. + if is_opentype_cff_font(filename): + fonttype = 42 + warnings.warn(("'%s' can not be subsetted into a Type 3 font. " + + "The entire font will be embedded in the output.") % + os.path.basename(filename)) + if fonttype == 3: return embedTTFType3(font, characters, descriptor) elif fonttype == 42: @@ -1130,10 +1141,6 @@ self.truetype_font_cache = {} self.afm_font_cache = {} self.file.used_characters = self.used_characters = {} - if rcParams['pdf.fonttype'] == 3: - self.encode_string = self.encode_string_type3 - else: - self.encode_string = self.encode_string_type42 self.mathtext_parser = MathTextParser("Pdf") self.image_magnification = dpi/72.0 self.tex_font_map = None @@ -1235,7 +1242,7 @@ # When using Type 3 fonts, we can't use character codes higher # than 255, so we use the "Do" command to render those # instead. - fonttype = rcParams['pdf.fonttype'] + global_fonttype = rcParams['pdf.fonttype'] # Set up a global transformation matrix for the whole math expression a = angle / 180.0 * pi @@ -1248,6 +1255,11 @@ prev_font = None, None oldx, oldy = 0, 0 for ox, oy, fontname, fontsize, num, symbol_name in glyphs: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + if fonttype == 42 or num <= 255: self._setup_textpos(ox, oy, 0, oldx, oldy) oldx, oldy = ox, oy @@ -1255,14 +1267,19 @@ self.file.output(self.file.fontName(fontname), fontsize, Op.selectfont) prev_font = fontname, fontsize - self.file.output(self.encode_string(unichr(num)), Op.show) + self.file.output(self.encode_string(unichr(num), fonttype), Op.show) self.file.output(Op.end_text) # If using Type 3 fonts, render all of the two-byte characters # as XObjects using the 'Do' command. - if fonttype == 3: + if global_fonttype == 3: for ox, oy, fontname, fontsize, num, symbol_name in glyphs: - if num > 255: + if is_opentype_cff_font(fontname): + fonttype = 42 + else: + fonttype = global_fonttype + + if fonttype == 3 and num > 255: self.file.output(Op.gsave, 0.001 * fontsize, 0, 0, 0.001 * fontsize, @@ -1362,10 +1379,9 @@ self.draw_polygon(boxgc, gc._rgb, ((x1,y1), (x2,y2), (x3,y3), (x4,y4))) - def encode_string_type3(self, s): - return s.encode('cp1252', 'replace') - - def encode_string_type42(self, s): + def encode_string(self, s, fonttype): + if fonttype == 3: + return s.encode('cp1252', 'replace') return s.encode('utf-16be', 'replace') def draw_text(self, gc, x, y, s, prop, angle, ismath=False): @@ -1391,20 +1407,29 @@ font = self._get_font_afm(prop) l, b, w, h = font.get_str_bbox(s) y -= b * fontsize / 1000 + fonttype = 42 else: font = self._get_font_ttf(prop) self.track_characters(font, s) font.set_text(s, 0.0, flags=LOAD_NO_HINTING) y += font.get_descent() / 64.0 + fonttype = rcParams['pdf.fonttype'] + + # We can't subset all OpenType fonts, so switch to Type 42 + # in that case. + if is_opentype_cff_font(font.fname): + fonttype = 42 + def check_simple_method(s): """Determine if we should use the simple or woven method - to output this text, and chunks the string into 1-bit and - 2-bit sections if necessary.""" + to output this text, and chunks the string into 1-byte and + 2-byte sections if necessary.""" use_simple_method = True chunks = [] - if rcParams['pdf.fonttype'] == 3: - if not isinstance(s, str) and len(s) != 0: + + if not rcParams['pdf.use14corefonts']: + if fonttype == 3 and not isinstance(s, str) and len(s) != 0: # Break the string into chunks where each chunk is either # a string of chars <= 255, or a single character > 255. s = unicode(s) @@ -1428,7 +1453,7 @@ prop.get_size_in_points(), Op.selectfont) self._setup_textpos(x, y, angle) - self.file.output(self.encode_string(s), Op.show, Op.end_text) + self.file.output(self.encode_string(s, fonttype), Op.show, Op.end_text) def draw_text_woven(chunks): """Outputs text using the woven method, alternating @@ -1458,7 +1483,7 @@ for chunk_type, chunk in chunks: if mode == 1 and chunk_type == 1: self._setup_textpos(newx, 0, 0, oldx, 0, 0) - self.file.output(self.encode_string(chunk), Op.show) + self.file.output(self.encode_string(chunk, fonttype), Op.show) oldx = newx lastgind = None Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -18,7 +18,7 @@ from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat from matplotlib.figure import Figure -from matplotlib.font_manager import findfont +from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING from matplotlib.ttconv import convert_ttf_to_ps from matplotlib.mathtext import MathTextParser @@ -846,7 +846,7 @@ else: self._print_figure(outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype) - + def _print_figure(self, outfile, format, dpi=72, facecolor='w', edgecolor='w', orientation='portrait', isLandscape=False, papertype=None): """ @@ -950,7 +950,15 @@ for c in chars: gind = cmap.get(ord(c)) or 0 glyph_ids.append(gind) - convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) + # The ttf to ps (subsetting) support doesn't work for + # OpenType fonts that are Postscript inside (like the + # STIX fonts). This will simply turn that off to avoid + # errors. + if is_opentype_cff_font(font_filename): + raise RuntimeError("OpenType CFF fonts can not be saved using the internal Postscript backend at this time.\nConsider using the Cairo backend.") + else: + fonttype = rcParams['ps.fonttype'] + convert_ttf_to_ps(font_filename, fh, rcParams['ps.fonttype'], glyph_ids) print >>fh, "end" print >>fh, "%%EndProlog" Modified: branches/transforms/lib/matplotlib/backends/backend_qt4agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/backends/backend_qt4agg.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -6,8 +6,6 @@ import os, sys import matplotlib -from matplotlib import verbose -from matplotlib.cbook import enumerate from matplotlib.figure import Figure from backend_agg import FigureCanvasAgg @@ -61,7 +59,7 @@ self.drawRect = False self.rect = [] self.replot = True - self.pixmap = QtGui.QPixmap() + self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) def resizeEvent( self, e ): FigureCanvasQT.resizeEvent( self, e ) @@ -86,26 +84,25 @@ # only replot data when needed if type(self.replot) is bool: # might be a bbox for blitting - if ( self.replot ): - #stringBuffer = str( self.buffer_rgba(0,0) ) - FigureCanvasAgg.draw( self ) + if self.replot: + FigureCanvasAgg.draw(self) - # matplotlib is in rgba byte order. - # qImage wants to put the bytes into argb format and - # is in a 4 byte unsigned int. little endian system is LSB first - # and expects the bytes in reverse order (bgra). - if ( QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian ): - stringBuffer = self.renderer._renderer.tostring_bgra() - else: - stringBuffer = self.renderer._renderer.tostring_argb() - qImage = QtGui.QImage( stringBuffer, self.renderer.width, - self.renderer.height, - QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap( QtCore.QPoint( 0, 0 ), self.pixmap ) + # matplotlib is in rgba byte order. QImage wants to put the bytes + # into argb format and is in a 4 byte unsigned int. Little endian + # system is LSB first and expects the bytes in reverse order + # (bgra). + if QtCore.QSysInfo.ByteOrder == QtCore.QSysInfo.LittleEndian: + stringBuffer = self.renderer._renderer.tostring_bgra() + else: + stringBuffer = self.renderer._renderer.tostring_argb() + qImage = QtGui.QImage(stringBuffer, self.renderer.width, + self.renderer.height, + QtGui.QImage.Format_ARGB32) + p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage)) + # draw the zoom rectangle to the QPainter - if ( self.drawRect ): + if self.drawRect: p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) ) p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] ) @@ -117,8 +114,8 @@ reg = self.copy_from_bbox(bbox) stringBuffer = reg.to_string() qImage = QtGui.QImage(stringBuffer, w, h, QtGui.QImage.Format_ARGB32) - self.pixmap = self.pixmap.fromImage( qImage ) - p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), self.pixmap) + pixmap = QtGui.QPixmap.fromImage(qImage) + p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap) p.end() self.replot = False Modified: branches/transforms/lib/matplotlib/cbook.py =================================================================== --- branches/transforms/lib/matplotlib/cbook.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/cbook.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -558,7 +558,7 @@ # expressions. However, this function accounted for almost 30% of # matplotlib startup time, so it is worthy of optimization at all # costs. - + if not s: # includes case of s is None return '' @@ -577,7 +577,7 @@ if unindent is None: unindent = re.compile("\n\r? {0,%d}" % nshift) _dedent_regex[nshift] = unindent - + result = unindent.sub("\n", s).strip() return result @@ -845,6 +845,15 @@ return mem +_safezip_msg = 'In safezip, len(args[0])=%d but len(args[%d])=%d' +def safezip(*args): + 'make sure args are equal len before zipping' + Nx = len(args[0]) + for i, arg in enumerate(args[1:]): + if len(arg) != Nx: + raise ValueError(_safezip_msg % (Nx, i+1, len(arg))) + return zip(*args) + class MemoryMonitor: def __init__(self, nmax=20000): self._nmax = nmax Modified: branches/transforms/lib/matplotlib/config/checkdep.py =================================================================== --- branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/checkdep.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -4,28 +4,27 @@ import warnings import distutils.version as version +tex_req = '3.1415' +gs_req = '7.07' +gs_sugg = '8.60' +dvipng_req = '1.5' +pdftops_req = '3.0' + def dvipng(): try: stdin, stdout = os.popen4('dvipng -version') - line = stdout.readlines()[1] - v = line.split()[-1] - float(v) - return v + return stdout.readlines()[1].split()[-1] except (IndexError, ValueError): return None def ghostscript(): try: if sys.platform == 'win32': - command = 'gswin32c -v' + command = 'gswin32c --version' else: - command = 'gs -v' + command = 'gs --version' stdin, stdout = os.popen4(command) - line = stdout.readlines()[0] - v = line.split()[-2] - vtest = '.'.join(v.split('.')[:2]) # deal with version numbers like '7.07.1' - float(vtest) - return vtest + return stdout.read()[:-1] except (IndexError, ValueError): return None @@ -35,9 +34,7 @@ line = stdout.readlines()[0] pattern = '3\.1\d+' match = re.search(pattern, line) - v = match.group(0) - float(v) - return v + return match.group(0) except (IndexError, ValueError): return None @@ -46,9 +43,7 @@ stdin, stdout = os.popen4('pdftops -v') for line in stdout.readlines(): if 'version' in line: - v = line.split()[-1] - float(v) - return v + return line.split()[-1] except (IndexError, ValueError): return None @@ -66,8 +61,6 @@ return False flag = True - gs_req = '7.07' - gs_sugg = '7.07' gs_v = ghostscript() if compare_versions(gs_v, gs_sugg): pass elif compare_versions(gs_v, gs_req): @@ -81,14 +74,13 @@ 'system.') % gs_req) if s == 'xpdf': - pdftops_req = '3.0' pdftops_v = pdftops() if compare_versions(pdftops_v, pdftops_req): pass else: flag = False warnings.warn(('matplotlibrc ps.usedistiller can not be set to ' - 'xpdf unless xpdf-%s or later is installed on your ' - 'system.') % pdftops_req) + 'xpdf unless pdftops-%s or later is installed on ' + 'your system.') % pdftops_req) if flag: return s @@ -99,10 +91,6 @@ if not s: return False - tex_req = '3.1415' - gs_req = '7.07' - gs_sugg = '7.07' - dvipng_req = '1.5' flag = True tex_v = tex() Deleted: branches/transforms/lib/matplotlib/config/configtest.py =================================================================== --- branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/configtest.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -1,8 +0,0 @@ -from api import rcParams, mplConfig - -print 'loaded your old rcParams["backend"]:', rcParams['backend'] -print 'changing rcParams["backend"] to cairo' -rcParams["backend"] = 'cairo' -print 'mplConfig.backend.use is now :', mplConfig.backend.use -print 'changing rcParams["backend"] to BogusBackend:' -rcParams["backend"] = 'BogusBackend' Modified: branches/transforms/lib/matplotlib/config/cutils.py =================================================================== --- branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/cutils.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -55,8 +55,6 @@ else: raise RuntimeError('please define environment variable $HOME') - - get_home = verbose.wrap('$HOME=%s', _get_home, always=False) def _get_configdir(): @@ -89,9 +87,9 @@ os.mkdir(p) return p + get_configdir = verbose.wrap('CONFIGDIR=%s', _get_configdir, always=False) - def _get_data_path(): 'get the path to matplotlib data' Modified: branches/transforms/lib/matplotlib/config/mplconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -166,7 +166,7 @@ it = T.Trait('serif:oblique' , mplT.FontconfigPatternHandler()) bf = T.Trait('serif:bold' , mplT.FontconfigPatternHandler()) sf = T.Trait('sans' , mplT.FontconfigPatternHandler()) - use_cm = T.true + fontset = T.Trait('cm', 'cm', 'stix', 'custom') fallback_to_cm = T.true class axes(TConfig): @@ -344,7 +344,7 @@ 'mathtext.it' : (self.tconfig.mathtext, 'it'), 'mathtext.bf' : (self.tconfig.mathtext, 'bf'), 'mathtext.sf' : (self.tconfig.mathtext, 'sf'), - 'mathtext.use_cm' : (self.tconfig.mathtext, 'use_cm'), + 'mathtext.fontset' : (self.tconfig.mathtext, 'fontset'), 'mathtext.fallback_to_cm' : (self.tconfig.mathtext, 'fallback_to_cm'), 'image.aspect' : (self.tconfig.image, 'aspect'), Modified: branches/transforms/lib/matplotlib/config/rcsetup.py =================================================================== --- branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -203,6 +203,8 @@ parse_fontconfig_pattern(s) return s +validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'custom']) + validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', ]) @@ -365,7 +367,7 @@ 'mathtext.it' : ['serif:italic', validate_font_properties], 'mathtext.bf' : ['serif:bold', validate_font_properties], 'mathtext.sf' : ['sans\-serif', validate_font_properties], - 'mathtext.use_cm' : [True, validate_bool], + 'mathtext.fontset' : ['cm', validate_fontset], 'mathtext.fallback_to_cm' : [True, validate_bool], 'image.aspect' : ['equal', validate_aspect], # equal, auto, a number Modified: branches/transforms/lib/matplotlib/contour.py =================================================================== --- branches/transforms/lib/matplotlib/contour.py 2007-11-06 19:48:40 UTC (rev 4134) +++ branches/transforms/lib/matplotlib/contour.py 2007-11-06 20:02:07 UTC (rev 4135) @@ -395,7 +395,8 @@ self.levels = kwargs.get('levels', None) self.filled = kwargs.get('filled', False) self.linewidths = kwargs.get('linewidths', None) - + self.linestyles = kwargs.get('linestyles', 'solid') + self.alpha = kwargs.get('alpha', 1.0) self.origin = kwargs.get('origin', None) self.extent = kwargs.get('extent', None) @@ -406,6 +407,15 @@ self.antialiased = kwargs.get('antialiased', True) self.nchunk = kwargs.get('nchunk', 0) self.locator = kwargs.get('locator', None) + if (isinstance(norm, colors.LogNorm) + or isinstance(self.locator, ticker.LogLocator)): + self.logscale = True + if norm is None: + norm = colors.LogNorm() + if self.extend is not 'neither': + raise ValueError('extend kwarg does not work yet with log scale') + else: + self.logscale = False if self.origin is not None: assert(self.origin in ['lower', 'upper', 'image']) @@ -453,11 +463,13 @@ else: tlinewidths = self._process_linewidths() self.tlinewidths = tlinewidths + tlinestyles = self._process_linestyles() C = _cntr.Cntr(x, y... [truncated message content] |
From: <md...@us...> - 2007-11-07 15:31:40
|
Revision: 4142 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4142&view=rev Author: mdboom Date: 2007-11-07 07:31:37 -0800 (Wed, 07 Nov 2007) Log Message: ----------- Further speed improvements. For collections, now has faster ignoring of elements that aren't provided, such as offsets. Paths now do not even store the "default" codes array -- which is MOVETO followed by N LINETOs. These are generated automatically by the iterators if no codes array is provided. (Should also result in significant memory savings for graphs with many points.) Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/backend_bases.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/path.py branches/transforms/src/_backend_agg.cpp branches/transforms/src/_path.cpp branches/transforms/src/agg_py_path_iterator.h Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -4697,7 +4697,6 @@ kwargs.setdefault('edgecolors', edgecolors) kwargs.setdefault('antialiaseds', (0,)) kwargs.setdefault('linewidths', (0.25,)) - kwargs['closed'] = False collection = mcoll.PolyCollection(verts, **kwargs) Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -99,13 +99,12 @@ if Npaths == 0: return + transform = transforms.IdentityTransform() for i in xrange(N): path = paths[i % Npaths] - transform = all_transforms[i % Ntransforms] - if transform is None: - transform = transforms.IdentityTransform() - transform += master_transform - yield path, transform + if Ntransforms: + transform = all_transforms[i % Ntransforms] + yield path, transform + master_transform def _iter_collection(self, path_ids, cliprect, clippath, clippath_trans, offsets, offsetTrans, facecolors, edgecolors, @@ -146,8 +145,8 @@ if (Nfacecolors == 0 and Nedgecolors == 0) or Npaths == 0: return - - toffsets = offsetTrans.transform(offsets) + if Noffsets: + toffsets = offsetTrans.transform(offsets) gc = self.new_gc() @@ -159,9 +158,11 @@ if Nfacecolors == 0: rgbFace = None + xo, yo = 0, 0 for i in xrange(N): path_id = path_ids[i % Npaths] - xo, yo = toffsets[i % Noffsets] + if Noffsets: + xo, yo = toffsets[i % Noffsets] if Nfacecolors: rgbFace = facecolors[i % Nfacecolors] if Nedgecolors: Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -51,9 +51,9 @@ draw time a call to scalar mappable will be made to set the face colors. """ - _offsets = npy.zeros((1, 2)) + _offsets = npy.array([], npy.float_) _transOffset = transforms.IdentityTransform() - _transforms = [None] + _transforms = [] zorder = 1 def __init__(self, @@ -93,7 +93,7 @@ self._antialiaseds = self._get_value(antialiaseds) self._uniform_offsets = None - self._offsets = npy.zeros((1, 2)) + self._offsets = npy.array([], npy.float_) if offsets is not None: offsets = npy.asarray(offsets, npy.float_) if len(offsets.shape) == 1: @@ -135,10 +135,11 @@ if not transOffset.is_affine: offsets = transOffset.transform_non_affine(offsets) transOffset = transOffset.get_affine() - + offsets = npy.asarray(offsets, npy.float_) + result = mpath.get_path_collection_extents( transform.frozen(), paths, self.get_transforms(), - npy.asarray(offsets, npy.float_), transOffset.frozen()) + offsets, transOffset.frozen()) result = result.inverse_transformed(transData) return result @@ -158,12 +159,12 @@ xs = self.convert_xunits(xs) ys = self.convert_yunits(ys) paths.append(mpath.Path(zip(xs, ys), path.codes)) - if self._offsets is not None: + if len(self._offsets): xs = self.convert_xunits(self._offsets[:0]) ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) if len(offsets) == 0: - offsets = npy.zeros((1, 2)) + offsets = npy.array([], npy.float_) else: offsets = npy.asarray(offsets, npy.float_) @@ -384,27 +385,33 @@ self._coordinates = coordinates self._showedges = showedges - # MGDTODO: Is it possible to Numpify this? - coordinates = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) - c = coordinates - paths = [] + c = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) # We could let the Path constructor generate the codes for us, # but this is faster, since we know they'll always be the same - codes = npy.array([Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]) - for m in xrange(meshHeight): - for n in xrange(meshWidth): - paths.append(Path( - [c[m , n], - c[m , n+1], - c[m+1, n+1], - c[m+1, n], - c[m , n]], - codes)) - self._paths = paths + codes = npy.array( + [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY], + Path.code_type) + + points = npy.concatenate(( + c[0:-1, 0:-1], + c[0:-1, 1: ], + c[1: , 1: ], + c[1: , 0:-1], + c[0:-1, 0:-1] + ), axis=2) + points = points.reshape((meshWidth * meshHeight, 5, 2)) + self._paths = [Path(x, codes) for x in points] + + self._bbox = transforms.Bbox.unit() + self._bbox.update_from_data_xy(c.reshape( + ((meshWidth + 1) * (meshHeight + 1), 2))) def get_paths(self, dataTrans=None): return self._paths + def get_datalim(self, transData): + return self._bbox + def draw(self, renderer): self.update_scalarmappable() @@ -425,14 +432,13 @@ %(Collection)s """ - self.closed = kwargs.pop("closed", True) Collection.__init__(self,**kwargs) self.set_verts(verts) __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def set_verts(self, verts): '''This allows one to delay initialization of the vertices.''' - self._paths = [mpath.Path(v, closed=self.closed) for v in verts] + self._paths = [mpath.Path(v) for v in verts] def get_paths(self): return self._paths Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -928,7 +928,7 @@ path, path_trans) - _caret_path = Path([[-1.0, 1.5], [0.0, 0.0], [1.0, 1.5]], closed=False) + _caret_path = Path([[-1.0, 1.5], [0.0, 0.0], [1.0, 1.5]]) def _draw_caretdown(self, renderer, gc, path, path_trans): offset = 0.5*renderer.points_to_pixels(self._markersize) transform = Affine2D().scale(offset) Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/patches.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -530,7 +530,7 @@ See Patch documentation for additional kwargs """ Patch.__init__(self, **kwargs) - self._path = Path(xy, closed=True) + self._path = Path(xy) __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd def get_path(self): @@ -539,7 +539,7 @@ def _get_xy(self): return self._path.vertices def _set_xy(self, vertices): - self._path = Path(vertices, closed=True) + self._path = Path(vertices) xy = property(_get_xy, _set_xy) class Wedge(Patch): Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/lib/matplotlib/path.py 2007-11-07 15:31:37 UTC (rev 4142) @@ -53,6 +53,12 @@ CLOSEPOLY : 1 vertex (ignored) Draw a line segment to the start point of the current polyline. + + Users of Path objects should not access the vertices and codes + arrays directly. Instead, they should use iter_segments to get + the vertex/code pairs. This is important since many Paths do not + store a codes array at all, but have a default one provided for + them by iter_segments. """ # Path codes @@ -67,10 +73,7 @@ code_type = npy.uint8 - _open_codes_cache = WeakValueDictionary() - _closed_codes_cache = WeakValueDictionary() - - def __init__(self, vertices, codes=None, closed=False): + def __init__(self, vertices, codes=None): """ Create a new path with the given vertices and codes. @@ -87,43 +90,17 @@ dimension. If codes is None, vertices will be treated as a series of line - segments. Additionally, if closed is also True, the polyline - will closed. If vertices contains masked values, the - resulting path will be compressed, with MOVETO codes inserted - in the correct places to jump over the masked regions. + segments. If vertices contains masked values, the resulting + path will be compressed, with MOVETO codes inserted in the + correct places to jump over the masked regions. """ if ma.isMaskedArray(vertices): mask = ma.getmask(vertices) else: vertices = npy.asarray(vertices, npy.float_) mask = ma.nomask - - if codes is None: - if closed: - # MGDTODO: Remove me once efficiency concerns are - # taken care of. - warnings.warn(""" -EFFICIENCY CONCERN: Having the Path constructor create a closed -polyline automatically is not always the most efficient way to do -things, since it causes a memory copy of the vertices array. If the -caller can easily close the polygon itself it should do so. -""") - codes = self._closed_codes_cache.get(len(vertices)) - if codes is None: - codes = self.LINETO * npy.ones( - vertices.shape[0] + 1, self.code_type) - codes[0] = self.MOVETO - codes[-1] = self.CLOSEPOLY - self._closed_codes_cache[len(vertices)] = codes - vertices = npy.concatenate((vertices, [vertices[0]])) - else: - codes = self._open_codes_cache.get(len(vertices)) - if codes is None: - codes = self.LINETO * npy.ones( - vertices.shape[0], self.code_type) - codes[0] = self.MOVETO - self._open_codes_cache[len(vertices)] = codes - else: + + if codes is not None: codes = npy.asarray(codes, self.code_type) assert codes.ndim == 1 assert len(codes) == len(vertices) @@ -136,6 +113,10 @@ if mask is not ma.nomask: mask1d = ma.mask_or(mask[:, 0], mask[:, 1]) vertices = ma.compress(npy.invert(mask1d), vertices, 0) + if codes is None: + codes = self.LINETO * npy.ones( + vertices.shape[0], self.code_type) + codes[0] = self.MOVETO codes = npy.where(npy.concatenate((mask1d[-1:], mask1d[:-1])), self.MOVETO, codes) codes = ma.masked_array(codes, mask=mask1d).compressed() @@ -144,23 +125,15 @@ assert vertices.ndim == 2 assert vertices.shape[1] == 2 - self._codes = codes - self._vertices = vertices + self.codes = codes + self.vertices = vertices def __repr__(self): return "Path(%s, %s)" % (self.vertices, self.codes) def __len__(self): - return len(self._vertices) + return len(self.vertices) - def _get_codes(self): - return self._codes - codes = property(_get_codes) - - def _get_vertices(self): - return self._vertices - vertices = property(_get_vertices) - def iter_segments(self): """ Iterates over all of the endpoints in the path. Unlike @@ -171,18 +144,28 @@ NUM_VERTICES = self.NUM_VERTICES vertices = self.vertices codes = self.codes + + if not len(vertices): + return - while i < len(vertices): - code = codes[i] - if code == self.CLOSEPOLY: - yield [], code - i += 1 - elif code == self.STOP: - return - else: - num_vertices = NUM_VERTICES[code] - yield vertices[i:i+num_vertices].flatten(), code - i += num_vertices + if codes is None: + code = self.MOVETO + yield vertices[0], self.MOVETO + i = 1 + for v in vertices[1:]: + yield v, self.LINETO + else: + while i < len(vertices): + code = codes[i] + if code == self.CLOSEPOLY: + yield [], code + i += 1 + elif code == self.STOP: + return + else: + num_vertices = NUM_VERTICES[code] + yield vertices[i:i+num_vertices].flatten(), code + i += num_vertices def transformed(self, transform): """ @@ -242,7 +225,7 @@ return cls._unit_rectangle unit_rectangle = classmethod(unit_rectangle) - _unit_regular_polygons = {} + _unit_regular_polygons = WeakValueDictionary() #@classmethod def unit_regular_polygon(cls, numVertices): """ @@ -262,7 +245,7 @@ return path unit_regular_polygon = classmethod(unit_regular_polygon) - _unit_regular_stars = {} + _unit_regular_stars = WeakValueDictionary() #@classmethod def unit_regular_star(cls, numVertices, innerCircle=0.5): """ @@ -413,6 +396,7 @@ return Path(vertices, codes) arc = classmethod(arc) + #@classmethod def wedge(cls, theta1, theta2): """ Returns a wedge of the unit circle from angle theta1 to angle Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/src/_backend_agg.cpp 2007-11-07 15:31:37 UTC (rev 4142) @@ -940,9 +940,12 @@ PyArrayObject* edgecolors = NULL; try { - offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2); - if (!offsets || offsets->dimensions[1] != 2) + offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 0, 2); + if (!offsets || + (offsets->nd == 2 && offsets->dimensions[1] != 2) || + (offsets->nd == 1 && offsets->dimensions[0])) { throw Py::ValueError("Offsets array must be Nx2"); + } PyArrayObject* facecolors = (PyArrayObject*)PyArray_FromObject (facecolors_obj.ptr(), PyArray_DOUBLE, 1, 2); @@ -1004,14 +1007,22 @@ gc.linewidth = 0.0; facepair_t face; face.first = Nfacecolors != 0; - + agg::trans_affine trans; + 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]; + if (Ntransforms) { + trans = transforms[i % Ntransforms]; + } else { + trans = master_transform; + } + + if (Noffsets) { + double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0); + double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1); + offset_trans.transform(&xo, &yo); + trans *= agg::trans_affine_translation(xo, yo); + } if (Nfacecolors) { size_t fi = i % Nfacecolors; @@ -1034,7 +1045,7 @@ gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); - _draw_path(path, trans * transOffset, has_clippath, face, gc); + _draw_path(path, trans, has_clippath, face, gc); } } catch (...) { Py_XDECREF(offsets); Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/src/_path.cpp 2007-11-07 15:31:37 UTC (rev 4142) @@ -261,9 +261,12 @@ double x0, y0, x1, y1; try { - offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 2, 2); - if (!offsets || offsets->dimensions[1] != 2) + offsets = (PyArrayObject*)PyArray_FromObject(offsets_obj.ptr(), PyArray_DOUBLE, 0, 2); + if (!offsets || + (offsets->nd == 2 && offsets->dimensions[1] != 2) || + (offsets->nd == 1 && offsets->dimensions[0])) { throw Py::ValueError("Offsets array must be Nx2"); + } size_t Npaths = paths.length(); size_t Noffsets = offsets->dimensions[0]; @@ -287,16 +290,23 @@ y0 = std::numeric_limits<double>::infinity(); x1 = -std::numeric_limits<double>::infinity(); y1 = -std::numeric_limits<double>::infinity(); + agg::trans_affine trans; + 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 (Ntransforms) { + trans = transforms[i % Ntransforms]; + } else { + trans = master_transform; + } + if (Noffsets) { + double xo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 0); + double yo = *(double*)PyArray_GETPTR2(offsets, i % Noffsets, 1); + offset_trans.transform(&xo, &yo); + trans *= agg::trans_affine_translation(xo, yo); + } + ::get_path_extents(path, trans, &x0, &y0, &x1, &y1); } } catch (...) { Modified: branches/transforms/src/agg_py_path_iterator.h =================================================================== --- branches/transforms/src/agg_py_path_iterator.h 2007-11-07 15:30:25 UTC (rev 4141) +++ branches/transforms/src/agg_py_path_iterator.h 2007-11-07 15:31:37 UTC (rev 4142) @@ -23,15 +23,14 @@ if (!vertices || vertices->nd != 2 || vertices->dimensions[1] != 2) throw Py::ValueError("Invalid vertices array."); - codes = (PyArrayObject*)PyArray_FromObject - (codes_obj.ptr(), PyArray_UINT8, 1, 1); - if (!codes) - throw Py::ValueError("Invalid codes array."); - - if (codes->dimensions[0] != vertices->dimensions[0]) - throw Py::ValueError("vertices and codes arrays are not the same length."); + if (codes_obj.ptr() != Py_None) { + codes = (PyArrayObject*)PyArray_FromObject + (codes_obj.ptr(), PyArray_UINT8, 1, 1); + if (!codes) + throw Py::ValueError("Invalid codes array."); + } - m_total_vertices = codes->dimensions[0]; + m_total_vertices = vertices->dimensions[0]; } ~PathIterator() { @@ -46,7 +45,11 @@ throw Py::RuntimeError("Requested vertex past end"); *x = *(double*)PyArray_GETPTR2(vertices, idx, 0); *y = *(double*)PyArray_GETPTR2(vertices, idx, 1); - return code_map[(int)*(char *)PyArray_GETPTR1(codes, idx)]; + if (codes) { + return code_map[(int)*(char *)PyArray_GETPTR1(codes, idx)]; + } else { + return idx == 0 ? agg::path_cmd_move_to : agg::path_cmd_line_to; + } } inline unsigned vertex(double* x, double* y) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-07 20:13:38
|
Revision: 4152 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4152&view=rev Author: mdboom Date: 2007-11-07 12:13:35 -0800 (Wed, 07 Nov 2007) Log Message: ----------- Further speed improvements. Quadmesh extension code (still not as fast as the old version, for various reasons.) Fix bugs in quadmesh masking in PDF and PS backends. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.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/backends/backend_ps.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/lines.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/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -4788,7 +4788,8 @@ vmax = kwargs.pop('vmax', None) shading = kwargs.pop('shading', 'flat') edgecolors = kwargs.pop('edgecolors', 'None') - + antialiased = kwargs.pop('antialiased', False) + X, Y, C = self._pcolorargs('pcolormesh', *args) Ny, Nx = X.shape @@ -4807,7 +4808,7 @@ showedges = 0 collection = mcoll.QuadMesh( - Nx - 1, Ny - 1, coords, showedges) # kwargs are not used + Nx - 1, Ny - 1, coords, showedges, antialiased=antialiased) # kwargs are not used collection.set_alpha(alpha) collection.set_array(C) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) Modified: branches/transforms/lib/matplotlib/backend_bases.py =================================================================== --- branches/transforms/lib/matplotlib/backend_bases.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/backend_bases.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -9,6 +9,7 @@ import numpy as npy import matplotlib.cbook as cbook import matplotlib.colors as colors +import matplotlib.path as path import matplotlib.transforms as transforms import matplotlib.widgets as widgets from matplotlib import rcParams @@ -75,7 +76,31 @@ path, transform = path_id transform = transforms.Affine2D(transform.get_matrix()).translate(xo, yo) self.draw_path(gc, path, transform, rgbFace) + + def draw_quad_mesh(self, master_transform, cliprect, clippath, + clippath_trans, meshWidth, meshHeight, coordinates, + offsets, offsetTrans, facecolors, antialiased, + showedges): + """ + This provides a fallback implementation of draw_quad_mesh that + generates paths and then calls draw_path_collection. + """ + from matplotlib.collections import QuadMesh + paths = QuadMesh.convert_mesh_to_paths( + meshWidth, meshHeight, coordinates) + + if showedges: + edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_) + linewidths = npy.array([1.0], npy.float_) + else: + edgecolors = linewidths = npy.array([], npy.float_) + linewidths = npy.array([0.0], npy.float_) + return self.draw_path_collection( + master_transform, cliprect, clippath, clippath_trans, + paths, [], offsets, offsetTrans, facecolors, edgecolors, + linewidths, [], [antialiased]) + def _iter_collection_raw_paths(self, master_transform, paths, all_transforms): """ This is a helper method (along with _iter_collection) to make @@ -158,6 +183,9 @@ if Nfacecolors == 0: rgbFace = None + if Nedgecolors == 0: + gc.set_linewidth(0.0) + xo, yo = 0, 0 for i in xrange(N): path_id = path_ids[i % Npaths] Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -66,6 +66,7 @@ self.draw_path = self._renderer.draw_path self.draw_markers = self._renderer.draw_markers self.draw_path_collection = self._renderer.draw_path_collection + self.draw_quad_mesh = self._renderer.draw_quad_mesh self.draw_image = self._renderer.draw_image self.copy_from_bbox = self._renderer.copy_from_bbox self.restore_region = self._renderer.restore_region Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -993,7 +993,7 @@ rgba = npy.fromstring(s, npy.uint8) rgba.shape = (h, w, 4) - rgb = rgba[:,:,:3] + rgb = rgba[:,:,:4] return h, w, rgb.tostring() def _gray(self, im, rc=0.3, gc=0.59, bc=0.11): @@ -1601,10 +1601,12 @@ return `d` def _strokep(self): - return self._linewidth > 0 and self._alpha > 0 + return (self._linewidth > 0 and self._alpha > 0 and + (len(self._rgb) <= 3 or self._rgb[3] != 0.0)) def _fillp(self): - return self._fillcolor is not None or self._hatch + return ((self._fillcolor is not None or self._hatch) and + (len(self._fillcolor) <= 3 or self._fillcolor[3] != 0.0)) def close_and_paint(self): if self._strokep(): Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -745,14 +745,20 @@ if debugPS and command: write("% "+command+"\n") - self.set_linewidth(gc.get_linewidth()) - jint = gc.get_joinstyle() - self.set_linejoin(jint) - cint = gc.get_capstyle() - self.set_linecap(cint) - self.set_linedash(*gc.get_dashes()) - if self.linewidth > 0 and stroke: - self.set_color(*gc.get_rgb()[:3]) + stroke = (stroke and gc.get_linewidth() > 0.0 and + (len(gc.get_rgb()) <= 3 or gc.get_rgb()[3] != 0.0)) + fill = (fill and rgbFace is not None and + (len(rgbFace) <= 3 or rgbFace[3] != 0.0)) + + if stroke: + self.set_linewidth(gc.get_linewidth()) + jint = gc.get_joinstyle() + self.set_linejoin(jint) + cint = gc.get_capstyle() + self.set_linecap(cint) + self.set_linedash(*gc.get_dashes()) + if self.linewidth > 0 and stroke: + self.set_color(*gc.get_rgb()[:3]) cliprect = gc.get_clip_rectangle() if cliprect: @@ -767,7 +773,7 @@ write(ps.strip()) write("\n") - if rgbFace is not None and fill: + if fill: #print 'rgbface', rgbFace write("gsave\n") self.set_color(store=0, *rgbFace[:3]) Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -376,53 +376,89 @@ at mesh coordinates (0, 0), then the one at (0, 1), then at (0, 2) .. (0, meshWidth), (1, 0), (1, 1), and so on. """ - def __init__(self, meshWidth, meshHeight, coordinates, showedges): - Path = mpath.Path - + def __init__(self, meshWidth, meshHeight, coordinates, showedges, antialiased=True): Collection.__init__(self) self._meshWidth = meshWidth self._meshHeight = meshHeight self._coordinates = coordinates self._showedges = showedges + self._antialiased = antialiased + self._paths = None + + self._bbox = transforms.Bbox.unit() + self._bbox.update_from_data_xy(coordinates.reshape( + ((meshWidth + 1) * (meshHeight + 1), 2))) + + def get_paths(self, dataTrans=None): + import pdb + pdb.set_trace() + if self._paths is None: + self._paths = self.convert_mesh_to_paths( + self._meshWidth, self._meshHeight, self._coordinates) + return self._paths + + #@staticmethod + def convert_mesh_to_paths(meshWidth, meshHeight, coordinates): + Path = mpath.Path + c = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) # We could let the Path constructor generate the codes for us, # but this is faster, since we know they'll always be the same codes = npy.array( [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY], Path.code_type) - + points = npy.concatenate(( - c[0:-1, 0:-1], - c[0:-1, 1: ], - c[1: , 1: ], - c[1: , 0:-1], - c[0:-1, 0:-1] - ), axis=2) + c[0:-1, 0:-1], + c[0:-1, 1: ], + c[1: , 1: ], + c[1: , 0:-1], + c[0:-1, 0:-1] + ), axis=2) points = points.reshape((meshWidth * meshHeight, 5, 2)) - self._paths = [Path(x, codes) for x in points] - - self._bbox = transforms.Bbox.unit() - self._bbox.update_from_data_xy(c.reshape( - ((meshWidth + 1) * (meshHeight + 1), 2))) - - def get_paths(self, dataTrans=None): - return self._paths - + return [Path(x, codes) for x in points] + convert_mesh_to_paths = staticmethod(convert_mesh_to_paths) + def get_datalim(self, transData): return self._bbox def draw(self, renderer): - self.update_scalarmappable() + if not self.get_visible(): return + renderer.open_group(self.__class__.__name__) + transform = self.get_transform() + transOffset = self._transOffset + offsets = self._offsets - self._linewidths = (1,) - if self._showedges: - self._edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_) + if self.have_units(): + if len(self._offsets): + xs = self.convert_xunits(self._offsets[:0]) + ys = self.convert_yunits(self._offsets[:1]) + offsets = zip(xs, ys) + + if len(offsets) == 0: + offsets = npy.array([], npy.float_) else: - self._edgecolors = self._facecolors + offsets = npy.asarray(offsets, npy.float_) - Collection.draw(self, renderer) + self.update_scalarmappable() + clippath, clippath_trans = self.get_transformed_clip_path_and_affine() + if clippath_trans is not None: + clippath_trans = clippath_trans.frozen() + + assert transform.is_affine + if not transOffset.is_affine: + offsets = transOffset.transform_non_affine(offsets) + transOffset = transOffset.get_affine() + + renderer.draw_quad_mesh( + transform.frozen(), self.clipbox, clippath, clippath_trans, + self._meshWidth, self._meshHeight, self._coordinates, + offsets, transOffset, self._facecolors, self._antialiased, + self._showedges) + renderer.close_group(self.__class__.__name__) + class PolyCollection(Collection): def __init__(self, verts, **kwargs): """ Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-07 20:13:35 UTC (rev 4152) @@ -388,8 +388,10 @@ 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)))): + (x is not self._xorig and + (x.shape != self._xorig.shape or npy.any(x != self._xorig))) or + (y is not self._yorig and + (y.shape != self._yorig.shape or npy.any(y != self._yorig)))): self._xorig = x self._yorig = y self.recache() Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/src/_backend_agg.cpp 2007-11-07 20:13:35 UTC (rev 4152) @@ -302,7 +302,7 @@ template<class R> void -RendererAgg::set_clipbox(Py::Object& cliprect, R rasterizer) { +RendererAgg::set_clipbox(const Py::Object& cliprect, R rasterizer) { //set the clip rectangle from the gc _VERBOSE("RendererAgg::set_clipbox"); @@ -775,10 +775,11 @@ return Py::Object(); } -void RendererAgg::_draw_path(PathIterator& path, agg::trans_affine trans, +template<class PathIteratorType> +void RendererAgg::_draw_path(PathIteratorType& path, agg::trans_affine trans, bool has_clippath, const facepair_t& face, - const GCAgg& gc) { - typedef agg::conv_transform<PathIterator> transformed_path_t; + const GCAgg& gc, bool check_snap) { + typedef agg::conv_transform<PathIteratorType> transformed_path_t; typedef conv_quantize<transformed_path_t> quantize_t; typedef agg::conv_curve<quantize_t> curve_t; typedef agg::conv_stroke<curve_t> stroke_t; @@ -793,7 +794,9 @@ trans *= agg::trans_affine_translation(0.0, (double)height); // Build the transform stack - bool snap = should_snap(path, trans); + bool snap = false; + if (check_snap) + snap = should_snap(path, trans); transformed_path_t tpath(path, trans); quantize_t quantized(tpath, snap); // Benchmarking shows that there is no noticable slowdown to always @@ -908,31 +911,28 @@ set_clipbox(gc.cliprect, theRasterizer); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); - _draw_path(path, trans, has_clippath, face, gc); + _draw_path(path, trans, has_clippath, face, gc, true); return Py::Object(); } +template<class PathGenerator> Py::Object -RendererAgg::draw_path_collection(const Py::Tuple& args) { - _VERBOSE("RendererAgg::draw_path_collection"); - args.verify_length(13); - - //segments, trans, clipbox, colors, linewidths, antialiaseds - agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[0]); - Py::Object cliprect = args[1]; - Py::Object clippath = args[2]; - agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3], false); - Py::SeqBase<Py::Object> paths = args[4]; - Py::SeqBase<Py::Object> transforms_obj = args[5]; - Py::Object offsets_obj = args[6]; - agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7]); - Py::Object facecolors_obj = args[8]; - Py::Object edgecolors_obj = args[9]; - Py::SeqBase<Py::Float> linewidths = args[10]; - Py::SeqBase<Py::Object> linestyles_obj = args[11]; - Py::SeqBase<Py::Int> antialiaseds = args[12]; - +RendererAgg::_draw_path_collection_generic + (const agg::trans_affine& master_transform, + const Py::Object& cliprect, + const Py::Object& clippath, + const agg::trans_affine& clippath_trans, + const PathGenerator& path_generator, + const Py::SeqBase<Py::Object>& transforms_obj, + const Py::Object& offsets_obj, + const agg::trans_affine& offset_trans, + const Py::Object& facecolors_obj, + const Py::Object& edgecolors_obj, + const Py::SeqBase<Py::Float>& linewidths, + const Py::SeqBase<Py::Object>& linestyles_obj, + const Py::SeqBase<Py::Int>& antialiaseds, + bool check_snap) { GCAgg gc(dpi); PyArrayObject* offsets = NULL; @@ -961,7 +961,7 @@ (edgecolors->nd == 2 && edgecolors->dimensions[1] != 4)) throw Py::ValueError("Edgecolors must be a Nx4 numpy array"); - size_t Npaths = paths.length(); + size_t Npaths = path_generator.num_paths(); size_t Noffsets = offsets->dimensions[0]; size_t N = std::max(Npaths, Noffsets); size_t Ntransforms = std::min(transforms_obj.length(), N); @@ -1010,7 +1010,7 @@ agg::trans_affine trans; for (i = 0; i < N; ++i) { - PathIterator path(paths[i % Npaths]); + typename PathGenerator::path_iterator path = path_generator(i); if (Ntransforms) { trans = transforms[i % Ntransforms]; } else { @@ -1038,14 +1038,20 @@ *(double*)PyArray_GETPTR2(edgecolors, ei, 1), *(double*)PyArray_GETPTR2(edgecolors, ei, 2), *(double*)PyArray_GETPTR2(edgecolors, ei, 3)); - gc.linewidth = double(Py::Float(linewidths[i % Nlinewidths])) * dpi/72.0; - gc.dashes = dashes[i % Nlinestyles].second; - gc.dashOffset = dashes[i % Nlinestyles].first; + if (Nlinewidths) { + gc.linewidth = double(Py::Float(linewidths[i % Nlinewidths])) * dpi/72.0; + } else { + gc.linewidth = 1.0; + } + if (Nlinestyles) { + gc.dashes = dashes[i % Nlinestyles].second; + gc.dashOffset = dashes[i % Nlinestyles].first; + } } gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); - _draw_path(path, trans, has_clippath, face, gc); + _draw_path(path, trans, has_clippath, face, gc, check_snap); } } catch (...) { Py_XDECREF(offsets); @@ -1059,12 +1065,213 @@ } +class PathListGenerator { + const Py::SeqBase<Py::Object>& m_paths; + +public: + typedef PathIterator path_iterator; + + inline PathListGenerator(const Py::SeqBase<Py::Object>& paths) : + m_paths(paths) { + + } + + inline size_t num_paths() const { + return m_paths.size(); + } + + inline path_iterator operator()(size_t i) const { + return PathIterator(m_paths[i]); + } +}; + Py::Object +RendererAgg::draw_path_collection(const Py::Tuple& args) { + _VERBOSE("RendererAgg::draw_path_collection"); + args.verify_length(13); + + //segments, trans, clipbox, colors, linewidths, antialiaseds + agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[0]); + Py::Object cliprect = args[1]; + Py::Object clippath = args[2]; + agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3], false); + Py::SeqBase<Py::Object> paths = args[4]; + Py::SeqBase<Py::Object> transforms_obj = args[5]; + Py::Object offsets_obj = args[6]; + agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7]); + Py::Object facecolors_obj = args[8]; + Py::Object edgecolors_obj = args[9]; + Py::SeqBase<Py::Float> linewidths = args[10]; + Py::SeqBase<Py::Object> linestyles_obj = args[11]; + Py::SeqBase<Py::Int> antialiaseds = args[12]; + + PathListGenerator path_generator(paths); + + _draw_path_collection_generic + (master_transform, + cliprect, + clippath, + clippath_trans, + path_generator, + transforms_obj, + offsets_obj, + offset_trans, + facecolors_obj, + edgecolors_obj, + linewidths, + linestyles_obj, + antialiaseds, + true); + + return Py::Object(); +} + +class QuadMeshGenerator { + size_t m_meshWidth; + size_t m_meshHeight; + PyArrayObject* m_coordinates; + + class QuadMeshPathIterator { + size_t m_iterator; + size_t m_m, m_n; + PyArrayObject* m_coordinates; + public: + QuadMeshPathIterator(size_t m, size_t n, PyArrayObject* coordinates) : + m_iterator(0), m_m(m), m_n(n), m_coordinates(coordinates) { + } + + static const size_t offsets[5][2]; + + inline unsigned vertex(unsigned idx, double* x, double* y) { + size_t m = m_m + offsets[idx][0]; + size_t n = m_n + offsets[idx][1]; + *x = *(double*)PyArray_GETPTR3(m_coordinates, m, n, 0); + *y = *(double*)PyArray_GETPTR3(m_coordinates, m, n, 1); + return (idx == 0) ? agg::path_cmd_move_to : agg::path_cmd_line_to; + } + + inline unsigned vertex(double* x, double* y) { + if (m_iterator >= total_vertices()) return agg::path_cmd_stop; + return vertex(m_iterator++, x, y); + } + + inline void rewind(unsigned path_id) { + m_iterator = path_id; + } + + inline unsigned total_vertices() { + return 5; + } + + inline bool has_curves() { + return false; + } + }; + +public: + typedef QuadMeshPathIterator path_iterator; + + inline QuadMeshGenerator(size_t meshWidth, size_t meshHeight, const Py::Object& coordinates) : + m_meshWidth(meshWidth), m_meshHeight(meshHeight), m_coordinates(NULL) { + PyArrayObject* coordinates_array = (PyArrayObject*)PyArray_FromObject(coordinates.ptr(), PyArray_DOUBLE, 1, 3); + if (!coordinates_array) { + throw Py::ValueError("Invalid coordinates array."); + } + + Py::Tuple shape(3); + shape[0] = Py::Int((int)meshHeight + 1); + shape[1] = Py::Int((int)meshWidth + 1); + shape[2] = Py::Int(2); + m_coordinates = (PyArrayObject*)PyArray_Reshape(coordinates_array, shape.ptr()); + } + + inline ~QuadMeshGenerator() { + Py_XDECREF(m_coordinates); + } + + inline size_t num_paths() const { + return m_meshWidth * m_meshHeight; + } + + inline path_iterator operator()(size_t i) const { + return QuadMeshPathIterator(i % m_meshHeight, i / m_meshHeight, m_coordinates); + } +}; + +const size_t QuadMeshGenerator::QuadMeshPathIterator::offsets[5][2] = { + { 0, 0 }, + { 0, 1 }, + { 1, 1 }, + { 1, 0 }, + { 0, 0 } }; + +Py::Object +RendererAgg::draw_quad_mesh(const Py::Tuple& args) { + _VERBOSE("RendererAgg::draw_quad_mesh"); + args.verify_length(12); + + //segments, trans, clipbox, colors, linewidths, antialiaseds + agg::trans_affine master_transform = py_to_agg_transformation_matrix(args[0]); + Py::Object cliprect = args[1]; + Py::Object clippath = args[2]; + agg::trans_affine clippath_trans = py_to_agg_transformation_matrix(args[3], false); + size_t mesh_width = Py::Int(args[4]); + size_t mesh_height = Py::Int(args[5]); + Py::Object coordinates = args[6]; + Py::Object offsets_obj = args[7]; + agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[8]); + Py::Object facecolors_obj = args[9]; + bool antialiased = (bool)Py::Int(args[10]); + bool showedges = (bool)Py::Int(args[11]); + + QuadMeshGenerator path_generator(mesh_width, mesh_height, coordinates); + + Py::SeqBase<Py::Object> transforms_obj; + Py::Object edgecolors_obj; + Py::Tuple linewidths(1); + linewidths[0] = Py::Float(1.0); + Py::SeqBase<Py::Object> linestyles_obj; + Py::Tuple antialiaseds(1); + antialiaseds[0] = Py::Int(antialiased ? 1 : 0); + + if (showedges) { + int dims[] = { 1, 4, 0 }; + double data[] = { 0, 0, 0, 1 }; + edgecolors_obj = PyArray_FromDimsAndData(2, dims, PyArray_DOUBLE, (char*)data); + } else { + if (antialiased) { + edgecolors_obj = facecolors_obj; + } else { + int dims[] = { 0, 0 }; + edgecolors_obj = PyArray_FromDims(1, dims, PyArray_DOUBLE); + } + } + + _draw_path_collection_generic + (master_transform, + cliprect, + clippath, + clippath_trans, + path_generator, + transforms_obj, + offsets_obj, + offset_trans, + facecolors_obj, + edgecolors_obj, + linewidths, + linestyles_obj, + antialiaseds, + false); + + return Py::Object(); +} + +Py::Object RendererAgg::write_rgba(const Py::Tuple& args) { _VERBOSE("RendererAgg::write_rgba"); args.verify_length(1); - std::string fname = Py::String( args[0]); + std::string fname = Py::String(args[0]); std::ofstream of2( fname.c_str(), std::ios::binary|std::ios::out); for (size_t i=0; i<NUMBYTES; i++) { @@ -1073,7 +1280,6 @@ return Py::Object(); } - // this code is heavily adapted from the paint license, which is in // the file paint.license (BSD compatible) included in this // distribution. TODO, add license file to MANIFEST.in and CVS @@ -1398,6 +1604,8 @@ "draw_path(gc, path, transform, rgbFace)\n"); add_varargs_method("draw_path_collection", &RendererAgg::draw_path_collection, "draw_path_collection(master_transform, cliprect, clippath, clippath_trans, paths, transforms, offsets, offsetTrans, facecolors, edgecolors, linewidths, linestyles, antialiaseds)\n"); + add_varargs_method("draw_quad_mesh", &RendererAgg::draw_quad_mesh, + "draw_quad_mesh(master_transform, cliprect, clippath, clippath_trans, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiaseds, showedges)\n"); add_varargs_method("draw_markers", &RendererAgg::draw_markers, "draw_markers(gc, marker_path, marker_trans, path, rgbFace)\n"); add_varargs_method("draw_text_image", &RendererAgg::draw_text_image, Modified: branches/transforms/src/_backend_agg.h =================================================================== --- branches/transforms/src/_backend_agg.h 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/src/_backend_agg.h 2007-11-07 20:13:35 UTC (rev 4152) @@ -165,7 +165,9 @@ Py::Object draw_image(const Py::Tuple & args); Py::Object draw_path(const Py::Tuple & args); Py::Object draw_path_collection(const Py::Tuple & args); + Py::Object RendererAgg::draw_quad_mesh(const Py::Tuple& args); + Py::Object write_rgba(const Py::Tuple & args); Py::Object write_png(const Py::Tuple & args); Py::Object tostring_rgb(const Py::Tuple & args); @@ -215,10 +217,28 @@ facepair_t _get_rgba_face(const Py::Object& rgbFace, double alpha); bool bbox_to_rect(const Py::Object& bbox, double* l, double* b, double* r, double* t); template<class R> - void set_clipbox(Py::Object& cliprect, R rasterizer); + void set_clipbox(const Py::Object& cliprect, R rasterizer); bool render_clippath(const Py::Object& clippath, const agg::trans_affine& clippath_trans); - void _draw_path(PathIterator& path, agg::trans_affine trans, - bool has_clippath, const facepair_t& face, const GCAgg& gc); + template<class PathIteratorType> + void _draw_path(PathIteratorType& path, agg::trans_affine trans, + bool has_clippath, const facepair_t& face, const GCAgg& gc, bool check_snap); + template<class PathGenerator> + Py::Object + _draw_path_collection_generic + (const agg::trans_affine& master_transform, + const Py::Object& cliprect, + const Py::Object& clippath, + const agg::trans_affine& clippath_trans, + const PathGenerator& path_finder, + const Py::SeqBase<Py::Object>& transforms_obj, + const Py::Object& offsets_obj, + const agg::trans_affine& offset_trans, + const Py::Object& facecolors_obj, + const Py::Object& edgecolors_obj, + const Py::SeqBase<Py::Float>& linewidths, + const Py::SeqBase<Py::Object>& linestyles_obj, + const Py::SeqBase<Py::Int>& antialiaseds, + bool check_snap); private: Py::Object lastclippath; Modified: branches/transforms/src/agg_py_path_iterator.h =================================================================== --- branches/transforms/src/agg_py_path_iterator.h 2007-11-07 18:34:30 UTC (rev 4151) +++ branches/transforms/src/agg_py_path_iterator.h 2007-11-07 20:13:35 UTC (rev 4152) @@ -7,35 +7,35 @@ #include "agg_path_storage.h" class PathIterator { - PyArrayObject* vertices; - PyArrayObject* codes; + PyArrayObject* m_vertices; + PyArrayObject* m_codes; size_t m_iterator; size_t m_total_vertices; public: PathIterator(const Py::Object& path_obj) : - vertices(NULL), codes(NULL), m_iterator(0) { + m_vertices(NULL), m_codes(NULL), m_iterator(0) { Py::Object vertices_obj = path_obj.getAttr("vertices"); Py::Object codes_obj = path_obj.getAttr("codes"); - vertices = (PyArrayObject*)PyArray_FromObject + m_vertices = (PyArrayObject*)PyArray_FromObject (vertices_obj.ptr(), PyArray_DOUBLE, 2, 2); - if (!vertices || vertices->nd != 2 || vertices->dimensions[1] != 2) + if (!m_vertices || m_vertices->nd != 2 || m_vertices->dimensions[1] != 2) throw Py::ValueError("Invalid vertices array."); if (codes_obj.ptr() != Py_None) { - codes = (PyArrayObject*)PyArray_FromObject + m_codes = (PyArrayObject*)PyArray_FromObject (codes_obj.ptr(), PyArray_UINT8, 1, 1); - if (!codes) + if (!m_codes) throw Py::ValueError("Invalid codes array."); } - m_total_vertices = vertices->dimensions[0]; + m_total_vertices = m_vertices->dimensions[0]; } ~PathIterator() { - Py_XDECREF(vertices); - Py_XDECREF(codes); + Py_XDECREF(m_vertices); + Py_XDECREF(m_codes); } static const char code_map[]; @@ -43,10 +43,10 @@ inline unsigned vertex(unsigned idx, double* x, double* y) { if (idx > m_total_vertices) throw Py::RuntimeError("Requested vertex past end"); - *x = *(double*)PyArray_GETPTR2(vertices, idx, 0); - *y = *(double*)PyArray_GETPTR2(vertices, idx, 1); - if (codes) { - return code_map[(int)*(char *)PyArray_GETPTR1(codes, idx)]; + *x = *(double*)PyArray_GETPTR2(m_vertices, idx, 0); + *y = *(double*)PyArray_GETPTR2(m_vertices, idx, 1); + if (m_codes) { + return code_map[(int)*(char *)PyArray_GETPTR1(m_codes, idx)]; } else { return idx == 0 ? agg::path_cmd_move_to : agg::path_cmd_line_to; } @@ -64,6 +64,10 @@ inline unsigned total_vertices() { return m_total_vertices; } + + inline bool has_curves() { + return m_codes; + } }; // Maps path codes on the Python side to agg path commands This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-09 19:48:58
|
Revision: 4192 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4192&view=rev Author: mdboom Date: 2007-11-09 11:48:42 -0800 (Fri, 09 Nov 2007) Log Message: ----------- Merged revisions 4135-4190 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4155 | dsdale | 2007-11-07 19:09:17 -0500 (Wed, 07 Nov 2007) | 2 lines move configobj.py to lib/, install in site-packages only if required ........ r4156 | dsdale | 2007-11-07 19:24:57 -0500 (Wed, 07 Nov 2007) | 3 lines update enthought package to version 2.6b1, stripped of setuptools installed in site-packages, if not already present ........ r4160 | mdboom | 2007-11-08 09:31:15 -0500 (Thu, 08 Nov 2007) | 2 lines Throw in dummy characters for symbols not in the Bakoma fonts. ........ r4167 | dsdale | 2007-11-08 18:25:44 -0500 (Thu, 08 Nov 2007) | 3 lines move pyparsing from lib/matplotlib/ to lib/ install pyparsing only if not already available ........ r4168 | jdh2358 | 2007-11-08 18:29:46 -0500 (Thu, 08 Nov 2007) | 2 lines added recarray utils module ........ r4169 | dsdale | 2007-11-08 19:19:45 -0500 (Thu, 08 Nov 2007) | 2 lines updated pyparsing to version 1.4.8 ........ r4170 | dsdale | 2007-11-08 19:22:03 -0500 (Thu, 08 Nov 2007) | 3 lines added checks that also print version numbers for pyparsing, pytz, dateutil, configobj ........ r4171 | dsdale | 2007-11-08 19:31:48 -0500 (Thu, 08 Nov 2007) | 2 lines note pyparsing change to API_CHANGES ........ r4172 | dsdale | 2007-11-08 20:37:02 -0500 (Thu, 08 Nov 2007) | 2 lines remove old version of pytz ........ r4173 | dsdale | 2007-11-08 20:40:54 -0500 (Thu, 08 Nov 2007) | 2 lines added pytz-2007g ........ r4174 | dsdale | 2007-11-08 20:43:18 -0500 (Thu, 08 Nov 2007) | 2 lines fixed bug in dateutil version check ........ r4175 | jdh2358 | 2007-11-08 21:55:47 -0500 (Thu, 08 Nov 2007) | 2 lines reverted rec utils to mlab ........ r4176 | efiring | 2007-11-09 02:25:08 -0500 (Fri, 09 Nov 2007) | 2 lines Pylab uses numpy instead of oldnumeric ........ r4177 | dsdale | 2007-11-09 08:08:48 -0500 (Fri, 09 Nov 2007) | 2 lines move pyparsing back into mpl namespace ........ r4178 | mdboom | 2007-11-09 08:10:12 -0500 (Fri, 09 Nov 2007) | 3 lines Avoid annoying Qt4 messages when mpl raises an exception. (Thanks to Martin Teichmann in patch 1828813) ........ r4179 | mdboom | 2007-11-09 08:19:38 -0500 (Fri, 09 Nov 2007) | 2 lines Fix font caching bug on OSX ........ r4180 | dsdale | 2007-11-09 08:20:10 -0500 (Fri, 09 Nov 2007) | 3 lines committed Martin Teichmann's patch 1828813 to fix qt4 error messages related to QPainter ........ r4181 | mdboom | 2007-11-09 08:47:40 -0500 (Fri, 09 Nov 2007) | 3 lines Remove duplicate line caused by myself and Darren committing the same patch and virtually the same time. ........ r4182 | dsdale | 2007-11-09 08:49:54 -0500 (Fri, 09 Nov 2007) | 2 lines updated CHANGELOG and API_CHANGES ........ r4183 | dsdale | 2007-11-09 09:24:41 -0500 (Fri, 09 Nov 2007) | 2 lines updated dependency report during build process ........ r4187 | jdh2358 | 2007-11-09 11:42:55 -0500 (Fri, 09 Nov 2007) | 2 lines added face and edge color = 'None' support to patches ........ r4188 | jdh2358 | 2007-11-09 11:43:38 -0500 (Fri, 09 Nov 2007) | 2 lines removed unneeded draw command from tkagg ........ Modified Paths: -------------- branches/transforms/API_CHANGES branches/transforms/CHANGELOG branches/transforms/examples/image_demo2.py branches/transforms/examples/loadrec.py branches/transforms/examples/mathtext_demo.py branches/transforms/examples/mathtext_examples.py branches/transforms/examples/mri_with_eeg.py branches/transforms/examples/rc_traits.py branches/transforms/lib/dateutil/__init__.py branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/backend_bases.py branches/transforms/lib/matplotlib/backends/backend_qt4agg.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/config/checkdep.py branches/transforms/lib/matplotlib/font_manager.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/pylab.py branches/transforms/lib/matplotlib/pyparsing.py branches/transforms/setup.py branches/transforms/setupext.py Added Paths: ----------- branches/transforms/lib/configobj.py branches/transforms/lib/pytz/ branches/transforms/lib/pytz/CHANGES.txt branches/transforms/lib/pytz/LICENSE.txt branches/transforms/lib/pytz/README.txt branches/transforms/lib/pytz/__init__.py branches/transforms/lib/pytz/reference.py branches/transforms/lib/pytz/tzfile.py branches/transforms/lib/pytz/tzinfo.py branches/transforms/lib/pytz/zoneinfo/ branches/transforms/lib/pytz/zoneinfo/Africa/ branches/transforms/lib/pytz/zoneinfo/Africa/Abidjan branches/transforms/lib/pytz/zoneinfo/Africa/Accra branches/transforms/lib/pytz/zoneinfo/Africa/Addis_Ababa branches/transforms/lib/pytz/zoneinfo/Africa/Algiers branches/transforms/lib/pytz/zoneinfo/Africa/Asmara branches/transforms/lib/pytz/zoneinfo/Africa/Asmera branches/transforms/lib/pytz/zoneinfo/Africa/Bamako branches/transforms/lib/pytz/zoneinfo/Africa/Bangui branches/transforms/lib/pytz/zoneinfo/Africa/Banjul branches/transforms/lib/pytz/zoneinfo/Africa/Bissau branches/transforms/lib/pytz/zoneinfo/Africa/Blantyre branches/transforms/lib/pytz/zoneinfo/Africa/Brazzaville branches/transforms/lib/pytz/zoneinfo/Africa/Bujumbura branches/transforms/lib/pytz/zoneinfo/Africa/Cairo branches/transforms/lib/pytz/zoneinfo/Africa/Casablanca branches/transforms/lib/pytz/zoneinfo/Africa/Ceuta branches/transforms/lib/pytz/zoneinfo/Africa/Conakry branches/transforms/lib/pytz/zoneinfo/Africa/Dakar branches/transforms/lib/pytz/zoneinfo/Africa/Dar_es_Salaam branches/transforms/lib/pytz/zoneinfo/Africa/Djibouti branches/transforms/lib/pytz/zoneinfo/Africa/Douala branches/transforms/lib/pytz/zoneinfo/Africa/El_Aaiun branches/transforms/lib/pytz/zoneinfo/Africa/Freetown branches/transforms/lib/pytz/zoneinfo/Africa/Gaborone branches/transforms/lib/pytz/zoneinfo/Africa/Harare branches/transforms/lib/pytz/zoneinfo/Africa/Johannesburg branches/transforms/lib/pytz/zoneinfo/Africa/Kampala branches/transforms/lib/pytz/zoneinfo/Africa/Khartoum branches/transforms/lib/pytz/zoneinfo/Africa/Kigali branches/transforms/lib/pytz/zoneinfo/Africa/Kinshasa branches/transforms/lib/pytz/zoneinfo/Africa/Lagos branches/transforms/lib/pytz/zoneinfo/Africa/Libreville branches/transforms/lib/pytz/zoneinfo/Africa/Lome branches/transforms/lib/pytz/zoneinfo/Africa/Luanda branches/transforms/lib/pytz/zoneinfo/Africa/Lubumbashi branches/transforms/lib/pytz/zoneinfo/Africa/Lusaka branches/transforms/lib/pytz/zoneinfo/Africa/Malabo branches/transforms/lib/pytz/zoneinfo/Africa/Maputo branches/transforms/lib/pytz/zoneinfo/Africa/Maseru branches/transforms/lib/pytz/zoneinfo/Africa/Mbabane branches/transforms/lib/pytz/zoneinfo/Africa/Mogadishu branches/transforms/lib/pytz/zoneinfo/Africa/Monrovia branches/transforms/lib/pytz/zoneinfo/Africa/Nairobi branches/transforms/lib/pytz/zoneinfo/Africa/Ndjamena branches/transforms/lib/pytz/zoneinfo/Africa/Niamey branches/transforms/lib/pytz/zoneinfo/Africa/Nouakchott branches/transforms/lib/pytz/zoneinfo/Africa/Ouagadougou branches/transforms/lib/pytz/zoneinfo/Africa/Porto-Novo branches/transforms/lib/pytz/zoneinfo/Africa/Sao_Tome branches/transforms/lib/pytz/zoneinfo/Africa/Timbuktu branches/transforms/lib/pytz/zoneinfo/Africa/Tripoli branches/transforms/lib/pytz/zoneinfo/Africa/Tunis branches/transforms/lib/pytz/zoneinfo/Africa/Windhoek branches/transforms/lib/pytz/zoneinfo/America/ branches/transforms/lib/pytz/zoneinfo/America/Adak branches/transforms/lib/pytz/zoneinfo/America/Anchorage branches/transforms/lib/pytz/zoneinfo/America/Anguilla branches/transforms/lib/pytz/zoneinfo/America/Antigua branches/transforms/lib/pytz/zoneinfo/America/Araguaina branches/transforms/lib/pytz/zoneinfo/America/Argentina/ branches/transforms/lib/pytz/zoneinfo/America/Argentina/Buenos_Aires branches/transforms/lib/pytz/zoneinfo/America/Argentina/Catamarca branches/transforms/lib/pytz/zoneinfo/America/Argentina/ComodRivadavia branches/transforms/lib/pytz/zoneinfo/America/Argentina/Cordoba branches/transforms/lib/pytz/zoneinfo/America/Argentina/Jujuy branches/transforms/lib/pytz/zoneinfo/America/Argentina/La_Rioja branches/transforms/lib/pytz/zoneinfo/America/Argentina/Mendoza branches/transforms/lib/pytz/zoneinfo/America/Argentina/Rio_Gallegos branches/transforms/lib/pytz/zoneinfo/America/Argentina/San_Juan branches/transforms/lib/pytz/zoneinfo/America/Argentina/Tucuman branches/transforms/lib/pytz/zoneinfo/America/Argentina/Ushuaia branches/transforms/lib/pytz/zoneinfo/America/Aruba branches/transforms/lib/pytz/zoneinfo/America/Asuncion branches/transforms/lib/pytz/zoneinfo/America/Atikokan branches/transforms/lib/pytz/zoneinfo/America/Atka branches/transforms/lib/pytz/zoneinfo/America/Bahia branches/transforms/lib/pytz/zoneinfo/America/Barbados branches/transforms/lib/pytz/zoneinfo/America/Belem branches/transforms/lib/pytz/zoneinfo/America/Belize branches/transforms/lib/pytz/zoneinfo/America/Blanc-Sablon branches/transforms/lib/pytz/zoneinfo/America/Boa_Vista branches/transforms/lib/pytz/zoneinfo/America/Bogota branches/transforms/lib/pytz/zoneinfo/America/Boise branches/transforms/lib/pytz/zoneinfo/America/Buenos_Aires branches/transforms/lib/pytz/zoneinfo/America/Cambridge_Bay branches/transforms/lib/pytz/zoneinfo/America/Campo_Grande branches/transforms/lib/pytz/zoneinfo/America/Cancun branches/transforms/lib/pytz/zoneinfo/America/Caracas branches/transforms/lib/pytz/zoneinfo/America/Catamarca branches/transforms/lib/pytz/zoneinfo/America/Cayenne branches/transforms/lib/pytz/zoneinfo/America/Cayman branches/transforms/lib/pytz/zoneinfo/America/Chicago branches/transforms/lib/pytz/zoneinfo/America/Chihuahua branches/transforms/lib/pytz/zoneinfo/America/Coral_Harbour branches/transforms/lib/pytz/zoneinfo/America/Cordoba branches/transforms/lib/pytz/zoneinfo/America/Costa_Rica branches/transforms/lib/pytz/zoneinfo/America/Cuiaba branches/transforms/lib/pytz/zoneinfo/America/Curacao branches/transforms/lib/pytz/zoneinfo/America/Danmarkshavn branches/transforms/lib/pytz/zoneinfo/America/Dawson branches/transforms/lib/pytz/zoneinfo/America/Dawson_Creek branches/transforms/lib/pytz/zoneinfo/America/Denver branches/transforms/lib/pytz/zoneinfo/America/Detroit branches/transforms/lib/pytz/zoneinfo/America/Dominica branches/transforms/lib/pytz/zoneinfo/America/Edmonton branches/transforms/lib/pytz/zoneinfo/America/Eirunepe branches/transforms/lib/pytz/zoneinfo/America/El_Salvador branches/transforms/lib/pytz/zoneinfo/America/Ensenada branches/transforms/lib/pytz/zoneinfo/America/Fort_Wayne branches/transforms/lib/pytz/zoneinfo/America/Fortaleza branches/transforms/lib/pytz/zoneinfo/America/Glace_Bay branches/transforms/lib/pytz/zoneinfo/America/Godthab branches/transforms/lib/pytz/zoneinfo/America/Goose_Bay branches/transforms/lib/pytz/zoneinfo/America/Grand_Turk branches/transforms/lib/pytz/zoneinfo/America/Grenada branches/transforms/lib/pytz/zoneinfo/America/Guadeloupe branches/transforms/lib/pytz/zoneinfo/America/Guatemala branches/transforms/lib/pytz/zoneinfo/America/Guayaquil branches/transforms/lib/pytz/zoneinfo/America/Guyana branches/transforms/lib/pytz/zoneinfo/America/Halifax branches/transforms/lib/pytz/zoneinfo/America/Havana branches/transforms/lib/pytz/zoneinfo/America/Hermosillo branches/transforms/lib/pytz/zoneinfo/America/Indiana/ branches/transforms/lib/pytz/zoneinfo/America/Indiana/Indianapolis branches/transforms/lib/pytz/zoneinfo/America/Indiana/Knox branches/transforms/lib/pytz/zoneinfo/America/Indiana/Marengo branches/transforms/lib/pytz/zoneinfo/America/Indiana/Petersburg branches/transforms/lib/pytz/zoneinfo/America/Indiana/Tell_City branches/transforms/lib/pytz/zoneinfo/America/Indiana/Vevay branches/transforms/lib/pytz/zoneinfo/America/Indiana/Vincennes branches/transforms/lib/pytz/zoneinfo/America/Indiana/Winamac branches/transforms/lib/pytz/zoneinfo/America/Indianapolis branches/transforms/lib/pytz/zoneinfo/America/Inuvik branches/transforms/lib/pytz/zoneinfo/America/Iqaluit branches/transforms/lib/pytz/zoneinfo/America/Jamaica branches/transforms/lib/pytz/zoneinfo/America/Jujuy branches/transforms/lib/pytz/zoneinfo/America/Juneau branches/transforms/lib/pytz/zoneinfo/America/Kentucky/ branches/transforms/lib/pytz/zoneinfo/America/Kentucky/Louisville branches/transforms/lib/pytz/zoneinfo/America/Kentucky/Monticello branches/transforms/lib/pytz/zoneinfo/America/Knox_IN branches/transforms/lib/pytz/zoneinfo/America/La_Paz branches/transforms/lib/pytz/zoneinfo/America/Lima branches/transforms/lib/pytz/zoneinfo/America/Los_Angeles branches/transforms/lib/pytz/zoneinfo/America/Louisville branches/transforms/lib/pytz/zoneinfo/America/Maceio branches/transforms/lib/pytz/zoneinfo/America/Managua branches/transforms/lib/pytz/zoneinfo/America/Manaus branches/transforms/lib/pytz/zoneinfo/America/Martinique branches/transforms/lib/pytz/zoneinfo/America/Mazatlan branches/transforms/lib/pytz/zoneinfo/America/Mendoza branches/transforms/lib/pytz/zoneinfo/America/Menominee branches/transforms/lib/pytz/zoneinfo/America/Merida branches/transforms/lib/pytz/zoneinfo/America/Mexico_City branches/transforms/lib/pytz/zoneinfo/America/Miquelon branches/transforms/lib/pytz/zoneinfo/America/Moncton branches/transforms/lib/pytz/zoneinfo/America/Monterrey branches/transforms/lib/pytz/zoneinfo/America/Montevideo branches/transforms/lib/pytz/zoneinfo/America/Montreal branches/transforms/lib/pytz/zoneinfo/America/Montserrat branches/transforms/lib/pytz/zoneinfo/America/Nassau branches/transforms/lib/pytz/zoneinfo/America/New_York branches/transforms/lib/pytz/zoneinfo/America/Nipigon branches/transforms/lib/pytz/zoneinfo/America/Nome branches/transforms/lib/pytz/zoneinfo/America/Noronha branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/ branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/Center branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/New_Salem branches/transforms/lib/pytz/zoneinfo/America/Panama branches/transforms/lib/pytz/zoneinfo/America/Pangnirtung branches/transforms/lib/pytz/zoneinfo/America/Paramaribo branches/transforms/lib/pytz/zoneinfo/America/Phoenix branches/transforms/lib/pytz/zoneinfo/America/Port-au-Prince branches/transforms/lib/pytz/zoneinfo/America/Port_of_Spain branches/transforms/lib/pytz/zoneinfo/America/Porto_Acre branches/transforms/lib/pytz/zoneinfo/America/Porto_Velho branches/transforms/lib/pytz/zoneinfo/America/Puerto_Rico branches/transforms/lib/pytz/zoneinfo/America/Rainy_River branches/transforms/lib/pytz/zoneinfo/America/Rankin_Inlet branches/transforms/lib/pytz/zoneinfo/America/Recife branches/transforms/lib/pytz/zoneinfo/America/Regina branches/transforms/lib/pytz/zoneinfo/America/Resolute branches/transforms/lib/pytz/zoneinfo/America/Rio_Branco branches/transforms/lib/pytz/zoneinfo/America/Rosario branches/transforms/lib/pytz/zoneinfo/America/Santiago branches/transforms/lib/pytz/zoneinfo/America/Santo_Domingo branches/transforms/lib/pytz/zoneinfo/America/Sao_Paulo branches/transforms/lib/pytz/zoneinfo/America/Scoresbysund branches/transforms/lib/pytz/zoneinfo/America/Shiprock branches/transforms/lib/pytz/zoneinfo/America/St_Johns branches/transforms/lib/pytz/zoneinfo/America/St_Kitts branches/transforms/lib/pytz/zoneinfo/America/St_Lucia branches/transforms/lib/pytz/zoneinfo/America/St_Thomas branches/transforms/lib/pytz/zoneinfo/America/St_Vincent branches/transforms/lib/pytz/zoneinfo/America/Swift_Current branches/transforms/lib/pytz/zoneinfo/America/Tegucigalpa branches/transforms/lib/pytz/zoneinfo/America/Thule branches/transforms/lib/pytz/zoneinfo/America/Thunder_Bay branches/transforms/lib/pytz/zoneinfo/America/Tijuana branches/transforms/lib/pytz/zoneinfo/America/Toronto branches/transforms/lib/pytz/zoneinfo/America/Tortola branches/transforms/lib/pytz/zoneinfo/America/Vancouver branches/transforms/lib/pytz/zoneinfo/America/Virgin branches/transforms/lib/pytz/zoneinfo/America/Whitehorse branches/transforms/lib/pytz/zoneinfo/America/Winnipeg branches/transforms/lib/pytz/zoneinfo/America/Yakutat branches/transforms/lib/pytz/zoneinfo/America/Yellowknife branches/transforms/lib/pytz/zoneinfo/Antarctica/ branches/transforms/lib/pytz/zoneinfo/Antarctica/Casey branches/transforms/lib/pytz/zoneinfo/Antarctica/Davis branches/transforms/lib/pytz/zoneinfo/Antarctica/DumontDUrville branches/transforms/lib/pytz/zoneinfo/Antarctica/Mawson branches/transforms/lib/pytz/zoneinfo/Antarctica/McMurdo branches/transforms/lib/pytz/zoneinfo/Antarctica/Palmer branches/transforms/lib/pytz/zoneinfo/Antarctica/Rothera branches/transforms/lib/pytz/zoneinfo/Antarctica/South_Pole branches/transforms/lib/pytz/zoneinfo/Antarctica/Syowa branches/transforms/lib/pytz/zoneinfo/Antarctica/Vostok branches/transforms/lib/pytz/zoneinfo/Arctic/ branches/transforms/lib/pytz/zoneinfo/Arctic/Longyearbyen branches/transforms/lib/pytz/zoneinfo/Asia/ branches/transforms/lib/pytz/zoneinfo/Asia/Aden branches/transforms/lib/pytz/zoneinfo/Asia/Almaty branches/transforms/lib/pytz/zoneinfo/Asia/Amman branches/transforms/lib/pytz/zoneinfo/Asia/Anadyr branches/transforms/lib/pytz/zoneinfo/Asia/Aqtau branches/transforms/lib/pytz/zoneinfo/Asia/Aqtobe branches/transforms/lib/pytz/zoneinfo/Asia/Ashgabat branches/transforms/lib/pytz/zoneinfo/Asia/Ashkhabad branches/transforms/lib/pytz/zoneinfo/Asia/Baghdad branches/transforms/lib/pytz/zoneinfo/Asia/Bahrain branches/transforms/lib/pytz/zoneinfo/Asia/Baku branches/transforms/lib/pytz/zoneinfo/Asia/Bangkok branches/transforms/lib/pytz/zoneinfo/Asia/Beirut branches/transforms/lib/pytz/zoneinfo/Asia/Bishkek branches/transforms/lib/pytz/zoneinfo/Asia/Brunei branches/transforms/lib/pytz/zoneinfo/Asia/Calcutta branches/transforms/lib/pytz/zoneinfo/Asia/Choibalsan branches/transforms/lib/pytz/zoneinfo/Asia/Chongqing branches/transforms/lib/pytz/zoneinfo/Asia/Chungking branches/transforms/lib/pytz/zoneinfo/Asia/Colombo branches/transforms/lib/pytz/zoneinfo/Asia/Dacca branches/transforms/lib/pytz/zoneinfo/Asia/Damascus branches/transforms/lib/pytz/zoneinfo/Asia/Dhaka branches/transforms/lib/pytz/zoneinfo/Asia/Dili branches/transforms/lib/pytz/zoneinfo/Asia/Dubai branches/transforms/lib/pytz/zoneinfo/Asia/Dushanbe branches/transforms/lib/pytz/zoneinfo/Asia/Gaza branches/transforms/lib/pytz/zoneinfo/Asia/Harbin branches/transforms/lib/pytz/zoneinfo/Asia/Hong_Kong branches/transforms/lib/pytz/zoneinfo/Asia/Hovd branches/transforms/lib/pytz/zoneinfo/Asia/Irkutsk branches/transforms/lib/pytz/zoneinfo/Asia/Istanbul branches/transforms/lib/pytz/zoneinfo/Asia/Jakarta branches/transforms/lib/pytz/zoneinfo/Asia/Jayapura branches/transforms/lib/pytz/zoneinfo/Asia/Jerusalem branches/transforms/lib/pytz/zoneinfo/Asia/Kabul branches/transforms/lib/pytz/zoneinfo/Asia/Kamchatka branches/transforms/lib/pytz/zoneinfo/Asia/Karachi branches/transforms/lib/pytz/zoneinfo/Asia/Kashgar branches/transforms/lib/pytz/zoneinfo/Asia/Katmandu branches/transforms/lib/pytz/zoneinfo/Asia/Krasnoyarsk branches/transforms/lib/pytz/zoneinfo/Asia/Kuala_Lumpur branches/transforms/lib/pytz/zoneinfo/Asia/Kuching branches/transforms/lib/pytz/zoneinfo/Asia/Kuwait branches/transforms/lib/pytz/zoneinfo/Asia/Macao branches/transforms/lib/pytz/zoneinfo/Asia/Macau branches/transforms/lib/pytz/zoneinfo/Asia/Magadan branches/transforms/lib/pytz/zoneinfo/Asia/Makassar branches/transforms/lib/pytz/zoneinfo/Asia/Manila branches/transforms/lib/pytz/zoneinfo/Asia/Muscat branches/transforms/lib/pytz/zoneinfo/Asia/Nicosia branches/transforms/lib/pytz/zoneinfo/Asia/Novosibirsk branches/transforms/lib/pytz/zoneinfo/Asia/Omsk branches/transforms/lib/pytz/zoneinfo/Asia/Oral branches/transforms/lib/pytz/zoneinfo/Asia/Phnom_Penh branches/transforms/lib/pytz/zoneinfo/Asia/Pontianak branches/transforms/lib/pytz/zoneinfo/Asia/Pyongyang branches/transforms/lib/pytz/zoneinfo/Asia/Qatar branches/transforms/lib/pytz/zoneinfo/Asia/Qyzylorda branches/transforms/lib/pytz/zoneinfo/Asia/Rangoon branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh87 branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh88 branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh89 branches/transforms/lib/pytz/zoneinfo/Asia/Saigon branches/transforms/lib/pytz/zoneinfo/Asia/Sakhalin branches/transforms/lib/pytz/zoneinfo/Asia/Samarkand branches/transforms/lib/pytz/zoneinfo/Asia/Seoul branches/transforms/lib/pytz/zoneinfo/Asia/Shanghai branches/transforms/lib/pytz/zoneinfo/Asia/Singapore branches/transforms/lib/pytz/zoneinfo/Asia/Taipei branches/transforms/lib/pytz/zoneinfo/Asia/Tashkent branches/transforms/lib/pytz/zoneinfo/Asia/Tbilisi branches/transforms/lib/pytz/zoneinfo/Asia/Tehran branches/transforms/lib/pytz/zoneinfo/Asia/Tel_Aviv branches/transforms/lib/pytz/zoneinfo/Asia/Thimbu branches/transforms/lib/pytz/zoneinfo/Asia/Thimphu branches/transforms/lib/pytz/zoneinfo/Asia/Tokyo branches/transforms/lib/pytz/zoneinfo/Asia/Ujung_Pandang branches/transforms/lib/pytz/zoneinfo/Asia/Ulaanbaatar branches/transforms/lib/pytz/zoneinfo/Asia/Ulan_Bator branches/transforms/lib/pytz/zoneinfo/Asia/Urumqi branches/transforms/lib/pytz/zoneinfo/Asia/Vientiane branches/transforms/lib/pytz/zoneinfo/Asia/Vladivostok branches/transforms/lib/pytz/zoneinfo/Asia/Yakutsk branches/transforms/lib/pytz/zoneinfo/Asia/Yekaterinburg branches/transforms/lib/pytz/zoneinfo/Asia/Yerevan branches/transforms/lib/pytz/zoneinfo/Atlantic/ branches/transforms/lib/pytz/zoneinfo/Atlantic/Azores branches/transforms/lib/pytz/zoneinfo/Atlantic/Bermuda branches/transforms/lib/pytz/zoneinfo/Atlantic/Canary branches/transforms/lib/pytz/zoneinfo/Atlantic/Cape_Verde branches/transforms/lib/pytz/zoneinfo/Atlantic/Faeroe branches/transforms/lib/pytz/zoneinfo/Atlantic/Faroe branches/transforms/lib/pytz/zoneinfo/Atlantic/Jan_Mayen branches/transforms/lib/pytz/zoneinfo/Atlantic/Madeira branches/transforms/lib/pytz/zoneinfo/Atlantic/Reykjavik branches/transforms/lib/pytz/zoneinfo/Atlantic/South_Georgia branches/transforms/lib/pytz/zoneinfo/Atlantic/St_Helena branches/transforms/lib/pytz/zoneinfo/Atlantic/Stanley branches/transforms/lib/pytz/zoneinfo/Australia/ branches/transforms/lib/pytz/zoneinfo/Australia/ACT branches/transforms/lib/pytz/zoneinfo/Australia/Adelaide branches/transforms/lib/pytz/zoneinfo/Australia/Brisbane branches/transforms/lib/pytz/zoneinfo/Australia/Broken_Hill branches/transforms/lib/pytz/zoneinfo/Australia/Canberra branches/transforms/lib/pytz/zoneinfo/Australia/Currie branches/transforms/lib/pytz/zoneinfo/Australia/Darwin branches/transforms/lib/pytz/zoneinfo/Australia/Eucla branches/transforms/lib/pytz/zoneinfo/Australia/Hobart branches/transforms/lib/pytz/zoneinfo/Australia/LHI branches/transforms/lib/pytz/zoneinfo/Australia/Lindeman branches/transforms/lib/pytz/zoneinfo/Australia/Lord_Howe branches/transforms/lib/pytz/zoneinfo/Australia/Melbourne branches/transforms/lib/pytz/zoneinfo/Australia/NSW branches/transforms/lib/pytz/zoneinfo/Australia/North branches/transforms/lib/pytz/zoneinfo/Australia/Perth branches/transforms/lib/pytz/zoneinfo/Australia/Queensland branches/transforms/lib/pytz/zoneinfo/Australia/South branches/transforms/lib/pytz/zoneinfo/Australia/Sydney branches/transforms/lib/pytz/zoneinfo/Australia/Tasmania branches/transforms/lib/pytz/zoneinfo/Australia/Victoria branches/transforms/lib/pytz/zoneinfo/Australia/West branches/transforms/lib/pytz/zoneinfo/Australia/Yancowinna branches/transforms/lib/pytz/zoneinfo/Brazil/ branches/transforms/lib/pytz/zoneinfo/Brazil/Acre branches/transforms/lib/pytz/zoneinfo/Brazil/DeNoronha branches/transforms/lib/pytz/zoneinfo/Brazil/East branches/transforms/lib/pytz/zoneinfo/Brazil/West branches/transforms/lib/pytz/zoneinfo/CET branches/transforms/lib/pytz/zoneinfo/CST6CDT branches/transforms/lib/pytz/zoneinfo/Canada/ branches/transforms/lib/pytz/zoneinfo/Canada/Atlantic branches/transforms/lib/pytz/zoneinfo/Canada/Central branches/transforms/lib/pytz/zoneinfo/Canada/East-Saskatchewan branches/transforms/lib/pytz/zoneinfo/Canada/Eastern branches/transforms/lib/pytz/zoneinfo/Canada/Mountain branches/transforms/lib/pytz/zoneinfo/Canada/Newfoundland branches/transforms/lib/pytz/zoneinfo/Canada/Pacific branches/transforms/lib/pytz/zoneinfo/Canada/Saskatchewan branches/transforms/lib/pytz/zoneinfo/Canada/Yukon branches/transforms/lib/pytz/zoneinfo/Chile/ branches/transforms/lib/pytz/zoneinfo/Chile/Continental branches/transforms/lib/pytz/zoneinfo/Chile/EasterIsland branches/transforms/lib/pytz/zoneinfo/Cuba branches/transforms/lib/pytz/zoneinfo/EET branches/transforms/lib/pytz/zoneinfo/EST branches/transforms/lib/pytz/zoneinfo/EST5EDT branches/transforms/lib/pytz/zoneinfo/Egypt branches/transforms/lib/pytz/zoneinfo/Eire branches/transforms/lib/pytz/zoneinfo/Etc/ branches/transforms/lib/pytz/zoneinfo/Etc/GMT branches/transforms/lib/pytz/zoneinfo/Etc/GMT+0 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+1 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+10 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+11 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+12 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+2 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+3 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+4 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+5 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+6 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+7 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+8 branches/transforms/lib/pytz/zoneinfo/Etc/GMT+9 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-0 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-1 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-10 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-11 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-12 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-13 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-14 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-2 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-3 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-4 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-5 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-6 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-7 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-8 branches/transforms/lib/pytz/zoneinfo/Etc/GMT-9 branches/transforms/lib/pytz/zoneinfo/Etc/GMT0 branches/transforms/lib/pytz/zoneinfo/Etc/Greenwich branches/transforms/lib/pytz/zoneinfo/Etc/UCT branches/transforms/lib/pytz/zoneinfo/Etc/UTC branches/transforms/lib/pytz/zoneinfo/Etc/Universal branches/transforms/lib/pytz/zoneinfo/Etc/Zulu branches/transforms/lib/pytz/zoneinfo/Europe/ branches/transforms/lib/pytz/zoneinfo/Europe/Amsterdam branches/transforms/lib/pytz/zoneinfo/Europe/Andorra branches/transforms/lib/pytz/zoneinfo/Europe/Athens branches/transforms/lib/pytz/zoneinfo/Europe/Belfast branches/transforms/lib/pytz/zoneinfo/Europe/Belgrade branches/transforms/lib/pytz/zoneinfo/Europe/Berlin branches/transforms/lib/pytz/zoneinfo/Europe/Bratislava branches/transforms/lib/pytz/zoneinfo/Europe/Brussels branches/transforms/lib/pytz/zoneinfo/Europe/Bucharest branches/transforms/lib/pytz/zoneinfo/Europe/Budapest branches/transforms/lib/pytz/zoneinfo/Europe/Chisinau branches/transforms/lib/pytz/zoneinfo/Europe/Copenhagen branches/transforms/lib/pytz/zoneinfo/Europe/Dublin branches/transforms/lib/pytz/zoneinfo/Europe/Gibraltar branches/transforms/lib/pytz/zoneinfo/Europe/Guernsey branches/transforms/lib/pytz/zoneinfo/Europe/Helsinki branches/transforms/lib/pytz/zoneinfo/Europe/Isle_of_Man branches/transforms/lib/pytz/zoneinfo/Europe/Istanbul branches/transforms/lib/pytz/zoneinfo/Europe/Jersey branches/transforms/lib/pytz/zoneinfo/Europe/Kaliningrad branches/transforms/lib/pytz/zoneinfo/Europe/Kiev branches/transforms/lib/pytz/zoneinfo/Europe/Lisbon branches/transforms/lib/pytz/zoneinfo/Europe/Ljubljana branches/transforms/lib/pytz/zoneinfo/Europe/London branches/transforms/lib/pytz/zoneinfo/Europe/Luxembourg branches/transforms/lib/pytz/zoneinfo/Europe/Madrid branches/transforms/lib/pytz/zoneinfo/Europe/Malta branches/transforms/lib/pytz/zoneinfo/Europe/Mariehamn branches/transforms/lib/pytz/zoneinfo/Europe/Minsk branches/transforms/lib/pytz/zoneinfo/Europe/Monaco branches/transforms/lib/pytz/zoneinfo/Europe/Moscow branches/transforms/lib/pytz/zoneinfo/Europe/Nicosia branches/transforms/lib/pytz/zoneinfo/Europe/Oslo branches/transforms/lib/pytz/zoneinfo/Europe/Paris branches/transforms/lib/pytz/zoneinfo/Europe/Podgorica branches/transforms/lib/pytz/zoneinfo/Europe/Prague branches/transforms/lib/pytz/zoneinfo/Europe/Riga branches/transforms/lib/pytz/zoneinfo/Europe/Rome branches/transforms/lib/pytz/zoneinfo/Europe/Samara branches/transforms/lib/pytz/zoneinfo/Europe/San_Marino branches/transforms/lib/pytz/zoneinfo/Europe/Sarajevo branches/transforms/lib/pytz/zoneinfo/Europe/Simferopol branches/transforms/lib/pytz/zoneinfo/Europe/Skopje branches/transforms/lib/pytz/zoneinfo/Europe/Sofia branches/transforms/lib/pytz/zoneinfo/Europe/Stockholm branches/transforms/lib/pytz/zoneinfo/Europe/Tallinn branches/transforms/lib/pytz/zoneinfo/Europe/Tirane branches/transforms/lib/pytz/zoneinfo/Europe/Tiraspol branches/transforms/lib/pytz/zoneinfo/Europe/Uzhgorod branches/transforms/lib/pytz/zoneinfo/Europe/Vaduz branches/transforms/lib/pytz/zoneinfo/Europe/Vatican branches/transforms/lib/pytz/zoneinfo/Europe/Vienna branches/transforms/lib/pytz/zoneinfo/Europe/Vilnius branches/transforms/lib/pytz/zoneinfo/Europe/Volgograd branches/transforms/lib/pytz/zoneinfo/Europe/Warsaw branches/transforms/lib/pytz/zoneinfo/Europe/Zagreb branches/transforms/lib/pytz/zoneinfo/Europe/Zaporozhye branches/transforms/lib/pytz/zoneinfo/Europe/Zurich branches/transforms/lib/pytz/zoneinfo/Factory branches/transforms/lib/pytz/zoneinfo/GB branches/transforms/lib/pytz/zoneinfo/GB-Eire branches/transforms/lib/pytz/zoneinfo/GMT branches/transforms/lib/pytz/zoneinfo/GMT+0 branches/transforms/lib/pytz/zoneinfo/GMT-0 branches/transforms/lib/pytz/zoneinfo/GMT0 branches/transforms/lib/pytz/zoneinfo/Greenwich branches/transforms/lib/pytz/zoneinfo/HST branches/transforms/lib/pytz/zoneinfo/Hongkong branches/transforms/lib/pytz/zoneinfo/Iceland branches/transforms/lib/pytz/zoneinfo/Indian/ branches/transforms/lib/pytz/zoneinfo/Indian/Antananarivo branches/transforms/lib/pytz/zoneinfo/Indian/Chagos branches/transforms/lib/pytz/zoneinfo/Indian/Christmas branches/transforms/lib/pytz/zoneinfo/Indian/Cocos branches/transforms/lib/pytz/zoneinfo/Indian/Comoro branches/transforms/lib/pytz/zoneinfo/Indian/Kerguelen branches/transforms/lib/pytz/zoneinfo/Indian/Mahe branches/transforms/lib/pytz/zoneinfo/Indian/Maldives branches/transforms/lib/pytz/zoneinfo/Indian/Mauritius branches/transforms/lib/pytz/zoneinfo/Indian/Mayotte branches/transforms/lib/pytz/zoneinfo/Indian/Reunion branches/transforms/lib/pytz/zoneinfo/Iran branches/transforms/lib/pytz/zoneinfo/Israel branches/transforms/lib/pytz/zoneinfo/Jamaica branches/transforms/lib/pytz/zoneinfo/Japan branches/transforms/lib/pytz/zoneinfo/Kwajalein branches/transforms/lib/pytz/zoneinfo/Libya branches/transforms/lib/pytz/zoneinfo/MET branches/transforms/lib/pytz/zoneinfo/MST branches/transforms/lib/pytz/zoneinfo/MST7MDT branches/transforms/lib/pytz/zoneinfo/Mexico/ branches/transforms/lib/pytz/zoneinfo/Mexico/BajaNorte branches/transforms/lib/pytz/zoneinfo/Mexico/BajaSur branches/transforms/lib/pytz/zoneinfo/Mexico/General branches/transforms/lib/pytz/zoneinfo/Mideast/ branches/transforms/lib/pytz/zoneinfo/Mideast/Riyadh87 branches/transforms/lib/pytz/zoneinfo/Mideast/Riyadh88 branches/transforms/lib/pytz/zoneinfo/Mideast/Riyadh89 branches/transforms/lib/pytz/zoneinfo/NZ branches/transforms/lib/pytz/zoneinfo/NZ-CHAT branches/transforms/lib/pytz/zoneinfo/Navajo branches/transforms/lib/pytz/zoneinfo/PRC branches/transforms/lib/pytz/zoneinfo/PST8PDT branches/transforms/lib/pytz/zoneinfo/Pacific/ branches/transforms/lib/pytz/zoneinfo/Pacific/Apia branches/transforms/lib/pytz/zoneinfo/Pacific/Auckland branches/transforms/lib/pytz/zoneinfo/Pacific/Chatham branches/transforms/lib/pytz/zoneinfo/Pacific/Easter branches/transforms/lib/pytz/zoneinfo/Pacific/Efate branches/transforms/lib/pytz/zoneinfo/Pacific/Enderbury branches/transforms/lib/pytz/zoneinfo/Pacific/Fakaofo branches/transforms/lib/pytz/zoneinfo/Pacific/Fiji branches/transforms/lib/pytz/zoneinfo/Pacific/Funafuti branches/transforms/lib/pytz/zoneinfo/Pacific/Galapagos branches/transforms/lib/pytz/zoneinfo/Pacific/Gambier branches/transforms/lib/pytz/zoneinfo/Pacific/Guadalcanal branches/transforms/lib/pytz/zoneinfo/Pacific/Guam branches/transforms/lib/pytz/zoneinfo/Pacific/Honolulu branches/transforms/lib/pytz/zoneinfo/Pacific/Johnston branches/transforms/lib/pytz/zoneinfo/Pacific/Kiritimati branches/transforms/lib/pytz/zoneinfo/Pacific/Kosrae branches/transforms/lib/pytz/zoneinfo/Pacific/Kwajalein branches/transforms/lib/pytz/zoneinfo/Pacific/Majuro branches/transforms/lib/pytz/zoneinfo/Pacific/Marquesas branches/transforms/lib/pytz/zoneinfo/Pacific/Midway branches/transforms/lib/pytz/zoneinfo/Pacific/Nauru branches/transforms/lib/pytz/zoneinfo/Pacific/Niue branches/transforms/lib/pytz/zoneinfo/Pacific/Norfolk branches/transforms/lib/pytz/zoneinfo/Pacific/Noumea branches/transforms/lib/pytz/zoneinfo/Pacific/Pago_Pago branches/transforms/lib/pytz/zoneinfo/Pacific/Palau branches/transforms/lib/pytz/zoneinfo/Pacific/Pitcairn branches/transforms/lib/pytz/zoneinfo/Pacific/Ponape branches/transforms/lib/pytz/zoneinfo/Pacific/Port_Moresby branches/transforms/lib/pytz/zoneinfo/Pacific/Rarotonga branches/transforms/lib/pytz/zoneinfo/Pacific/Saipan branches/transforms/lib/pytz/zoneinfo/Pacific/Samoa branches/transforms/lib/pytz/zoneinfo/Pacific/Tahiti branches/transforms/lib/pytz/zoneinfo/Pacific/Tarawa branches/transforms/lib/pytz/zoneinfo/Pacific/Tongatapu branches/transforms/lib/pytz/zoneinfo/Pacific/Truk branches/transforms/lib/pytz/zoneinfo/Pacific/Wake branches/transforms/lib/pytz/zoneinfo/Pacific/Wallis branches/transforms/lib/pytz/zoneinfo/Pacific/Yap branches/transforms/lib/pytz/zoneinfo/Poland branches/transforms/lib/pytz/zoneinfo/Portugal branches/transforms/lib/pytz/zoneinfo/ROC branches/transforms/lib/pytz/zoneinfo/ROK branches/transforms/lib/pytz/zoneinfo/Singapore branches/transforms/lib/pytz/zoneinfo/Turkey branches/transforms/lib/pytz/zoneinfo/UCT branches/transforms/lib/pytz/zoneinfo/US/ branches/transforms/lib/pytz/zoneinfo/US/Alaska branches/transforms/lib/pytz/zoneinfo/US/Aleutian branches/transforms/lib/pytz/zoneinfo/US/Arizona branches/transforms/lib/pytz/zoneinfo/US/Central branches/transforms/lib/pytz/zoneinfo/US/East-Indiana branches/transforms/lib/pytz/zoneinfo/US/Eastern branches/transforms/lib/pytz/zoneinfo/US/Hawaii branches/transforms/lib/pytz/zoneinfo/US/Indiana-Starke branches/transforms/lib/pytz/zoneinfo/US/Michigan branches/transforms/lib/pytz/zoneinfo/US/Mountain branches/transforms/lib/pytz/zoneinfo/US/Pacific branches/transforms/lib/pytz/zoneinfo/US/Pacific-New branches/transforms/lib/pytz/zoneinfo/US/Samoa branches/transforms/lib/pytz/zoneinfo/UTC branches/transforms/lib/pytz/zoneinfo/Universal branches/transforms/lib/pytz/zoneinfo/W-SU branches/transforms/lib/pytz/zoneinfo/WET branches/transforms/lib/pytz/zoneinfo/Zulu branches/transforms/lib/pytz/zoneinfo/iso3166.tab branches/transforms/lib/pytz/zoneinfo/localtime branches/transforms/lib/pytz/zoneinfo/posixrules branches/transforms/lib/pytz/zoneinfo/zone.tab Removed Paths: ------------- branches/transforms/lib/enthought/traits/__init__.pyc branches/transforms/lib/enthought/traits/ui/__init__.pyc branches/transforms/lib/matplotlib/config/configobj.py branches/transforms/lib/matplotlib/enthought/ branches/transforms/lib/pytz/CHANGES.txt branches/transforms/lib/pytz/LICENSE.txt branches/transforms/lib/pytz/README.txt branches/transforms/lib/pytz/__init__.py branches/transforms/lib/pytz/reference.py branches/transforms/lib/pytz/tzfile.py branches/transforms/lib/pytz/tzinfo.py branches/transforms/lib/pytz/zoneinfo/ branches/transforms/lib/pytz/zoneinfo/Africa/ branches/transforms/lib/pytz/zoneinfo/Africa/Abidjan branches/transforms/lib/pytz/zoneinfo/Africa/Accra branches/transforms/lib/pytz/zoneinfo/Africa/Addis_Ababa branches/transforms/lib/pytz/zoneinfo/Africa/Algiers branches/transforms/lib/pytz/zoneinfo/Africa/Asmara branches/transforms/lib/pytz/zoneinfo/Africa/Asmera branches/transforms/lib/pytz/zoneinfo/Africa/Bamako branches/transforms/lib/pytz/zoneinfo/Africa/Bangui branches/transforms/lib/pytz/zoneinfo/Africa/Banjul branches/transforms/lib/pytz/zoneinfo/Africa/Bissau branches/transforms/lib/pytz/zoneinfo/Africa/Blantyre branches/transforms/lib/pytz/zoneinfo/Africa/Brazzaville branches/transforms/lib/pytz/zoneinfo/Africa/Bujumbura branches/transforms/lib/pytz/zoneinfo/Africa/Cairo branches/transforms/lib/pytz/zoneinfo/Africa/Casablanca branches/transforms/lib/pytz/zoneinfo/Africa/Ceuta branches/transforms/lib/pytz/zoneinfo/Africa/Conakry branches/transforms/lib/pytz/zoneinfo/Africa/Dakar branches/transforms/lib/pytz/zoneinfo/Africa/Dar_es_Salaam branches/transforms/lib/pytz/zoneinfo/Africa/Djibouti branches/transforms/lib/pytz/zoneinfo/Africa/Douala branches/transforms/lib/pytz/zoneinfo/Africa/El_Aaiun branches/transforms/lib/pytz/zoneinfo/Africa/Freetown branches/transforms/lib/pytz/zoneinfo/Africa/Gaborone branches/transforms/lib/pytz/zoneinfo/Africa/Harare branches/transforms/lib/pytz/zoneinfo/Africa/Johannesburg branches/transforms/lib/pytz/zoneinfo/Africa/Kampala branches/transforms/lib/pytz/zoneinfo/Africa/Khartoum branches/transforms/lib/pytz/zoneinfo/Africa/Kigali branches/transforms/lib/pytz/zoneinfo/Africa/Kinshasa branches/transforms/lib/pytz/zoneinfo/Africa/Lagos branches/transforms/lib/pytz/zoneinfo/Africa/Libreville branches/transforms/lib/pytz/zoneinfo/Africa/Lome branches/transforms/lib/pytz/zoneinfo/Africa/Luanda branches/transforms/lib/pytz/zoneinfo/Africa/Lubumbashi branches/transforms/lib/pytz/zoneinfo/Africa/Lusaka branches/transforms/lib/pytz/zoneinfo/Africa/Malabo branches/transforms/lib/pytz/zoneinfo/Africa/Maputo branches/transforms/lib/pytz/zoneinfo/Africa/Maseru branches/transforms/lib/pytz/zoneinfo/Africa/Mbabane branches/transforms/lib/pytz/zoneinfo/Africa/Mogadishu branches/transforms/lib/pytz/zoneinfo/Africa/Monrovia branches/transforms/lib/pytz/zoneinfo/Africa/Nairobi branches/transforms/lib/pytz/zoneinfo/Africa/Ndjamena branches/transforms/lib/pytz/zoneinfo/Africa/Niamey branches/transforms/lib/pytz/zoneinfo/Africa/Nouakchott branches/transforms/lib/pytz/zoneinfo/Africa/Ouagadougou branches/transforms/lib/pytz/zoneinfo/Africa/Porto-Novo branches/transforms/lib/pytz/zoneinfo/Africa/Sao_Tome branches/transforms/lib/pytz/zoneinfo/Africa/Timbuktu branches/transforms/lib/pytz/zoneinfo/Africa/Tripoli branches/transforms/lib/pytz/zoneinfo/Africa/Tunis branches/transforms/lib/pytz/zoneinfo/Africa/Windhoek branches/transforms/lib/pytz/zoneinfo/America/ branches/transforms/lib/pytz/zoneinfo/America/Adak branches/transforms/lib/pytz/zoneinfo/America/Anchorage branches/transforms/lib/pytz/zoneinfo/America/Anguilla branches/transforms/lib/pytz/zoneinfo/America/Antigua branches/transforms/lib/pytz/zoneinfo/America/Araguaina branches/transforms/lib/pytz/zoneinfo/America/Argentina/ branches/transforms/lib/pytz/zoneinfo/America/Argentina/Buenos_Aires branches/transforms/lib/pytz/zoneinfo/America/Argentina/Catamarca branches/transforms/lib/pytz/zoneinfo/America/Argentina/ComodRivadavia branches/transforms/lib/pytz/zoneinfo/America/Argentina/Cordoba branches/transforms/lib/pytz/zoneinfo/America/Argentina/Jujuy branches/transforms/lib/pytz/zoneinfo/America/Argentina/La_Rioja branches/transforms/lib/pytz/zoneinfo/America/Argentina/Mendoza branches/transforms/lib/pytz/zoneinfo/America/Argentina/Rio_Gallegos branches/transforms/lib/pytz/zoneinfo/America/Argentina/San_Juan branches/transforms/lib/pytz/zoneinfo/America/Argentina/Tucuman branches/transforms/lib/pytz/zoneinfo/America/Argentina/Ushuaia branches/transforms/lib/pytz/zoneinfo/America/Aruba branches/transforms/lib/pytz/zoneinfo/America/Asuncion branches/transforms/lib/pytz/zoneinfo/America/Atikokan branches/transforms/lib/pytz/zoneinfo/America/Atka branches/transforms/lib/pytz/zoneinfo/America/Bahia branches/transforms/lib/pytz/zoneinfo/America/Barbados branches/transforms/lib/pytz/zoneinfo/America/Belem branches/transforms/lib/pytz/zoneinfo/America/Belize branches/transforms/lib/pytz/zoneinfo/America/Blanc-Sablon branches/transforms/lib/pytz/zoneinfo/America/Boa_Vista branches/transforms/lib/pytz/zoneinfo/America/Bogota branches/transforms/lib/pytz/zoneinfo/America/Boise branches/transforms/lib/pytz/zoneinfo/America/Buenos_Aires branches/transforms/lib/pytz/zoneinfo/America/Cambridge_Bay branches/transforms/lib/pytz/zoneinfo/America/Campo_Grande branches/transforms/lib/pytz/zoneinfo/America/Cancun branches/transforms/lib/pytz/zoneinfo/America/Caracas branches/transforms/lib/pytz/zoneinfo/America/Catamarca branches/transforms/lib/pytz/zoneinfo/America/Cayenne branches/transforms/lib/pytz/zoneinfo/America/Cayman branches/transforms/lib/pytz/zoneinfo/America/Chicago branches/transforms/lib/pytz/zoneinfo/America/Chihuahua branches/transforms/lib/pytz/zoneinfo/America/Coral_Harbour branches/transforms/lib/pytz/zoneinfo/America/Cordoba branches/transforms/lib/pytz/zoneinfo/America/Costa_Rica branches/transforms/lib/pytz/zoneinfo/America/Cuiaba branches/transforms/lib/pytz/zoneinfo/America/Curacao branches/transforms/lib/pytz/zoneinfo/America/Danmarkshavn branches/transforms/lib/pytz/zoneinfo/America/Dawson branches/transforms/lib/pytz/zoneinfo/America/Dawson_Creek branches/transforms/lib/pytz/zoneinfo/America/Denver branches/transforms/lib/pytz/zoneinfo/America/Detroit branches/transforms/lib/pytz/zoneinfo/America/Dominica branches/transforms/lib/pytz/zoneinfo/America/Edmonton branches/transforms/lib/pytz/zoneinfo/America/Eirunepe branches/transforms/lib/pytz/zoneinfo/America/El_Salvador branches/transforms/lib/pytz/zoneinfo/America/Ensenada branches/transforms/lib/pytz/zoneinfo/America/Fort_Wayne branches/transforms/lib/pytz/zoneinfo/America/Fortaleza branches/transforms/lib/pytz/zoneinfo/America/Glace_Bay branches/transforms/lib/pytz/zoneinfo/America/Godthab branches/transforms/lib/pytz/zoneinfo/America/Goose_Bay branches/transforms/lib/pytz/zoneinfo/America/Grand_Turk branches/transforms/lib/pytz/zoneinfo/America/Grenada branches/transforms/lib/pytz/zoneinfo/America/Guadeloupe branches/transforms/lib/pytz/zoneinfo/America/Guatemala branches/transforms/lib/pytz/zoneinfo/America/Guayaquil branches/transforms/lib/pytz/zoneinfo/America/Guyana branches/transforms/lib/pytz/zoneinfo/America/Halifax branches/transforms/lib/pytz/zoneinfo/America/Havana branches/transforms/lib/pytz/zoneinfo/America/Hermosillo branches/transforms/lib/pytz/zoneinfo/America/Indiana/ branches/transforms/lib/pytz/zoneinfo/America/Indiana/Indianapolis branches/transforms/lib/pytz/zoneinfo/America/Indiana/Knox branches/transforms/lib/pytz/zoneinfo/America/Indiana/Marengo branches/transforms/lib/pytz/zoneinfo/America/Indiana/Petersburg branches/transforms/lib/pytz/zoneinfo/America/Indiana/Tell_City branches/transforms/lib/pytz/zoneinfo/America/Indiana/Vevay branches/transforms/lib/pytz/zoneinfo/America/Indiana/Vincennes branches/transforms/lib/pytz/zoneinfo/America/Indiana/Winamac branches/transforms/lib/pytz/zoneinfo/America/Indianapolis branches/transforms/lib/pytz/zoneinfo/America/Inuvik branches/transforms/lib/pytz/zoneinfo/America/Iqaluit branches/transforms/lib/pytz/zoneinfo/America/Jamaica branches/transforms/lib/pytz/zoneinfo/America/Jujuy branches/transforms/lib/pytz/zoneinfo/America/Juneau branches/transforms/lib/pytz/zoneinfo/America/Kentucky/ branches/transforms/lib/pytz/zoneinfo/America/Kentucky/Louisville branches/transforms/lib/pytz/zoneinfo/America/Kentucky/Monticello branches/transforms/lib/pytz/zoneinfo/America/Knox_IN branches/transforms/lib/pytz/zoneinfo/America/La_Paz branches/transforms/lib/pytz/zoneinfo/America/Lima branches/transforms/lib/pytz/zoneinfo/America/Los_Angeles branches/transforms/lib/pytz/zoneinfo/America/Louisville branches/transforms/lib/pytz/zoneinfo/America/Maceio branches/transforms/lib/pytz/zoneinfo/America/Managua branches/transforms/lib/pytz/zoneinfo/America/Manaus branches/transforms/lib/pytz/zoneinfo/America/Martinique branches/transforms/lib/pytz/zoneinfo/America/Mazatlan branches/transforms/lib/pytz/zoneinfo/America/Mendoza branches/transforms/lib/pytz/zoneinfo/America/Menominee branches/transforms/lib/pytz/zoneinfo/America/Merida branches/transforms/lib/pytz/zoneinfo/America/Mexico_City branches/transforms/lib/pytz/zoneinfo/America/Miquelon branches/transforms/lib/pytz/zoneinfo/America/Moncton branches/transforms/lib/pytz/zoneinfo/America/Monterrey branches/transforms/lib/pytz/zoneinfo/America/Montevideo branches/transforms/lib/pytz/zoneinfo/America/Montreal branches/transforms/lib/pytz/zoneinfo/America/Montserrat branches/transforms/lib/pytz/zoneinfo/America/Nassau branches/transforms/lib/pytz/zoneinfo/America/New_York branches/transforms/lib/pytz/zoneinfo/America/Nipigon branches/transforms/lib/pytz/zoneinfo/America/Nome branches/transforms/lib/pytz/zoneinfo/America/Noronha branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/ branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/Center branches/transforms/lib/pytz/zoneinfo/America/North_Dakota/New_Salem branches/transforms/lib/pytz/zoneinfo/America/Panama branches/transforms/lib/pytz/zoneinfo/America/Pangnirtung branches/transforms/lib/pytz/zoneinfo/America/Paramaribo branches/transforms/lib/pytz/zoneinfo/America/Phoenix branches/transforms/lib/pytz/zoneinfo/America/Port-au-Prince branches/transforms/lib/pytz/zoneinfo/America/Port_of_Spain branches/transforms/lib/pytz/zoneinfo/America/Porto_Acre branches/transforms/lib/pytz/zoneinfo/America/Porto_Velho branches/transforms/lib/pytz/zoneinfo/America/Puerto_Rico branches/transforms/lib/pytz/zoneinfo/America/Rainy_River branches/transforms/lib/pytz/zoneinfo/America/Rankin_Inlet branches/transforms/lib/pytz/zoneinfo/America/Recife branches/transforms/lib/pytz/zoneinfo/America/Regina branches/transforms/lib/pytz/zoneinfo/America/Resolute branches/transforms/lib/pytz/zoneinfo/America/Rio_Branco branches/transforms/lib/pytz/zoneinfo/America/Rosario branches/transforms/lib/pytz/zoneinfo/America/Santiago branches/transforms/lib/pytz/zoneinfo/America/Santo_Domingo branches/transforms/lib/pytz/zoneinfo/America/Sao_Paulo branches/transforms/lib/pytz/zoneinfo/America/Scoresbysund branches/transforms/lib/pytz/zoneinfo/America/Shiprock branches/transforms/lib/pytz/zoneinfo/America/St_Johns branches/transforms/lib/pytz/zoneinfo/America/St_Kitts branches/transforms/lib/pytz/zoneinfo/America/St_Lucia branches/transforms/lib/pytz/zoneinfo/America/St_Thomas branches/transforms/lib/pytz/zoneinfo/America/St_Vincent branches/transforms/lib/pytz/zoneinfo/America/Swift_Current branches/transforms/lib/pytz/zoneinfo/America/Tegucigalpa branches/transforms/lib/pytz/zoneinfo/America/Thule branches/transforms/lib/pytz/zoneinfo/America/Thunder_Bay branches/transforms/lib/pytz/zoneinfo/America/Tijuana branches/transforms/lib/pytz/zoneinfo/America/Toronto branches/transforms/lib/pytz/zoneinfo/America/Tortola branches/transforms/lib/pytz/zoneinfo/America/Vancouver branches/transforms/lib/pytz/zoneinfo/America/Virgin branches/transforms/lib/pytz/zoneinfo/America/Whitehorse branches/transforms/lib/pytz/zoneinfo/America/Winnipeg branches/transforms/lib/pytz/zoneinfo/America/Yakutat branches/transforms/lib/pytz/zoneinfo/America/Yellowknife branches/transforms/lib/pytz/zoneinfo/Antarctica/ branches/transforms/lib/pytz/zoneinfo/Antarctica/Casey branches/transforms/lib/pytz/zoneinfo/Antarctica/Davis branches/transforms/lib/pytz/zoneinfo/Antarctica/DumontDUrville branches/transforms/lib/pytz/zoneinfo/Antarctica/Mawson branches/transforms/lib/pytz/zoneinfo/Antarctica/McMurdo branches/transforms/lib/pytz/zoneinfo/Antarctica/Palmer branches/transforms/lib/pytz/zoneinfo/Antarctica/Rothera branches/transforms/lib/pytz/zoneinfo/Antarctica/South_Pole branches/transforms/lib/pytz/zoneinfo/Antarctica/Syowa branches/transforms/lib/pytz/zoneinfo/Antarctica/Vostok branches/transforms/lib/pytz/zoneinfo/Arctic/ branches/transforms/lib/pytz/zoneinfo/Arctic/Longyearbyen branches/transforms/lib/pytz/zoneinfo/Asia/ branches/transforms/lib/pytz/zoneinfo/Asia/Aden branches/transforms/lib/pytz/zoneinfo/Asia/Almaty branches/transforms/lib/pytz/zoneinfo/Asia/Amman branches/transforms/lib/pytz/zoneinfo/Asia/Anadyr branches/transforms/lib/pytz/zoneinfo/Asia/Aqtau branches/transforms/lib/pytz/zoneinfo/Asia/Aqtobe branches/transforms/lib/pytz/zoneinfo/Asia/Ashgabat branches/transforms/lib/pytz/zoneinfo/Asia/Ashkhabad branches/transforms/lib/pytz/zoneinfo/Asia/Baghdad branches/transforms/lib/pytz/zoneinfo/Asia/Bahrain branches/transforms/lib/pytz/zoneinfo/Asia/Baku branches/transforms/lib/pytz/zoneinfo/Asia/Bangkok branches/transforms/lib/pytz/zoneinfo/Asia/Beirut branches/transforms/lib/pytz/zoneinfo/Asia/Bishkek branches/transforms/lib/pytz/zoneinfo/Asia/Brunei branches/transforms/lib/pytz/zoneinfo/Asia/Calcutta branches/transforms/lib/pytz/zoneinfo/Asia/Choibalsan branches/transforms/lib/pytz/zoneinfo/Asia/Chongqing branches/transforms/lib/pytz/zoneinfo/Asia/Chungking branches/transforms/lib/pytz/zoneinfo/Asia/Colombo branches/transforms/lib/pytz/zoneinfo/Asia/Dacca branches/transforms/lib/pytz/zoneinfo/Asia/Damascus branches/transforms/lib/pytz/zoneinfo/Asia/Dhaka branches/transforms/lib/pytz/zoneinfo/Asia/Dili branches/transforms/lib/pytz/zoneinfo/Asia/Dubai branches/transforms/lib/pytz/zoneinfo/Asia/Dushanbe branches/transforms/lib/pytz/zoneinfo/Asia/Gaza branches/transforms/lib/pytz/zoneinfo/Asia/Harbin branches/transforms/lib/pytz/zoneinfo/Asia/Hong_Kong branches/transforms/lib/pytz/zoneinfo/Asia/Hovd branches/transforms/lib/pytz/zoneinfo/Asia/Irkutsk branches/transforms/lib/pytz/zoneinfo/Asia/Istanbul branches/transforms/lib/pytz/zoneinfo/Asia/Jakarta branches/transforms/lib/pytz/zoneinfo/Asia/Jayapura branches/transforms/lib/pytz/zoneinfo/Asia/Jerusalem branches/transforms/lib/pytz/zoneinfo/Asia/Kabul branches/transforms/lib/pytz/zoneinfo/Asia/Kamchatka branches/transforms/lib/pytz/zoneinfo/Asia/Karachi branches/transforms/lib/pytz/zoneinfo/Asia/Kashgar branches/transforms/lib/pytz/zoneinfo/Asia/Katmandu branches/transforms/lib/pytz/zoneinfo/Asia/Krasnoyarsk branches/transforms/lib/pytz/zoneinfo/Asia/Kuala_Lumpur branches/transforms/lib/pytz/zoneinfo/Asia/Kuching branches/transforms/lib/pytz/zoneinfo/Asia/Kuwait branches/transforms/lib/pytz/zoneinfo/Asia/Macao branches/transforms/lib/pytz/zoneinfo/Asia/Macau branches/transforms/lib/pytz/zoneinfo/Asia/Magadan branches/transforms/lib/pytz/zoneinfo/Asia/Makassar branches/transforms/lib/pytz/zoneinfo/Asia/Manila branches/transforms/lib/pytz/zoneinfo/Asia/Muscat branches/transforms/lib/pytz/zoneinfo/Asia/Nicosia branches/transforms/lib/pytz/zoneinfo/Asia/Novosibirsk branches/transforms/lib/pytz/zoneinfo/Asia/Omsk branches/transforms/lib/pytz/zoneinfo/Asia/Oral branches/transforms/lib/pytz/zoneinfo/Asia/Phnom_Penh branches/transforms/lib/pytz/zoneinfo/Asia/Pontianak branches/transforms/lib/pytz/zoneinfo/Asia/Pyongyang branches/transforms/lib/pytz/zoneinfo/Asia/Qatar branches/transforms/lib/pytz/zoneinfo/Asia/Qyzylorda branches/transforms/lib/pytz/zoneinfo/Asia/Rangoon branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh87 branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh88 branches/transforms/lib/pytz/zoneinfo/Asia/Riyadh89 branches/transforms/lib/pytz/zoneinfo/Asia/Saigon branches/transforms/lib/pytz/zoneinfo/Asia/Sakhalin branches/transforms/lib/pytz/zoneinfo/Asia/Samarkand branches/transforms/lib/pytz/zoneinfo/Asia/Seoul branches/transforms/lib/pytz/zoneinfo/Asia/Shanghai branches/transforms/lib/pytz/zoneinfo/Asia/Singapore branches/transforms/lib/pytz/zoneinfo/Asia/Taipei branches/transforms/lib/pytz/zoneinfo/Asia/Tashkent branches/transforms/lib/pytz/zoneinfo/Asia/Tbilisi branches/transforms/lib/pytz/zoneinfo/Asia/Tehran branches/transforms/lib/pytz/zoneinfo/Asia/Tel_Aviv branches/transforms/lib/pytz/zoneinfo/Asia/Thimbu branches/transforms/lib/pytz/zoneinfo/Asia/Thimphu branches/transforms/lib/pytz/zoneinfo/Asia/Tokyo branches/transforms/lib/pytz/zoneinfo/Asia/Ujung_Pandang branches/transforms/lib/pytz/zoneinfo/Asia/Ulaanbaatar branches/transforms/lib/pytz/zoneinfo/Asia/Ulan_Bator branches/transforms/lib/pytz/zoneinfo/Asia/Urumqi branches/transforms/lib/pytz/zoneinfo/Asia/Vientiane branches/transforms/lib/pytz/zoneinfo/Asia/Vladivostok branches/transforms/lib/pytz/zoneinfo/Asia/Yakutsk branches/transforms/lib/pytz/zoneinfo/Asia/Yekaterinburg branches/transforms/lib/pytz/zoneinfo/Asia/Yerevan branches/transforms/lib/pytz/zoneinfo/Atlantic/ branches/transforms/lib/pytz/zoneinfo/Atlantic/Azores branches/transforms/lib/pytz/zoneinfo/Atlantic/Bermuda branches/transforms/lib/pytz/zoneinfo/Atlantic/Canary branches/transforms/lib/pytz/zoneinfo/Atlantic/Cape_Verde branches/transforms/lib/pytz/zoneinfo/Atlantic/Faeroe branches/transforms/lib/pytz/zoneinfo/Atlantic/Faroe branches/transforms/lib/pytz/zoneinfo/Atlantic/Jan_Mayen branches/transforms/lib/pytz/zoneinfo/Atlantic/Madeira branches/transforms/lib/pytz/zoneinfo/Atlantic/Reykjavik branches/transforms/lib/pytz/zoneinfo/Atlantic/South_Georgia branches/transforms/lib/pytz/zoneinfo/Atlantic/St_Helena branches/transforms/lib/pytz/zoneinfo/Atlantic/Stanley branches/transforms/lib/pytz/zoneinfo/Australia/ branches/transforms/lib/pytz/zoneinfo/Australia/ACT branches/transforms/lib/pytz/zoneinfo/Australia/Adelaide branches/transforms/lib/pytz/zoneinfo/Australia/Brisbane branches/transforms/lib/pytz/zoneinfo/Australia/Broken_Hill branches/transforms/lib/pytz/zoneinfo/Australia/Canberra branches/transforms/lib/pytz/zoneinfo/Australia/Currie branches/transforms/lib/pytz/zoneinfo/Australia/Darwin branches/transforms/lib/pytz/zoneinfo/Australia/Eucla branches/transforms/lib/pytz/zoneinfo/Australia/Hobart branches/transforms/lib/pytz/zoneinfo/Australia/LHI branches/transforms/lib/pytz/zoneinfo/Australia/Lindeman branches/transforms/lib/pytz/zoneinfo/Australia/Lord_Howe branches/transforms/lib/pytz/zoneinfo/Australia/Melbourne branches/transforms/lib/pytz/zoneinfo/Australia/NSW branches/transforms/lib/pytz/zoneinfo/Australia/North branches/transforms/lib/pytz/zoneinfo/Australia/Perth branches/transforms/lib/pytz/zoneinfo/Australia/Queensland branches/transforms/lib/pytz/zoneinfo/Australia/South branches/transforms/lib/pytz/zoneinfo/Australia/Sydney branches/transforms/lib/pytz/zoneinfo/Australia/Tasmania branches/transforms/lib/pytz/zoneinfo/Australia/Victoria branches/transforms/lib/pytz/zoneinfo/Australia/West branches/transforms/lib/pytz/zoneinfo/Australia/Yancowinna branches/transforms/lib/pytz/zoneinfo/Brazil/ branches/transforms/lib/pytz/zoneinfo/Brazil/Acre branches/transforms/lib/pytz/zoneinfo/Brazil/DeNoronha branches/transforms/lib/pytz/zoneinfo/Brazil/East branches/transforms/lib/pytz/zoneinfo/Brazil/West branches/transforms/lib/pytz/zoneinfo/CET branches/transforms/lib/pytz/zoneinfo/CST6CDT branches/transforms/lib/pytz/zoneinfo/Canada/ branches/transforms/lib/pytz/zoneinfo/Canada/Atlantic branches/transforms/lib/pytz/zoneinfo/Canada/Central branches/transforms/lib/pytz/zoneinfo/Canada/East-Saskatchewan branches/transforms/lib/pytz/zoneinfo/Canada/Eastern branches/transforms/lib/pytz/zoneinfo/Canada/Mountain branches/transforms/lib/pytz/zoneinfo/Canada/Newfoundland branches/transforms/lib/pytz/zoneinfo/Canada/Pacific branches/transforms/lib/pytz/zoneinfo/Canada/Saskatchewan branches/transforms/lib/pytz/zoneinfo/Canada/Yukon branches/transforms/lib/pytz/zoneinfo/Chile/ branches/transforms/lib/pytz/zoneinfo/Chile/Continental branches/transforms/lib/pytz/zoneinfo/Chile/EasterIsland branches/transforms/lib/pytz/zoneinfo/Cuba branches/transforms/lib/pytz/zoneinfo/EET branches/transforms/lib/pytz/zoneinfo/EST branches/transforms/lib/pytz/zoneinfo/EST5EDT branches/transforms/lib/pytz/zoneinfo/Egypt branches/transforms/lib/pytz/zoneinfo/Eire branches/transforms/lib/pytz/zoneinfo/Etc/ branches/transforms/lib/pytz/zoneinfo/Etc/GMT branches/transforms/lib/pytz/zoneinfo/Etc/GMT+0 branches/transforms/lib/pytz/zonei... [truncated message content] |
From: <md...@us...> - 2007-11-12 13:53:41
|
Revision: 4220 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4220&view=rev Author: mdboom Date: 2007-11-12 05:53:38 -0800 (Mon, 12 Nov 2007) Log Message: ----------- Merged revisions 4191-4219 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4191 | efiring | 2007-11-09 14:37:15 -0500 (Fri, 09 Nov 2007) | 2 lines Remove numerix as nx from pylab ........ r4194 | mdboom | 2007-11-09 15:14:29 -0500 (Fri, 09 Nov 2007) | 2 lines Fix exception plotting an errorbar graph with only two data points. ........ r4195 | mdboom | 2007-11-09 15:15:52 -0500 (Fri, 09 Nov 2007) | 2 lines Bugfix: [ 1808189 ] lw kwarg broken in errorbar (Thanks Joe Monaco). ........ r4196 | dsdale | 2007-11-09 15:37:57 -0500 (Fri, 09 Nov 2007) | 2 lines minor formatting change to dependency report ........ r4197 | mdboom | 2007-11-09 15:59:47 -0500 (Fri, 09 Nov 2007) | 5 lines Bugfix: [ 1757315 ] ValueError: Cannot set nonpositive limits with log transform. The axes scales were not getting set back to "linear" when cla() is called, so autoscale_limits gets confused on the next call to plot(). ........ r4198 | mdboom | 2007-11-09 16:09:04 -0500 (Fri, 09 Nov 2007) | 5 lines Bugfix: [ 1745650 ] patch for mlab.py's comment handling Comment handling had the potential to lose the last character of a line. Slightly different from user submitted patch -- uses split() instead of three lines of Python code. ........ r4199 | mdboom | 2007-11-09 16:27:30 -0500 (Fri, 09 Nov 2007) | 3 lines Bugfix: [ 1732274 ] No antialiasing with pie on wxpython Reducing the sampling of the curve on the wedge looks much better. ........ r4200 | mdboom | 2007-11-09 16:28:58 -0500 (Fri, 09 Nov 2007) | 2 lines Oops in last commit. ........ r4214 | dsdale | 2007-11-10 18:08:19 -0500 (Sat, 10 Nov 2007) | 3 lines added flags in setup.cfg to disable providing external packages like pytz and datetime ........ r4215 | dsdale | 2007-11-10 18:10:15 -0500 (Sat, 10 Nov 2007) | 2 lines added a comment in setup.cfg, will rename to setup.cfg.template ........ r4216 | dsdale | 2007-11-10 18:20:44 -0500 (Sat, 10 Nov 2007) | 2 lines dont use spaces in setup.cfg section names ........ r4217 | dsdale | 2007-11-10 18:21:38 -0500 (Sat, 10 Nov 2007) | 3 lines moved setup.cfg to setup.cfg.template, so local modifications can be made without affecting the trunk ........ r4218 | dsdale | 2007-11-10 18:26:36 -0500 (Sat, 10 Nov 2007) | 2 lines expand comments in build report ........ Modified Paths: -------------- branches/transforms/examples/animation_blit_fltk.py branches/transforms/examples/annotation_demo.py branches/transforms/examples/barcode_demo.py branches/transforms/examples/broken_barh.py branches/transforms/examples/clippath_test.py branches/transforms/examples/custom_figure_class.py branches/transforms/examples/date_demo_convert.py branches/transforms/examples/dynamic_collection.py branches/transforms/examples/fill_demo2.py branches/transforms/examples/gradient_bar.py branches/transforms/examples/interp_demo.py branches/transforms/examples/lasso_demo.py branches/transforms/examples/pick_event_demo.py branches/transforms/examples/scatter_custom_symbol.py branches/transforms/examples/scatter_star_poly.py branches/transforms/examples/spy_demos.py branches/transforms/examples/xcorr_demo.py branches/transforms/examples/zoom_window.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/pylab.py branches/transforms/setup.py branches/transforms/setupext.py Added Paths: ----------- branches/transforms/setup.cfg.template Removed Paths: ------------- branches/transforms/setup.cfg Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4190 + /trunk/matplotlib:1-4219 Modified: branches/transforms/examples/animation_blit_fltk.py =================================================================== --- branches/transforms/examples/animation_blit_fltk.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/animation_blit_fltk.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -3,7 +3,7 @@ import matplotlib matplotlib.use('FltkAgg') import pylab as p -import numpy as nx +import numpy as npy import time @@ -29,7 +29,7 @@ self.background = self.canvas.copy_from_bbox(self.ax.bbox) self.canvas.restore_region(self.background) # update the data - line.set_ydata(nx.sin(x+self.cnt/10.0)) + line.set_ydata(npy.sin(x+self.cnt/10.0)) # just draw the animated artist self.ax.draw_artist(line) # just redraw the axes rectangle @@ -45,8 +45,8 @@ p.subplots_adjust(left=0.3, bottom=0.3) # check for flipy bugs p.grid() # to ensure proper background restore # create the initial line -x = nx.arange(0,2*nx.pi,0.01) -line, = p.plot(x, nx.sin(x), animated=True) +x = npy.arange(0,2*npy.pi,0.01) +line, = p.plot(x, npy.sin(x), animated=True) p.draw() anim=animator(ax) Modified: branches/transforms/examples/annotation_demo.py =================================================================== --- branches/transforms/examples/annotation_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/annotation_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -32,17 +32,19 @@ """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.patches import Ellipse +import numpy as npy + if 1: # if only one location is given, the text and xypoint being # annotated are assumed to be the same fig = figure() ax = fig.add_subplot(111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5)) - t = nx.arange(0.0, 5.0, 0.01) - s = nx.cos(2*nx.pi*t) + t = npy.arange(0.0, 5.0, 0.01) + s = npy.cos(2*npy.pi*t) line, = ax.plot(t, s, lw=3, color='purple') ax.annotate('axes center', xy=(.5, .5), xycoords='axes fraction', @@ -85,8 +87,8 @@ # respected fig = figure() ax = fig.add_subplot(111, polar=True) - r = nx.arange(0,1,0.001) - theta = 2*2*nx.pi*r + r = npy.arange(0,1,0.001) + theta = 2*2*npy.pi*r line, = ax.plot(theta, r, color='#ee8d18', lw=3) ind = 800 @@ -115,8 +117,8 @@ ax.add_artist(el) el.set_clip_box(ax.bbox) ax.annotate('the top', - xy=(nx.pi/2., 10.), # theta, radius - xytext=(nx.pi/3, 20.), # theta, radius + xy=(npy.pi/2., 10.), # theta, radius + xytext=(npy.pi/3, 20.), # theta, radius xycoords='polar', textcoords='polar', arrowprops=dict(facecolor='black', shrink=0.05), Modified: branches/transforms/examples/barcode_demo.py =================================================================== --- branches/transforms/examples/barcode_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/barcode_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,14 +1,16 @@ -from pylab import figure, show, cm, nx +from matplotlib.pyplot import figure, show, cm +from numpy import where +from numpy.random import rand # the bar -x = nx.where(nx.mlab.rand(500)>0.7, 1.0, 0.0) +x = where(rand(500)>0.7, 1.0, 0.0) axprops = dict(xticks=[], yticks=[]) barprops = dict(aspect='auto', cmap=cm.binary, interpolation='nearest') fig = figure() -# a vertical barcode +# a vertical barcode -- this is broken at present x.shape = len(x), 1 ax = fig.add_axes([0.1, 0.3, 0.1, 0.6], **axprops) ax.imshow(x, **barprops) Modified: branches/transforms/examples/broken_barh.py =================================================================== --- branches/transforms/examples/broken_barh.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/broken_barh.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -2,7 +2,7 @@ """ Make a "broken" horizontal bar plot, ie one with gaps """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show fig = figure() ax = fig.add_subplot(111) Modified: branches/transforms/examples/clippath_test.py =================================================================== --- branches/transforms/examples/clippath_test.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/clippath_test.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,9 +1,10 @@ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show import matplotlib.transforms as transforms from matplotlib.patches import RegularPolygon import matplotlib.agg as agg +from numpy import arange, sin, pi +from numpy.random import rand - class ClipWindow: def __init__(self, ax, line): self.ax = ax @@ -47,9 +48,9 @@ fig = figure(figsize=(8,8)) ax = fig.add_subplot(111) -t = nx.arange(0.0, 4.0, 0.01) -s = 2*nx.sin(2*nx.pi*8*t) +t = arange(0.0, 4.0, 0.01) +s = 2*sin(2*pi*8*t) -line, = ax.plot(t, 2*(nx.mlab.rand(len(t))-0.5), 'b-') +line, = ax.plot(t, 2*(rand(len(t))-0.5), 'b-') clipwin = ClipWindow(ax, line) show() Modified: branches/transforms/examples/custom_figure_class.py =================================================================== --- branches/transforms/examples/custom_figure_class.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/custom_figure_class.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,7 +1,7 @@ """ You can pass a custom Figure constructor to figure if youy want to derive from the default Figure. This simple example creates a figure with a figure title """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.figure import Figure class MyFigure(Figure): Modified: branches/transforms/examples/date_demo_convert.py =================================================================== --- branches/transforms/examples/date_demo_convert.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/date_demo_convert.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,16 +1,16 @@ #!/usr/bin/env python import datetime -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.dates import DayLocator, HourLocator, DateFormatter, drange +from numpy import arange - date1 = datetime.datetime( 2000, 3, 2) date2 = datetime.datetime( 2000, 3, 6) delta = datetime.timedelta(hours=6) dates = drange(date1, date2, delta) -y = nx.arange( len(dates)*1.0) +y = arange( len(dates)*1.0) fig = figure() ax = fig.add_subplot(111) @@ -25,7 +25,7 @@ # tick, not the base multiple ax.xaxis.set_major_locator( DayLocator() ) -ax.xaxis.set_minor_locator( HourLocator(nx.arange(0,25,6)) ) +ax.xaxis.set_minor_locator( HourLocator(arange(0,25,6)) ) ax.xaxis.set_major_formatter( DateFormatter('%Y-%m-%d') ) ax.fmt_xdata = DateFormatter('%Y-%m-%d %H:%M:%S') Modified: branches/transforms/examples/dynamic_collection.py =================================================================== --- branches/transforms/examples/dynamic_collection.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/dynamic_collection.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,7 +1,8 @@ import random from matplotlib.collections import RegularPolyCollection import matplotlib.cm as cm -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +from numpy.random import rand fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) @@ -29,8 +30,8 @@ press 'a' to add a random point from the collection, 'd' to delete one """ if event.key=='a': - x,y = nx.mlab.rand(2) - color = cm.jet(nx.mlab.rand()) + x,y = rand(2) + color = cm.jet(rand()) offsets.append((x,y)) facecolors.append(color) fig.canvas.draw() Modified: branches/transforms/examples/fill_demo2.py =================================================================== --- branches/transforms/examples/fill_demo2.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/fill_demo2.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,8 +1,10 @@ -from pylab import figure, nx, show +from matplotlib.pyplot import figure, show +from numpy import arange, sin, pi + fig = figure() ax = fig.add_subplot(111) -t = nx.arange(0.0,3.01,0.01) -s = nx.sin(2*nx.pi*t) -c = nx.sin(4*nx.pi*t) +t = arange(0.0,3.01,0.01) +s = sin(2*pi*t) +c = sin(4*pi*t) ax.fill(t, s, 'b', t, c, 'g', alpha=0.2) show() Modified: branches/transforms/examples/gradient_bar.py =================================================================== --- branches/transforms/examples/gradient_bar.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/gradient_bar.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,4 +1,6 @@ -from pylab import figure, show, nx, cm +from matplotlib.pyplot import figure, show, cm +from numpy import arange +from numpy.random import rand def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6],[.7,.7]] @@ -19,8 +21,8 @@ extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 -x = nx.arange(N)+0.25 -y = nx.mlab.rand(N) +x = arange(N)+0.25 +y = rand(N) gbar(ax, x, y, width=0.7) ax.set_aspect('normal') show() Modified: branches/transforms/examples/interp_demo.py =================================================================== --- branches/transforms/examples/interp_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/interp_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,6 +1,9 @@ -from pylab import figure, show, nx, linspace, stineman_interp -x = linspace(0,2*nx.pi,20); -y = nx.sin(x); yp = None +from matplotlib.pyplot import figure, show +from numpy import pi, sin, linspace +from matplotlib.mlab import stineman_interp + +x = linspace(0,2*pi,20); +y = sin(x); yp = None xi = linspace(x[0],x[-1],100); yi = stineman_interp(xi,x,y,yp); Modified: branches/transforms/examples/lasso_demo.py =================================================================== --- branches/transforms/examples/lasso_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/lasso_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -13,7 +13,9 @@ from matplotlib.colors import colorConverter from matplotlib.collections import RegularPolyCollection -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +from numpy import nonzero +from numpy.random import rand class Datum: colorin = colorConverter.to_rgba('red') @@ -47,9 +49,7 @@ self.cid = self.canvas.mpl_connect('button_press_event', self.onpress) def callback(self, verts): - #print 'all done', verts - #ind = matplotlib.mlab._inside_poly_deprecated(self.xys, verts) - ind = nx.nonzero(points_inside_poly(self.xys, verts)) + ind = nonzero(points_inside_poly(self.xys, verts))[0] for i in range(self.Nxy): if i in ind: self.facecolors[i] = Datum.colorin @@ -66,7 +66,7 @@ # acquire a lock on the widget drawing self.canvas.widgetlock(self.lasso) -data = [Datum(*xy) for xy in nx.mlab.rand(100, 2)] +data = [Datum(*xy) for xy in rand(100, 2)] fig = figure() ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) Modified: branches/transforms/examples/pick_event_demo.py =================================================================== --- branches/transforms/examples/pick_event_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/pick_event_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -63,23 +63,25 @@ The examples below illustrate each of these methods. """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show from matplotlib.lines import Line2D from matplotlib.patches import Patch, Rectangle from matplotlib.text import Text from matplotlib.image import AxesImage +import numpy as npy +from numpy.random import rand if 1: # simple picking, lines, rectangles and text fig = figure() ax1 = fig.add_subplot(211) ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) - line, = ax1.plot(nx.mlab.rand(100), 'o', picker=5) # 5 points tolerance + line, = ax1.plot(rand(100), 'o', picker=5) # 5 points tolerance # pick the rectangle ax2 = fig.add_subplot(212) - bars = ax2.bar(range(10), nx.mlab.rand(10), picker=True) + bars = ax2.bar(range(10), rand(10), picker=True) for label in ax2.get_xticklabels(): # make the xtick labels pickable label.set_picker(True) @@ -90,7 +92,7 @@ xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind - print 'onpick1 line:', zip(nx.take(xdata, ind), nx.take(ydata, ind)) + print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist print 'onpick1 patch:', patch.get_path() @@ -122,12 +124,12 @@ xdata = line.get_xdata() ydata = line.get_ydata() maxd = 0.05 - d = nx.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.) + d = npy.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.) - ind = nx.nonzero(nx.less_equal(d, maxd)) + ind = npy.nonzero(npy.less_equal(d, maxd)) if len(ind): - pickx = nx.take(xdata, ind) - picky = nx.take(ydata, ind) + pickx = npy.take(xdata, ind) + picky = npy.take(ydata, ind) props = dict(ind=ind, pickx=pickx, picky=picky) return True, props else: @@ -139,16 +141,16 @@ fig = figure() ax1 = fig.add_subplot(111) ax1.set_title('custom picker for line data') - line, = ax1.plot(nx.mlab.rand(100), nx.mlab.rand(100), 'o', picker=line_picker) + line, = ax1.plot(rand(100), rand(100), 'o', picker=line_picker) fig.canvas.mpl_connect('pick_event', onpick2) if 1: # picking on a scatter plot (matplotlib.collections.RegularPolyCollection) - x, y, c, s = nx.mlab.rand(4, 100) + x, y, c, s = rand(4, 100) def onpick3(event): ind = event.ind - print 'onpick3 scatter:', ind, nx.take(x, ind), nx.take(y, ind) + print 'onpick3 scatter:', ind, npy.take(x, ind), npy.take(y, ind) fig = figure() ax1 = fig.add_subplot(111) @@ -159,10 +161,10 @@ if 1: # picking images (matplotlib.image.AxesImage) fig = figure() ax1 = fig.add_subplot(111) - im1 = ax1.imshow(nx.rand(10,5), extent=(1,2,1,2), picker=True) - im2 = ax1.imshow(nx.rand(5,10), extent=(3,4,1,2), picker=True) - im3 = ax1.imshow(nx.rand(20,25), extent=(1,2,3,4), picker=True) - im4 = ax1.imshow(nx.rand(30,12), extent=(3,4,3,4), picker=True) + im1 = ax1.imshow(rand(10,5), extent=(1,2,1,2), picker=True) + im2 = ax1.imshow(rand(5,10), extent=(3,4,1,2), picker=True) + im3 = ax1.imshow(rand(20,25), extent=(1,2,3,4), picker=True) + im4 = ax1.imshow(rand(30,12), extent=(3,4,3,4), picker=True) ax1.axis([0,5,0,5]) def onpick4(event): Modified: branches/transforms/examples/scatter_custom_symbol.py =================================================================== --- branches/transforms/examples/scatter_custom_symbol.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/scatter_custom_symbol.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,12 +1,14 @@ -from pylab import figure, nx, show +from matplotlib.pyplot import figure, show +from numpy import arange, pi, cos, sin, pi +from numpy.random import rand # unit area ellipse rx, ry = 3., 1. -area = rx * ry * nx.pi -theta = nx.arange(0, 2*nx.pi+0.01, 0.1) -verts = zip(rx/area*nx.cos(theta), ry/area*nx.sin(theta)) +area = rx * ry * pi +theta = arange(0, 2*pi+0.01, 0.1) +verts = zip(rx/area*cos(theta), ry/area*sin(theta)) -x,y,s,c = nx.mlab.rand(4, 30) +x,y,s,c = rand(4, 30) s*= 10**2. fig = figure() Modified: branches/transforms/examples/scatter_star_poly.py =================================================================== --- branches/transforms/examples/scatter_star_poly.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/scatter_star_poly.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,7 +1,7 @@ import pylab -x = pylab.nx.mlab.rand(10) -y = pylab.nx.mlab.rand(10) +x = pylab.rand(10) +y = pylab.rand(10) pylab.subplot(321) pylab.scatter(x,y,s=80,marker=">") Modified: branches/transforms/examples/spy_demos.py =================================================================== --- branches/transforms/examples/spy_demos.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/spy_demos.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -2,7 +2,8 @@ Plot the sparsity pattern of arrays """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +import numpy fig = figure() ax1 = fig.add_subplot(221) @@ -10,7 +11,7 @@ ax3 = fig.add_subplot(223) ax4 = fig.add_subplot(224) -x = nx.mlab.randn(20,20) +x = numpy.random.randn(20,20) x[5] = 0. x[:,12] = 0. Modified: branches/transforms/examples/xcorr_demo.py =================================================================== --- branches/transforms/examples/xcorr_demo.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/xcorr_demo.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,6 +1,7 @@ -from pylab import figure, show, nx +from matplotlib.pylab import figure, show +import numpy -x,y = nx.mlab.randn(2,100) +x,y = numpy.random.randn(2,100) fig = figure() ax1 = fig.add_subplot(211) ax1.xcorr(x, y, usevlines=True, maxlags=50, normed=True) @@ -13,3 +14,4 @@ ax2.axhline(0, color='black', lw=2) show() + Modified: branches/transforms/examples/zoom_window.py =================================================================== --- branches/transforms/examples/zoom_window.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/examples/zoom_window.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -9,15 +9,17 @@ Note the diameter of the circles in the scatter are defined in points**2, so their size is independent of the zoom """ -from pylab import figure, show, nx +from matplotlib.pyplot import figure, show +import numpy figsrc = figure() figzoom = figure() axsrc = figsrc.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False) -axzoom = figzoom.add_subplot(111, xlim=(0.45,0.55), ylim=(0.4,.6), autoscale_on=False) +axzoom = figzoom.add_subplot(111, xlim=(0.45,0.55), ylim=(0.4,.6), + autoscale_on=False) axsrc.set_title('Click to zoom') axzoom.set_title('zoom window') -x,y,s,c = nx.mlab.rand(4,200) +x,y,s,c = numpy.random.rand(4,200) s *= 200 Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -740,6 +740,8 @@ self.xaxis.cla() self.yaxis.cla() + self.set_xscale('linear') + self.set_yscale('linear') self.ignore_existing_data_limits = True self.callbacks = cbook.CallbackRegistry(('xlim_changed', 'ylim_changed')) @@ -3787,7 +3789,7 @@ plot_kw['mew']=kwargs['mew'] if xerr is not None: - if iterable(xerr) and len(xerr)==2: + if iterable(xerr) and len(xerr)==2 and iterable(xerr[0]) and iterable(xerr[1]): # using list comps rather than arrays to preserve units left = [thisx-thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[0])] right = [thisx+thiserr for (thisx, thiserr) in cbook.safezip(x,xerr[1])] @@ -3821,7 +3823,7 @@ caplines.extend( self.plot(right, y, 'k|', **plot_kw) ) if yerr is not None: - if iterable(yerr) and len(yerr)==2: + if iterable(yerr) and len(yerr)==2 and iterable(yerr[0]) and iterable(yerr[1]): # using list comps rather than arrays to preserve units lower = [thisy-thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[0])] upper = [thisy+thiserr for (thisy, thiserr) in cbook.safezip(y,yerr[1])] Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -222,7 +222,7 @@ ACCEPTS: float or sequence of floats """ self._linewidths = self._get_value(lw) - set_linewidth = set_linewidths + set_lw = set_linewidth = set_linewidths def set_linestyles(self, ls): """ Modified: branches/transforms/lib/matplotlib/mlab.py =================================================================== --- branches/transforms/lib/matplotlib/mlab.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/lib/matplotlib/mlab.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -1265,7 +1265,7 @@ converterseq = None for i,line in enumerate(fh): if i<skiprows: continue - line = line[:line.find(comments)].strip() + line = line.split(comments, 1)[0].strip() if not len(line): continue if converterseq is None: converterseq = [converters.get(j,float) Modified: branches/transforms/lib/matplotlib/pylab.py =================================================================== --- branches/transforms/lib/matplotlib/pylab.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/lib/matplotlib/pylab.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -202,8 +202,13 @@ from cbook import flatten, is_string_like, exception_to_str, popd, \ silent_list, iterable, enumerate, dedent -import matplotlib.numerix as nx import numpy as npy +# The masked array namespace is brought in as ma; getting +# this from numerix allows one to select either numpy.ma or +# Pierre G-M's maskedarray implementation, which may +# replace the present numpy.ma implementation in a future +# numpy release. +from matplotlib.numerix import npyma as ma from matplotlib import mpl # pulls in most modules Deleted: branches/transforms/setup.cfg =================================================================== --- branches/transforms/setup.cfg 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/setup.cfg 2007-11-12 13:53:38 UTC (rev 4220) @@ -1,7 +0,0 @@ -[egg_info] -tag_svn_revision = 1 - -[status] -# To suppress display of the dependencies and their versions -# at the top of the build log, uncomment the following line: -# suppress = 1 \ No newline at end of file Copied: branches/transforms/setup.cfg.template (from rev 4218, trunk/matplotlib/setup.cfg.template) =================================================================== --- branches/transforms/setup.cfg.template (rev 0) +++ branches/transforms/setup.cfg.template 2007-11-12 13:53:38 UTC (rev 4220) @@ -0,0 +1,24 @@ +# Rename this file to setup.cfg to modify matplotlib's +# build options. + +[egg_info] +tag_svn_revision = 1 + +[status] +# To suppress display of the dependencies and their versions +# at the top of the build log, uncomment the following line: +# +#suppress = True + +[provide_packages] +# by default, matplotlib checks for a few dependencies and +# installs them if missing. This feature can be turned off +# by uncommenting the following lines: +# +## date/timezone support: +#pytz = False +#dateutil = False +# +## experimental config package support: +#enthought.traits = False +#configobj = False Modified: branches/transforms/setup.py =================================================================== --- branches/transforms/setup.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/setup.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -13,10 +13,8 @@ rc = {'backend':'PS', 'numerix':'numpy'} -# build the image support module - requires agg and Numeric or -# numarray. You can build the image module with either Numeric or -# numarray or both. By default, matplotlib will build support for -# whatever array packages you have installed. +# build the image support module - requires agg. By default, matplotlib will +# build support for whatever array packages you have installed. BUILD_IMAGE = 1 # Build the path utilities module. This module depends on some parts @@ -87,9 +85,10 @@ build_subprocess, build_ttconv, print_line, print_status, print_message, \ print_raw, check_for_freetype, check_for_libpng, check_for_gtk, \ check_for_tk, check_for_wx, check_for_numpy, check_for_qt, check_for_qt4, \ - check_for_cairo, check_for_traits, check_for_pytz, check_for_dateutil, \ - check_for_configobj, check_for_dvipng, check_for_ghostscript, \ - check_for_latex, check_for_pdftops, check_for_datetime + check_for_cairo, check_provide_traits, check_provide_pytz, \ + check_provide_dateutil, check_provide_configobj, check_for_dvipng, \ + check_for_ghostscript, check_for_latex, check_for_pdftops, \ + check_for_datetime #import distutils.sysconfig # jdh @@ -248,8 +247,8 @@ print_raw("OPTIONAL DATE/TIMEZONE DEPENDENCIES") hasdatetime = check_for_datetime() -hasdateutil = check_for_dateutil(hasdatetime) -haspytz = check_for_pytz(hasdatetime) +provide_dateutil = check_provide_dateutil(hasdatetime) +provide_pytz = check_provide_pytz(hasdatetime) if hasdatetime: # dates require python23 datetime # only install pytz and dateutil if the user hasn't got them @@ -280,8 +279,8 @@ add_dateutil() else: # only add them if we need them - if not haspytz: add_pytz() - if not hasdateutil: add_dateutil() + if provide_pytz: add_pytz() + if provide_dateutil: add_dateutil() print_raw("") print_raw("OPTIONAL USETEX DEPENDENCIES") @@ -293,8 +292,10 @@ # TODO: comment out for mpl release: print_raw("") print_raw("EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES") -if not check_for_configobj(): py_modules.append('configobj') -if not check_for_traits(): build_traits(ext_modules, packages) +if check_provide_configobj(): + py_modules.append('configobj') +if check_provide_traits(): + build_traits(ext_modules, packages) print_raw("") print_raw("[Edit setup.cfg to suppress the above messages]") Modified: branches/transforms/setupext.py =================================================================== --- branches/transforms/setupext.py 2007-11-11 21:11:35 UTC (rev 4219) +++ branches/transforms/setupext.py 2007-11-12 13:53:38 UTC (rev 4220) @@ -99,16 +99,35 @@ numpy_inc_dirs = [] # Based on the contents of setup.cfg, determine if the status block -# should be displayed +# should be displayed, if missing external packages should be provided display_status = True +provide_pytz = True +provide_dateutil = True +provide_configobj = True +provide_traits = True if os.path.exists("setup.cfg"): config = ConfigParser.SafeConfigParser() config.read("setup.cfg") try: - if config.get("status", "suppress"): - display_status = False + display_status = not config.getboolean("status", "suppress") except: pass + try: + provide_pytz = config.getboolean("provide_packages", "pytz") + except: + pass + try: + provide_dateutil = config.getboolean("provide_packages", "dateutil") + except: + pass + try: + provide_configobj = config.getboolean("provide_packages", "configobj") + except: + pass + try: + provide_traits = config.getboolean("provide_packages", "enthought.traits") + except: + pass if display_status: def print_line(char='='): @@ -300,7 +319,7 @@ print_status("Qt", "no") return False else: - print_status("Qt", "Qt: %s, pyqt: %s" % + print_status("Qt", "Qt: %s, PyQt: %s" % (convert_qt_version(pyqtconfig.Configuration().qt_version), pyqtconfig.Configuration().pyqt_version_str)) return True @@ -312,7 +331,7 @@ print_status("Qt4", "no") return False else: - print_status("Qt4", "Qt: %s, pyqt: %s" % + print_status("Qt4", "Qt: %s, PyQt4: %s" % (convert_qt_version(pyqtconfig.Configuration().qt_version), pyqtconfig.Configuration().pyqt_version_str)) return True @@ -337,57 +356,73 @@ print_status("datetime", "present, version unknown") return True -def check_for_pytz(hasdatetime=True): +def check_provide_pytz(hasdatetime=True): try: import pytz except ImportError: - if hasdatetime: print_status("pytz", "mpl-provided") - else: print_status("pytz", "no") - return False + if hasdatetime and provide_pytz: + print_status("pytz", "matplotlib will provide") + return True + else: + print_status("pytz", "no") + return False else: print_status("pytz", pytz.__version__) - return True + return False -def check_for_dateutil(hasdatetime=True): +def check_provide_dateutil(hasdatetime=True): try: import dateutil except ImportError: - if hasdatetime: print_status("dateutil", "mpl-provided") - else: print_status("dateutil", "no") - return False + if hasdatetime and provide_dateutil: + print_status("dateutil", "matplotlib will provide") + return True + else: + print_status("dateutil", "no") + return False else: try: print_status("dateutil", dateutil.__version__) except AttributeError: print_status("dateutil", "present, version unknown") - return True + return False -def check_for_configobj(): +def check_provide_configobj(): try: import configobj except ImportError: - print_status("configobj", "mpl-provided") - return False + if provide_configobj: + print_status("configobj", "matplotlib will provide") + return True + else: + print_status("configobj", "no") + return False else: print_status("configobj", configobj.__version__) - return True + return False -def check_for_traits(): - gotit = False +def check_provide_traits(): try: from enthought import traits - gotit = True try: from enthought.traits import version except: print_status("enthought.traits", "unknown and incompatible version: < 2.0") - return gotit + return False else: - if version.version.endswith('mpl'): gotit = False - print_status("enthought.traits", version.version) + if version.version.endswith('mpl'): + print_status("enthought.traits", "matplotlib will provide") + return True + else: + print_status("enthought.traits", version.version) + return False except ImportError: - print_status("enthought.traits", "no") - return gotit + if provide_traits: + print_status("enthought.traits", "matplotlib will provide") + return True + else: + print_status("enthought.traits", "no") + return False def check_for_dvipng(): try: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-13 15:22:57
|
Revision: 4244 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4244&view=rev Author: mdboom Date: 2007-11-13 07:22:55 -0800 (Tue, 13 Nov 2007) Log Message: ----------- Merged revisions 4220-4243 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4221 | dsdale | 2007-11-12 10:23:23 -0500 (Mon, 12 Nov 2007) | 3 lines option to disable building backend extension modules moved from setup.py to setup.cfg ........ r4222 | dsdale | 2007-11-12 10:36:08 -0500 (Mon, 12 Nov 2007) | 3 lines collect config package code in one location in setup.py, so it can easily be commented out for the next release. ........ r4223 | jdh2358 | 2007-11-12 11:31:28 -0500 (Mon, 12 Nov 2007) | 2 lines added some mlab imports back to pylab ........ r4231 | mdboom | 2007-11-12 13:10:25 -0500 (Mon, 12 Nov 2007) | 3 lines Provide way to access STIX "letterlike" symbols using LaTeX font commands. Add "stixsans" option to typeset math with sans-serif glyphs. ........ r4232 | mdboom | 2007-11-12 13:53:25 -0500 (Mon, 12 Nov 2007) | 4 lines [ 1691298 ] pcolormesh shows empty plot when plotting small time ranges Avoiding downcasting the data before we have to. ........ r4233 | mdboom | 2007-11-12 13:54:49 -0500 (Mon, 12 Nov 2007) | 4 lines [ 1660316 ] PolyInteractor verts call Should be calling get_verts() instead of .verts. (Thanks JPaul Rinehimer) ........ r4234 | mdboom | 2007-11-12 14:15:28 -0500 (Mon, 12 Nov 2007) | 3 lines [ 1638661 ] Toolbox Save button not saving file in GTK BE with Python2.5 ........ r4235 | mdboom | 2007-11-12 14:22:05 -0500 (Mon, 12 Nov 2007) | 3 lines [ 1545149 ] Problem rendering image in SVG backend Reading the image file should use binary mode. ........ r4236 | jdh2358 | 2007-11-12 15:08:11 -0500 (Mon, 12 Nov 2007) | 2 lines removed duplicate load import ........ r4237 | mdboom | 2007-11-12 15:27:33 -0500 (Mon, 12 Nov 2007) | 6 lines [ 1448342 ] FigureCanvasAgg.print_figure fails with StringIO 'file' Added support to write png to an arbitrary Python file-like object in the agg backend. Will continue to use faster C-only calls if the file-like object is in fact a file. Also, clean up exception handling in write_png. ........ r4238 | mdboom | 2007-11-12 15:45:15 -0500 (Mon, 12 Nov 2007) | 3 lines [ 1358130 ] Cannot get underscore in mathtext Fixed. ........ r4239 | dsdale | 2007-11-12 17:00:15 -0500 (Mon, 12 Nov 2007) | 2 lines expose remaining build options in setup.cfg. See setup.cfg for details ........ r4240 | dsdale | 2007-11-12 18:29:44 -0500 (Mon, 12 Nov 2007) | 2 lines updated default matplotlib.conf ........ r4241 | dsdale | 2007-11-12 18:38:12 -0500 (Mon, 12 Nov 2007) | 2 lines expose verbose build option in setup.cfg ........ r4242 | dsdale | 2007-11-13 08:50:29 -0500 (Tue, 13 Nov 2007) | 4 lines updated creation of default config files at build time: * modify matplotlib.conf based on available backends and setup.cfg * modify backend selection: SVG, Agg, TkAgg, WXAgg, GTK, GTKAgg, selection in setup.cfg ........ r4243 | mdboom | 2007-11-13 10:15:36 -0500 (Tue, 13 Nov 2007) | 2 lines All backends can write to file-like objects rather than only regular files. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/Makefile branches/transforms/examples/mathtext_examples.py branches/transforms/lib/configobj.py branches/transforms/lib/dateutil/__init__.py branches/transforms/lib/matplotlib/_mathtext_data.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/backends/backend_gtk.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_wx.py branches/transforms/lib/matplotlib/config/mplconfig.py branches/transforms/lib/matplotlib/config/rcsetup.py branches/transforms/lib/matplotlib/mathtext.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/pylab.py branches/transforms/lib/matplotlib/pyplot.py branches/transforms/lib/matplotlib/rcsetup.py branches/transforms/lib/pytz/__init__.py branches/transforms/matplotlibrc.template branches/transforms/setup.cfg.template branches/transforms/setup.py branches/transforms/setupext.py branches/transforms/src/_backend_agg.cpp Added Paths: ----------- branches/transforms/examples/stix_fonts_demo.py branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.template Removed Paths: ------------- branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.backup Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4219 + /trunk/matplotlib:1-4243 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/CHANGELOG 2007-11-13 15:22:55 UTC (rev 4244) @@ -1,3 +1,47 @@ +2007-11-13 All backends now support writing to a file-like object, not + just a regular file. savefig() can be passed a file-like + object in place of a file path. - MGD + +2007-11-13 Improved the default backend selection at build time: + SVG -> Agg -> TkAgg -> WXAgg -> GTK -> GTKAgg. The last usable + backend in this progression will be chosen in the default + config file. If a backend is defined in setup.cfg, that will + be the default backend - DSD + +2007-11-13 Improved creation of default config files at build time for + traited config package - DSD + +2007-11-12 Exposed all the build options in setup.cfg. These options are + read into a dict called "options" by setupext.py. Also, added + "-mpl" tags to the version strings for packages provided by + matplotlib. Versions provided by mpl will be identified and + updated on subsequent installs - DSD + +2007-11-12 Added support for STIX fonts. A new rcParam, + mathtext.fontset, can be used to choose between: + + 'cm': + The TeX/LaTeX Computer Modern fonts + + 'stix': + The STIX fonts (see stixfonts.org) + + 'stixsans': + The STIX fonts, using sans-serif glyphs by default + + 'custom': + A generic Unicode font, in which case the mathtext font + must be specified using mathtext.bf, mathtext.it, + mathtext.sf etc. + + Added a new example, stix_fonts_demo.py to show how to access + different fonts and unusual symbols. + + - MGD + +2007-11-12 Options to disable building backend extension modules moved + from setup.py to setup.cfg - DSD + 2007-11-09 Applied Martin Teichmann's patch 1828813: a QPainter is used in paintEvent, which has to be destroyed using the method end(). If matplotlib raises an exception before the call to end - and it Modified: branches/transforms/Makefile =================================================================== --- branches/transforms/Makefile 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/Makefile 2007-11-13 15:22:55 UTC (rev 4244) @@ -1,6 +1,6 @@ # Makefile for matplotlib -PYTHON = /usr/bin/python2.5 +PYTHON = `which python` VERSION = `${PYTHON} setup.py --version` DISTFILES = API_CHANGES KNOWN_BUGS INSTALL README TODO license \ @@ -12,11 +12,11 @@ clean: ${PYTHON} setup.py clean;\ - rm -f *.png *.ps *.eps *.svg *.jpg + rm -f *.png *.ps *.eps *.svg *.jpg *.pdf find . -name "_tmp*.py" | xargs rm -f;\ find . \( -name "*~" -o -name "*.pyc" \) | xargs rm -f;\ - find examples \( -name "*.svg" -o -name "*.png" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f - find unit \( -name "*.png" -o -name "*.ps" -o -name "*.eps" \) | xargs rm -f + find examples \( -name "*.svg" C-o -name "*.png" -o -name "*.pdf" -o -name "*.ps" -o -name "*.eps" -o -name "*.tar" -o -name "*.gz" -o -name "*.log" -o -name "*.aux" -o -name "*.tex" \) | xargs rm -f + find unit \( -name "*.png" -o -name "*.ps" -o -name "*.pdf" -o -name "*.eps" \) | xargs rm -f find . \( -name "#*" -o -name ".#*" -o -name ".*~" -o -name "*~" \) | xargs rm -f Modified: branches/transforms/examples/mathtext_examples.py =================================================================== --- branches/transforms/examples/mathtext_examples.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/examples/mathtext_examples.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -6,7 +6,7 @@ stests = [ r'Kerning: AVA $AVA$', - r'\$100.00 $\alpha$', + r'\$100.00 $\alpha \_$', r'$\frac{\$100.00}{y}$', r'$x y$', r'$x+y\ x=y\ x<y\ x:y\ x,y\ x@y$', @@ -49,7 +49,7 @@ r'$\widehat{abc}\widetilde{def}$', r'$\Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega$', r'$\alpha \beta \gamma \delta \epsilon \zeta \eta \theta \iota \lambda \mu \nu \xi \pi \kappa \rho \sigma \tau \upsilon \phi \chi \psi$', - #ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' + ur'Generic symbol: $\u23ce \mathrm{\ue0f2 \U0001D538}$' ] from pylab import * @@ -66,7 +66,7 @@ print (i, s) text(0.1, -i, s, fontsize=20) - #savefig('mathtext_example') + savefig('mathtext_examples') #close('all') show() Copied: branches/transforms/examples/stix_fonts_demo.py (from rev 4243, trunk/matplotlib/examples/stix_fonts_demo.py) =================================================================== --- branches/transforms/examples/stix_fonts_demo.py (rev 0) +++ branches/transforms/examples/stix_fonts_demo.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -0,0 +1,54 @@ +#!/usr/bin/env python + +import os, sys, re + +import gc + +stests = [ + r'$\mathcircled{123} \mathrm{\mathcircled{123}} \mathbf{\mathcircled{123}}$', + r'$\mathsf{Sans \Omega} \mathrm{\mathsf{Sans \Omega}} \mathbf{\mathsf{Sans \Omega}}$', + r'$\mathtt{Monospace}$', + r'$\mathcal{CALLIGRAPHIC}$', + r'$\mathbb{Blackboard \pi}$', + r'$\mathrm{\mathbb{Blackboard \pi}}$', + r'$\mathbf{\mathbb{Blackboard \pi}}$', + r'$\mathfrak{Fraktur} \mathbf{\mathfrak{Fraktur}}$', + r'$\mathscr{Script}$', + ur'Direct Unicode: $\u23ce \mathrm{\ue0f2 \U0001D538}$' + ] + +from pylab import * + +def doall(): + tests = stests + + figure(figsize=(8, (len(tests) * 1) + 2)) + plot([0, 0], 'r') + grid(False) + axis([0, 3, -len(tests), 0]) + yticks(arange(len(tests)) * -1) + for i, s in enumerate(tests): + print (i, s) + text(0.1, -i, s, fontsize=32) + + savefig('stix_fonts_example') + #close('all') + show() + +if '--latex' in sys.argv: + fd = open("stix_fonts_examples.ltx", "w") + fd.write("\\documentclass{article}\n") + fd.write("\\begin{document}\n") + fd.write("\\begin{enumerate}\n") + + for i, s in enumerate(stests): + s = re.sub(r"(?<!\\)\$", "$$", s) + fd.write("\\item %s\n" % s) + + fd.write("\\end{enumerate}\n") + fd.write("\\end{document}\n") + fd.close() + + os.system("pdflatex stix_fonts_examples.ltx") +else: + doall() Property changes on: branches/transforms/examples/stix_fonts_demo.py ___________________________________________________________________ Name: svn:executable + * Modified: branches/transforms/lib/configobj.py =================================================================== --- branches/transforms/lib/configobj.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/configobj.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -109,7 +109,7 @@ True, False = 1, 0 -__version__ = '4.4.0' +__version__ = '4.4.0-mpl' __revision__ = '$Id: configobj.py 156 2006-01-31 14:57:08Z fuzzyman $' Modified: branches/transforms/lib/dateutil/__init__.py =================================================================== --- branches/transforms/lib/dateutil/__init__.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/dateutil/__init__.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -6,4 +6,4 @@ """ __author__ = "Gustavo Niemeyer <gu...@ni...>" __license__ = "PSF License" -__version__ = "1.2" +__version__ = "1.2-mpl" Modified: branches/transforms/lib/matplotlib/_mathtext_data.py =================================================================== --- branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -115,6 +115,7 @@ r'%' : ('cmr10', 48), r'\$' : ('cmr10', 99), r'@' : ('cmr10', 111), + r'\_' : ('cmtt10', 79), r'\Gamma' : ('cmr10', 19), r'\Delta' : ('cmr10', 6), r'\Theta' : ('cmr10', 7), @@ -2234,6 +2235,7 @@ '$': 36, '{': 123, '}': 125, +'_': 95, 'imath': 0x131, 'circumflexaccent' : 770, 'combiningbreve' : 774, @@ -2263,482 +2265,207 @@ 'bigotimes': 10754 } -uni2tex = dict([(v,k) for k,v in tex2uni.items()]) - -tex2type1 = {'doteq': 'uni2250', -'partial': 'uni2202', -'gg': 'uni226B', -'asymp': 'uni224D', -'blacktriangledown': 'uni25BE', -'otimes': 'uni2297', -'nearrow': 'uni2197', -'varpi': 'uni03D6', -'vee': 'uni2228', -'vec': 'uni20D7', -'smile': 'uni2323', -'succnsim': 'uni22E9', -'gimel': 'uni2137', -'vert': 'bar', -'varrho': 'uni03F1', -'P': 'paragraph', -'approxident': 'uni224B', -'Swarrow': 'uni21D9', -'textasciicircum': 'asciicircum', -'imageof': 'uni22B7', -'ntriangleleft': 'uni22EA', -'nleq': 'uni2270', -'div': 'divide', -'nparallel': 'uni2226', -'Leftarrow': 'uni21D0', -'lll': 'uni22D8', -'oiint': 'uni222F', -'ngeq': 'uni2271', -'Theta': 'uni0398', -'origof': 'uni22B6', -'blacksquare': 'uni25A0', -'hspace': 'uni200A', -'solbar': 'uni233F', -'neg': 'logicalnot', -'sum': 'uni2211', -'Vdash': 'uni22A9', -'coloneq': 'uni2254', -'degree': 'degree', -'bowtie': 'uni22C8', -'blacktriangleright': 'uni25B6', -'varsigma': 'uni03C2', -'leq': 'uni2264', -'ggg': 'uni22D9', -'lneqq': 'uni2268', -'scurel': 'uni22B1', -'stareq': 'uni225B', -'BbbN': 'uni2115', -'nLeftarrow': 'uni21CD', -'nLeftrightarrow': 'uni21CE', -'k': 'uni0328', -'bot': 'uni22A5', -'BbbC': 'uni2102', -'Lsh': 'uni21B0', -'leftleftarrows': 'uni21C7', -'BbbZ': 'uni2124', -'digamma': 'uni03DD', -'BbbR': 'uni211D', -'BbbP': 'uni2119', -'BbbQ': 'uni211A', -'vartriangleright': 'uni22B3', -'succsim': 'uni227F', -'wedge': 'uni2227', -'lessgtr': 'uni2276', -'veebar': 'uni22BB', -'mapsdown': 'uni21A7', -'Rsh': 'uni21B1', -'chi': 'uni03C7', -'prec': 'uni227A', -'nsubseteq': 'uni2288', -'therefore': 'uni2234', -'eqcirc': 'uni2256', -'textexclamdown': 'exclamdown', -'nRightarrow': 'uni21CF', -'flat': 'uni266D', -'notin': 'uni2209', -'llcorner': 'uni231E', -'varepsilon': 'uni03B5', -'bigtriangleup': 'uni25B3', -'aleph': 'uni2135', -'dotminus': 'uni2238', -'upsilon': 'uni03C5', -'Lambda': 'uni039B', -'cap': 'uni2229', -'barleftarrow': 'uni21E4', -'mu': 'uni03BC', -'boxplus': 'uni229E', -'mp': 'uni2213', -'circledast': 'uni229B', -'tau': 'uni03C4', -'in': 'uni2208', -'backslash': 'backslash', -'varnothing': 'uni2205', -'sharp': 'uni266F', -'eqsim': 'uni2242', -'gnsim': 'uni22E7', -'Searrow': 'uni21D8', -'updownarrows': 'uni21C5', -'heartsuit': 'uni2661', -'trianglelefteq': 'uni22B4', -'ddag': 'daggerdbl', -'sqsubseteq': 'uni2291', -'mapsfrom': 'uni21A4', -'boxbar': 'uni25EB', -'sim': 'uni223C', -'Nwarrow': 'uni21D6', -'nequiv': 'uni2262', -'succ': 'uni227B', -'vdash': 'uni22A2', -'Leftrightarrow': 'uni21D4', -'parallel': 'uni2225', -'invnot': 'uni2310', -'natural': 'uni266E', -'ss': 'germandbls', -'uparrow': 'uni2191', -'nsim': 'uni2241', -'hookrightarrow': 'uni21AA', -'Equiv': 'uni2263', -'approx': 'uni2248', -'Vvdash': 'uni22AA', -'nsucc': 'uni2281', -'leftrightharpoons': 'uni21CB', -'Re': 'uni211C', -'boxminus': 'uni229F', -'equiv': 'uni2261', -'Lleftarrow': 'uni21DA', -'thinspace': 'uni2009', -'ll': 'uni226A', -'Cup': 'uni22D3', -'measeq': 'uni225E', -'upharpoonleft': 'uni21BF', -'lq': 'quoteleft', -'Upsilon': 'uni03D2', -'subsetneq': 'uni228A', -'greater': 'greater', -'supsetneq': 'uni228B', -'Cap': 'uni22D2', -'L': 'Lslash', -'spadesuit': 'uni2660', -'lrcorner': 'uni231F', -'not': 'uni0338', -'bar': 'uni0304', -'rightharpoonaccent': 'uni20D1', -'boxdot': 'uni22A1', -'l': 'lslash', -'leftharpoondown': 'uni21BD', -'bigcup': 'uni22C3', -'iint': 'uni222C', -'bigwedge': 'uni22C0', -'downharpoonleft': 'uni21C3', -'textasciitilde': 'asciitilde', -'subset': 'uni2282', -'leqq': 'uni2266', -'mapsup': 'uni21A5', -'nvDash': 'uni22AD', -'looparrowleft': 'uni21AB', -'nless': 'uni226E', -'rightarrowbar': 'uni21E5', -'Vert': 'uni2016', -'downdownarrows': 'uni21CA', -'uplus': 'uni228E', -'simeq': 'uni2243', -'napprox': 'uni2249', -'ast': 'uni2217', -'twoheaduparrow': 'uni219F', -'doublebarwedge ?': 'uni2306', -'Sigma': 'uni03A3', -'leftharpoonaccent': 'uni20D0', -'ntrianglelefteq': 'uni22EC', -'nexists': 'uni2204', -'times': 'multiply', -'measuredangle': 'uni2221', -'bumpeq': 'uni224F', -'carriagereturn': 'uni21B5', -'adots': 'uni22F0', -'checkmark': 'uni2713', -'lambda': 'uni03BB', -'xi': 'uni03BE', -'rbrace': 'braceright', -'rbrack': 'bracketright', -'Nearrow': 'uni21D7', -'maltese': 'uni2720', -'clubsuit': 'uni2663', -'top': 'uni22A4', -'overarc': 'uni0311', -'varphi': 'uni03C6', -'Delta': 'uni0394', -'iota': 'uni03B9', -'nleftarrow': 'uni219A', -'candra': 'uni0310', -'supset': 'uni2283', -'triangleleft': 'uni25C1', -'gtreqless': 'uni22DB', -'ntrianglerighteq': 'uni22ED', -'quad': 'uni2003', -'Xi': 'uni039E', -'gtrdot': 'uni22D7', -'leftthreetimes': 'uni22CB', -'minus': 'minus', -'preccurlyeq': 'uni227C', -'nleftrightarrow': 'uni21AE', -'lambdabar': 'uni019B', -'blacktriangle': 'uni25B4', -'kernelcontraction': 'uni223B', -'Phi': 'uni03A6', -'angle': 'uni2220', -'spadesuitopen': 'uni2664', -'eqless': 'uni22DC', -'mid': 'uni2223', -'varkappa': 'uni03F0', -'Ldsh': 'uni21B2', -'updownarrow': 'uni2195', -'beta': 'uni03B2', -'textquotedblleft': 'quotedblleft', -'rho': 'uni03C1', -'alpha': 'uni03B1', -'intercal': 'uni22BA', -'beth': 'uni2136', -'grave': 'uni0300', -'acwopencirclearrow': 'uni21BA', -'nmid': 'uni2224', -'nsupset': 'uni2285', -'sigma': 'uni03C3', -'dot': 'uni0307', -'Rightarrow': 'uni21D2', -'turnednot': 'uni2319', -'backsimeq': 'uni22CD', -'leftarrowtail': 'uni21A2', -'approxeq': 'uni224A', -'curlyeqsucc': 'uni22DF', -'rightarrowtail': 'uni21A3', -'Psi': 'uni03A8', -'copyright': 'copyright', -'yen': 'yen', -'vartriangleleft': 'uni22B2', -'rasp': 'uni02BC', -'triangleright': 'uni25B7', -'precsim': 'uni227E', -'infty': 'uni221E', -'geq': 'uni2265', -'updownarrowbar': 'uni21A8', -'precnsim': 'uni22E8', -'H': 'uni030B', -'ulcorner': 'uni231C', -'looparrowright': 'uni21AC', -'ncong': 'uni2247', -'downarrow': 'uni2193', -'circeq': 'uni2257', -'subseteq': 'uni2286', -'bigstar': 'uni2605', -'prime': 'uni2032', -'lceil': 'uni2308', -'Rrightarrow': 'uni21DB', -'oiiint': 'uni2230', -'curlywedge': 'uni22CF', -'vDash': 'uni22A8', -'lfloor': 'uni230A', -'ddots': 'uni22F1', -'exists': 'uni2203', -'underbar': 'uni0331', -'Pi': 'uni03A0', -'leftrightarrows': 'uni21C6', -'sphericalangle': 'uni2222', -'coprod': 'uni2210', -'circledcirc': 'uni229A', -'gtrsim': 'uni2273', -'gneqq': 'uni2269', -'between': 'uni226C', -'theta': 'uni03B8', -'complement': 'uni2201', -'arceq': 'uni2258', -'nVdash': 'uni22AE', -'S': 'section', -'wr': 'uni2240', -'wp': 'uni2118', -'backcong': 'uni224C', -'lasp': 'uni02BD', -'c': 'uni0327', -'nabla': 'uni2207', -'dotplus': 'uni2214', -'eta': 'uni03B7', -'forall': 'uni2200', -'eth': 'eth', -'colon': 'colon', -'sqcup': 'uni2294', -'rightrightarrows': 'uni21C9', -'sqsupset': 'uni2290', -'mapsto': 'uni21A6', -'bigtriangledown': 'uni25BD', -'sqsupseteq': 'uni2292', -'propto': 'uni221D', -'pi': 'uni03C0', -'pm': 'plusminus', -'dots': 'ellipsis', -'nrightarrow': 'uni219B', -'textasciiacute': 'acute', -'Doteq': 'uni2251', -'breve': 'uni0306', -'sqcap': 'uni2293', -'twoheadrightarrow': 'uni21A0', -'kappa': 'uni03BA', -'vartriangle': 'uni25B5', -'diamondsuit': 'uni2662', -'pitchfork': 'uni22D4', -'blacktriangleleft': 'uni25C0', -'nprec': 'uni2280', -'vdots': 'uni22EE', -'curvearrowright': 'uni21B7', -'barwedge': 'uni22BC', -'multimap': 'uni22B8', -'textquestiondown': 'questiondown', -'cong': 'uni2245', -'rtimes': 'uni22CA', -'rightzigzagarrow': 'uni21DD', -'rightarrow': 'uni2192', -'leftarrow': 'uni2190', -'__sqrt__': 'uni221A', -'twoheaddownarrow': 'uni21A1', -'oint': 'uni222E', -'bigvee': 'uni22C1', -'eqdef': 'uni225D', -'sterling': 'sterling', -'phi': 'uni03D5', -'Updownarrow': 'uni21D5', -'backprime': 'uni2035', -'emdash': 'emdash', -'Gamma': 'uni0393', -'i': 'dotlessi', -'rceil': 'uni2309', -'leftharpoonup': 'uni21BC', -'Im': 'uni2111', -'curvearrowleft': 'uni21B6', -'wedgeq': 'uni2259', -'fallingdotseq': 'uni2252', -'curlyeqprec': 'uni22DE', -'questeq': 'uni225F', -'less': 'less', -'upuparrows': 'uni21C8', -'tilde': 'uni0303', -'textasciigrave': 'grave', -'smallsetminus': 'uni2216', -'ell': 'uni2113', -'cup': 'uni222A', -'danger': 'uni2621', -'nVDash': 'uni22AF', -'cdotp': 'periodcentered', -'cdots': 'uni22EF', -'hat': 'uni0302', -'eqgtr': 'uni22DD', -'enspace': 'uni2002', -'psi': 'uni03C8', -'frown': 'uni2322', -'acute': 'uni0301', -'downzigzagarrow': 'uni21AF', -'ntriangleright': 'uni22EB', -'cupdot': 'uni228D', -'circleddash': 'uni229D', -'oslash': 'uni2298', -'mho': 'uni2127', -'d': 'uni0323', -'sqsubset': 'uni228F', -'cdot': 'uni22C5', -'Omega': 'uni03A9', -'OE': 'OE', -'veeeq': 'uni225A', -'Finv': 'uni2132', -'t': 'uni0361', -'leftrightarrow': 'uni2194', -'swarrow': 'uni2199', -'rightthreetimes': 'uni22CC', -'rightleftharpoons': 'uni21CC', -'lesssim': 'uni2272', -'searrow': 'uni2198', -'because': 'uni2235', -'gtrless': 'uni2277', -'star': 'uni22C6', -'nsubset': 'uni2284', -'zeta': 'uni03B6', -'dddot': 'uni20DB', -'bigcirc': 'uni25CB', -'Supset': 'uni22D1', -'circ': 'uni2218', -'slash': 'uni2215', -'ocirc': 'uni030A', -'prod': 'uni220F', -'twoheadleftarrow': 'uni219E', -'daleth': 'uni2138', -'upharpoonright': 'uni21BE', -'odot': 'uni2299', -'Uparrow': 'uni21D1', -'O': 'Oslash', -'hookleftarrow': 'uni21A9', -'trianglerighteq': 'uni22B5', -'nsime': 'uni2244', -'oe': 'oe', -'nwarrow': 'uni2196', -'o': 'oslash', -'ddddot': 'uni20DC', -'downharpoonright': 'uni21C2', -'succcurlyeq': 'uni227D', -'gamma': 'uni03B3', -'scrR': 'uni211B', -'dag': 'dagger', -'thickspace': 'uni2005', -'frakZ': 'uni2128', -'lessdot': 'uni22D6', -'triangledown': 'uni25BF', -'ltimes': 'uni22C9', -'scrB': 'uni212C', -'endash': 'endash', -'scrE': 'uni2130', -'scrF': 'uni2131', -'scrH': 'uni210B', -'scrI': 'uni2110', -'rightharpoondown': 'uni21C1', -'scrL': 'uni2112', -'scrM': 'uni2133', -'frakC': 'uni212D', -'nsupseteq': 'uni2289', -'circledR': 'registered', -'circledS': 'uni24C8', -'ngtr': 'uni226F', -'bigcap': 'uni22C2', -'scre': 'uni212F', -'Downarrow': 'uni21D3', -'scrg': 'uni210A', -'overleftrightarrow': 'uni20E1', -'scro': 'uni2134', -'lnsim': 'uni22E6', -'eqcolon': 'uni2255', -'curlyvee': 'uni22CE', -'urcorner': 'uni231D', -'lbrace': 'braceleft', -'Bumpeq': 'uni224E', -'delta': 'uni03B4', -'boxtimes': 'uni22A0', -'overleftarrow': 'uni20D6', -'prurel': 'uni22B0', -'clubsuitopen': 'uni2667', -'cwopencirclearrow': 'uni21BB', -'geqq': 'uni2267', -'rightleftarrows': 'uni21C4', -'ac': 'uni223E', -'ae': 'ae', -'int': 'uni222B', -'rfloor': 'uni230B', -'risingdotseq': 'uni2253', -'nvdash': 'uni22AC', -'diamond': 'uni22C4', -'ddot': 'uni0308', -'backsim': 'uni223D', -'oplus': 'uni2295', -'triangleq': 'uni225C', -'check': 'uni030C', -'ni': 'uni220B', -'iiint': 'uni222D', -'ne': 'uni2260', -'lesseqgtr': 'uni22DA', -'obar': 'uni233D', -'supseteq': 'uni2287', -'nu': 'uni03BD', -'AA': 'uni212B', -'AE': 'AE', -'models': 'uni22A7', -'ominus': 'uni2296', -'dashv': 'uni22A3', -'omega': 'uni03C9', -'rq': 'quoteright', -'Subset': 'uni22D0', -'rightharpoonup': 'uni21C0', -'Rdsh': 'uni21B3', -'bullet': 'uni2219', -'divideontimes': 'uni22C7', -'lbrack': 'bracketleft', -'textquotedblright': 'quotedblright', -'Colon': 'uni2237'} - -type12tex = dict([(v,k) for k,v in tex2type1.items()]) +# Each element is a 4-tuple of the form: +# src_start, src_end, dst_font, dst_start +# +stix_virtual_fonts = { + 'bb': + { + 'rm': + [ + (0x0030, 0x0039, 'rm', 0x1d7d8), # 0-9 + (0x0041, 0x0042, 'rm', 0x1d538), # A-B + (0x0043, 0x0043, 'rm', 0x2102), # C + (0x0044, 0x0047, 'rm', 0x1d53b), # D-G + (0x0048, 0x0048, 'rm', 0x210d), # H + (0x0049, 0x004d, 'rm', 0x1d540), # I-M + (0x004e, 0x004e, 'rm', 0x2115), # N + (0x004f, 0x004f, 'rm', 0x1d546), # O + (0x0050, 0x0051, 'rm', 0x2119), # P-Q + (0x0052, 0x0052, 'rm', 0x211d), # R + (0x0053, 0x0059, 'rm', 0x1d54a), # S-Y + (0x005a, 0x005a, 'rm', 0x2124), # Z + (0x0061, 0x007a, 'rm', 0x1d552), # a-z + (0x0393, 0x0393, 'rm', 0x213e), # \Gamma + (0x03a0, 0x03a0, 'rm', 0x213f), # \Pi + (0x03a3, 0x03a3, 'rm', 0x2140), # \Sigma + (0x03b3, 0x03b3, 'rm', 0x213d), # \gamma + (0x03c0, 0x03c0, 'rm', 0x213c), # \pi + ], + 'it': + [ + (0x0041, 0x0041, 'it', 0xe154), # A-B + (0x0043, 0x0043, 'it', 0x2102), # C (missing in beta STIX fonts) + (0x0044, 0x0044, 'it', 0x2145), # D + (0x0045, 0x0047, 'it', 0xe156), # E-G + (0x0048, 0x0048, 'it', 0x210d), # H (missing in beta STIX fonts) + (0x0049, 0x004d, 'it', 0xe159), # I-M + (0x004e, 0x004e, 'it', 0x2115), # N (missing in beta STIX fonts) + (0x004f, 0x004f, 'it', 0xe15e), # O + (0x0050, 0x0051, 'it', 0x2119), # P-Q (missing in beta STIX fonts) + (0x0052, 0x0052, 'it', 0x211d), # R (missing in beta STIX fonts) + (0x0053, 0x0059, 'it', 0xe15f), # S-Y + (0x005a, 0x005a, 'it', 0x2124), # Z (missing in beta STIX fonts) + (0x0061, 0x0063, 'it', 0xe166), # a-c + (0x0064, 0x0065, 'it', 0x2146), # d-e + (0x0066, 0x0068, 'it', 0xe169), # f-h + (0x0069, 0x006a, 'it', 0x2148), # i-j + (0x006b, 0x007a, 'it', 0xe16c), # k-z + (0x0393, 0x0393, 'it', 0x213e), # \Gamma (missing in beta STIX fonts) + (0x03a0, 0x03a0, 'it', 0x213f), # \Pi + (0x03a3, 0x03a3, 'it', 0x2140), # \Sigma (missing in beta STIX fonts) + (0x03b3, 0x03b3, 'it', 0x213d), # \gamma (missing in beta STIX fonts) + (0x03c0, 0x03c0, 'it', 0x213c), # \pi + ], + 'bf': + [ + (0x0030, 0x0039, 'rm', 0x1d7d8), # 0-9 + (0x0041, 0x005a, 'bf', 0xe38a), # A-Z + (0x0061, 0x007a, 'bf', 0xe39d), # a-z + (0x0393, 0x0393, 'bf', 0x213e), # \Gamma + (0x03a0, 0x03a0, 'bf', 0x213f), # \Pi + (0x03a3, 0x03a3, 'bf', 0x2140), # \Sigma + (0x03b3, 0x03b3, 'bf', 0x213d), # \gamma + (0x03c0, 0x03c0, 'bf', 0x213c), # \pi + ], + }, + 'cal': + [ + (0x0041, 0x005a, 'it', 0xe22d), # A-Z + ], + 'circled': + { + 'rm': + [ + (0x0030, 0x0030, 'rm', 0x24ea), # 0 + (0x0031, 0x0039, 'rm', 0x2460), # 1-9 + (0x0041, 0x005a, 'rm', 0x24b6), # A-Z + (0x0061, 0x007a, 'rm', 0x24d0) # a-z + ], + 'it': + [ + (0x0030, 0x0030, 'it', 0x24ea), # 0 + (0x0031, 0x0039, 'it', 0x2460), # 1-9 + (0x0041, 0x005a, 'it', 0x24b6), # A-Z + (0x0061, 0x007a, 'it', 0x24d0) # a-z + ], + 'bf': + [ + (0x0030, 0x0030, 'bf', 0x24ea), # 0 + (0x0031, 0x0039, 'bf', 0x2460), # 1-9 + (0x0041, 0x005a, 'bf', 0x24b6), # A-Z + (0x0061, 0x007a, 'bf', 0x24d0) # a-z + ], + }, + 'frak': + { + 'rm': + [ + (0x0041, 0x0042, 'rm', 0x1d504), # A-B + (0x0043, 0x0043, 'rm', 0x212d), # C + (0x0044, 0x0047, 'rm', 0x1d507), # D-G + (0x0048, 0x0048, 'rm', 0x210c), # H + (0x0049, 0x0049, 'rm', 0x2111), # I + (0x004a, 0x0051, 'rm', 0x1d50d), # J-Q + (0x0052, 0x0052, 'rm', 0x211c), # R + (0x0053, 0x0059, 'rm', 0x1d516), # S-Y + (0x005a, 0x005a, 'rm', 0x2128), # Z + (0x0061, 0x007a, 'rm', 0x1d51e), # a-z + ], + 'it': + [ + (0x0041, 0x0042, 'rm', 0x1d504), # A-B + (0x0043, 0x0043, 'rm', 0x212d), # C + (0x0044, 0x0047, 'rm', 0x1d507), # D-G + (0x0048, 0x0048, 'rm', 0x210c), # H + (0x0049, 0x0049, 'rm', 0x2111), # I + (0x004a, 0x0051, 'rm', 0x1d50d), # J-Q + (0x0052, 0x0052, 'rm', 0x211c), # R + (0x0053, 0x0059, 'rm', 0x1d516), # S-Y + (0x005a, 0x005a, 'rm', 0x2128), # Z + (0x0061, 0x007a, 'rm', 0x1d51e), # a-z + ], + 'bf': + [ + (0x0041, 0x005a, 'bf', 0x1d56c), # A-Z + (0x0061, 0x007a, 'bf', 0x1d586), # a-z + ], + }, + 'scr': + [ + (0x0041, 0x0041, 'it', 0x1d49c), # A + (0x0042, 0x0042, 'it', 0x212c), # B + (0x0043, 0x0044, 'it', 0x1d49e), # C-D + (0x0045, 0x0046, 'it', 0x2130), # E-F + (0x0047, 0x0047, 'it', 0x1d4a2), # G + (0x0048, 0x0048, 'it', 0x210b), # H + (0x0049, 0x0049, 'it', 0x2110), # I + (0x004a, 0x004b, 'it', 0x1d4a5), # J-K + (0x004c, 0x004c, 'it', 0x2112), # L + (0x004d, 0x003d, 'it', 0x2113), # M + (0x004e, 0x0051, 'it', 0x1d4a9), # N-Q + (0x0052, 0x0052, 'it', 0x211b), # R + (0x0053, 0x005a, 'it', 0x1d4ae), # S-Z + (0x0061, 0x0064, 'it', 0x1d4b6), # a-d + (0x0065, 0x0065, 'it', 0x212f), # e + (0x0066, 0x0066, 'it', 0x1d4bb), # f + (0x0067, 0x0067, 'it', 0x210a), # g + (0x0068, 0x006e, 'it', 0x1d4bd), # h-n + (0x006f, 0x006f, 'it', 0x2134), # o + (0x0070, 0x007a, 'it', 0x1d4c5), # p-z + ], + 'sf': + { + 'rm': + [ + (0x0030, 0x0039, 'rm', 0x1d7e2), # 0-9 + (0x0041, 0x005a, 'rm', 0x1d5a0), # A-Z + (0x0061, 0x007a, 'rm', 0x1d5ba), # a-z + (0x0391, 0x03a9, 'rm', 0xe17d), # \Alpha-\Omega + (0x03b1, 0x03c9, 'rm', 0xe196), # \alpha-\omega + (0x03d1, 0x03d1, 'rm', 0xe1b0), # theta variant + (0x03d5, 0x03d5, 'rm', 0xe1b1), # phi variant + (0x03d6, 0x03d6, 'rm', 0xe1b3), # pi variant + (0x03f1, 0x03f1, 'rm', 0xe1b2), # rho variant + (0x03f5, 0x03f5, 'rm', 0xe1af), # lunate epsilon + (0x2202, 0x2202, 'rm', 0xe17c), # partial differential + ], + 'it': + [ + (0x0030, 0x0039, 'it', 0xe1b4), # 0-9 + (0x0041, 0x005a, 'it', 0x1d608), # A-Z + (0x0061, 0x007a, 'it', 0x1d622), # a-z + (0x0391, 0x03a9, 'it', 0xe1bf), # \Alpha-\Omega + (0x03b1, 0x03c9, 'it', 0xe1d8), # \alpha-\omega + (0x03d1, 0x03d1, 'it', 0xe1f2), # theta variant + (0x03d5, 0x03d5, 'it', 0xe1f3), # phi variant + (0x03d6, 0x03d6, 'it', 0xe1f5), # pi variant + (0x03f1, 0x03f1, 'it', 0xe1f4), # rho variant + (0x03f5, 0x03f5, 'it', 0xe1f1), # lunate epsilon + ], + 'bf': + [ + (0x0030, 0x0039, 'bf', 0x1d7ec), # 0-9 + (0x0041, 0x005a, 'bf', 0x1d5d4), # A-Z + (0x0061, 0x007a, 'bf', 0x1d5ee), # a-z + (0x0391, 0x03a9, 'bf', 0x1d756), # \Alpha-\Omega + (0x03b1, 0x03c9, 'bf', 0x1d770), # \alpha-\omega + (0x03d1, 0x03d1, 'bf', 0x1d78b), # theta variant + (0x03d5, 0x03d5, 'bf', 0x1d78d), # phi variant + (0x03d6, 0x03d6, 'bf', 0x1d78f), # pi variant + (0x03f0, 0x03f0, 'bf', 0x1d78c), # kappa variant + (0x03f1, 0x03f1, 'bf', 0x1d78e), # rho variant + (0x03f5, 0x03f5, 'bf', 0x1d78a), # lunate epsilon + (0x2202, 0x2202, 'bf', 0x1d789), # partial differential + (0x2207, 0x2207, 'bf', 0x1d76f), # \Nabla + ], + }, + 'tt': + [ + (0x0030, 0x0039, 'rm', 0x1d7f6), # 0-9 + (0x0041, 0x005a, 'rm', 0x1d670), # A-Z + (0x0061, 0x007a, 'rm', 0x1d68a) # a-z + ], + } + + Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -4827,7 +4827,7 @@ X = X.ravel() Y = Y.ravel() - coords = npy.zeros(((Nx * Ny), 2), npy.float32) + coords = npy.zeros(((Nx * Ny), 2), X.dtype) coords[:, 0] = X coords[:, 1] = Y @@ -4898,6 +4898,39 @@ return mtable.table(self, **kwargs) table.__doc__ = cbook.dedent(table.__doc__) % martist.kwdocd + def twinx(self): + """ + ax = twinx() + + create a twin of Axes for generating a plot with a sharex + x-axis but independent y axis. The y-axis of self will have + ticks on left and the returned axes will have ticks on the + right + """ + + ax2 = self.figure.add_axes(self.get_position(), sharex=self, frameon=False) + ax2.yaxis.tick_right() + ax2.yaxis.set_label_position('right') + self.yaxis.tick_left() + return ax2 + + def twiny(self): + """ + ax = twiny() + + create a twin of Axes for generating a plot with a shared + y-axis but independent x axis. The x-axis of self will have + ticks on bottom and the returned axes will have ticks on the + top + """ + + ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False) + ax2.xaxis.tick_top() + ax2.xaxis.set_label_position('top') + self.xaxis.tick_bottom() + return ax2 + + #### Data analysis Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -318,5 +318,5 @@ def print_png(self, filename, *args, **kwargs): FigureCanvasAgg.draw(self) - self.get_renderer()._renderer.write_png(str(filename), self.figure.dpi) + self.get_renderer()._renderer.write_png(filename, self.figure.dpi) Modified: branches/transforms/lib/matplotlib/backends/backend_gtk.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -365,11 +365,24 @@ pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width, height) - try: - pixbuf.save(filename, format) - except gobject.GError, exc: - error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self) - + if is_string_like(filename): + try: + pixbuf.save(filename, format) + except gobject.GError, exc: + error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self) + elif hasattr(filename, 'write') and callable(filename.write): + if hasattr(pixbuf, 'save_to_callback'): + def save_callback(buf, data=None): + data.write(buf) + try: + pixbuf.save_to_callback(save_callback, format, user_data=filename) + except gobject.GError, exc: + error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self) + else: + raise ValueError("Saving to a Python file-like object is only supported by PyGTK >= 2.8") + else: + raise ValueError("filename must be a path or a file-like object") + def get_default_filetype(self): return 'png' @@ -1019,7 +1032,7 @@ def get_filename_from_user (self): while True: filename = None - if self.run() != gtk.RESPONSE_OK: + if self.run() != int(gtk.RESPONSE_OK): break filename = self.get_filename() break @@ -1045,7 +1058,7 @@ self.set_filename(self.path) filename = None - if self.run() == gtk.RESPONSE_OK: + if self.run() == int(gtk.RESPONSE_OK): self.path = filename = self.get_filename() self.hide() Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -330,7 +330,15 @@ self.width, self.height = width, height self.nextObject = 1 # next free object id self.xrefTable = [ [0, 65535, 'the zero object'] ] - fh = file(filename, 'wb') + self.passed_in_file_object = False + if is_string_like(filename): + fh = file(filename, 'wb') + elif hasattr(filename, 'write') and callable(filename.write): + fh = filename + self.passed_in_file_object = True + else: + raise ValueError("filename must be a path or a file-like object") + self.fh = fh self.currentstream = None # stream object to write to, if any fh.write("%PDF-1.4\n") # 1.4 is the first version to have alpha @@ -427,7 +435,8 @@ self.writeMarkers() self.writeXref() self.writeTrailer() - self.fh.close() + if not self.passed_in_file_object: + self.fh.close() def write(self, data): if self.currentstream is None: Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -869,10 +869,16 @@ written into this file object. """ isEPSF = format == 'eps' - title = outfile - - # write to a temp file, we'll move it to outfile when done - tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest()) + passed_in_file_object = False + if is_string_like(outfile): + title = outfile + tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest()) + elif hasattr(outfile, 'write') and callable(outfile.write): + title = None + tmpfile = os.path.join(gettempdir(), md5.md5(str(hash(outfile))).hexdigest()) + passed_in_file_object = True + else: + raise ValueError("outfile must be a path or a file-like object") fh = file(tmpfile, 'w') # find the appropriate papertype @@ -990,10 +996,11 @@ elif rcParams['ps.usedistiller'] == 'xpdf': xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox) - if isinstance(outfile, file): + if passed_in_file_object: fh = file(tmpfile) print >>outfile, fh.read() - else: shutil.move(tmpfile, outfile) + else: + shutil.move(tmpfile, outfile) def _print_figure_tex(self, outfile, format, dpi, facecolor, edgecolor, orientation, isLandscape, papertype): Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -5,6 +5,7 @@ from matplotlib import verbose, __version__, rcParams from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase +from matplotlib.cbook import is_string_like from matplotlib.colors import rgb2hex from matplotlib.figure import Figure from matplotlib.font_manager import findfont, FontProperties @@ -258,7 +259,7 @@ im.write_png(filename) im.flipud_out() - imfile = file (filename, 'r') + imfile = file (filename, 'rb') image64 = base64.encodestring (imfile.read()) imfile.close() os.remove(filename) @@ -500,15 +501,27 @@ 'svgz': 'Scalable Vector Graphics'} def print_svg(self, filename, *args, **kwargs): - svgwriter = codecs.open(filename, 'w', 'utf-8') - return self._print_svg(filename, svgwriter) - + if is_string_like(filename): + fh_to_close = svgwriter = codecs.open(filename, 'w', 'utf-8') + elif hasattr(filename, 'write') and callable(filename.write): + svgwriter = codecs.EncodedFile(filename, 'utf-8') + fh_to_close = None + else: + raise ValueError("filename must be a path or a file-like object") + return self._print_svg(filename, svgwriter, fh_to_close) + def print_svgz(self, filename, *args, **kwargs): - gzipwriter = gzip.GzipFile(filename, 'w') - svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') - return self._print_svg(filename, svgwriter) + if is_string_like(filename): + gzipwriter = gzip.GzipFile(filename, 'w') + fh_to_close = svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + elif hasattr(filename, 'write') and callable(filename.write): + fh_to_close = gzipwriter = gzip.GzipFile(fileobj=filename, mode='w') + svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') + else: + raise ValueError("filename must be a path or a file-like object") + return self._print_svg(filename, svgwriter, fh_to_close) - def _print_svg(self, filename, svgwriter): + def _print_svg(self, filename, svgwriter, fh_to_close=None): self.figure.set_dpi(72.0) width, height = self.figure.get_size_inches() w, h = width*72, height*72 @@ -516,7 +529,8 @@ renderer = RendererSVG(w, h, svgwriter, filename) self.figure.draw(renderer) renderer.finish() - svgwriter.close() + if fh_to_close is not None: + svgwriter.close() def get_default_filetype(self): return 'svg' Modified: branches/transforms/lib/matplotlib/backends/backend_wx.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -152,7 +152,7 @@ cursors from matplotlib._pylab_helpers import Gcf from matplotlib.artist import Artist -from matplotlib.cbook import exception_to_str +from matplotlib.cbook import exception_to_str, is_string_like from matplotlib.figure import Figure from matplotlib.path import Path from matplotlib.text import _process_text_args, Text @@ -969,12 +969,17 @@ # Now that we have rendered into the bitmap, save it # to the appropriate file type and clean up - if not self.bitmap.SaveFile(filename, filetype): - DEBUG_MSG('print_figure() file save error', 4, self) - # note the error must be displayed here because trapping - # the error on a call or print_figure may not work because - # printing can be qued and called from realize - raise RuntimeError('Could not save figure to %s\n' % (filename)) + if is_string_like(filename): + if not self.bitmap.SaveFile(filename, filetype): + DEBUG_MSG('print_figure() file save error', 4, self) + # note the error must be displayed here because trapping + # the error on a call or print_figure may not work because + # printing can be qued and called from realize + raise RuntimeError('Could not save figure to %s\n' % (filename)) + elif hasattr(filename, 'write') and callable(filename.write): + if not self.bitmap.ConvertToImage().SaveStream(filename, filetype): + DEBUG_MSG('print_figure() file save error', 4, self) + raise RuntimeError('Could not save figure to %s\n' % (filename)) # Restore everything to normal self.bitmap = origBitmap Modified: branches/transforms/lib/matplotlib/config/mplconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -65,7 +65,7 @@ class backend(TConfig): """Valid backends are: 'GTKAgg', 'GTKCairo', 'QtAgg', 'Qt4Agg', 'TkAgg', 'Agg', 'Cairo', 'PS', 'PDF', 'SVG'""" - use = T.Trait('TkAgg', mplT.BackendHandler()) + use = T.Trait('Agg', mplT.BackendHandler()) class cairo(TConfig): format = T.Trait('png', 'png', 'ps', 'pdf', 'svg') @@ -166,7 +166,7 @@ it = T.Trait('serif:oblique' , mplT.FontconfigPatternHandler()) bf = T.Trait('serif:bold' , mplT.FontconfigPatternHandler()) sf = T.Trait('sans' , mplT.FontconfigPatternHandler()) - fontset = T.Trait('cm', 'cm', 'stix', 'custom') + fontset = T.Trait('cm', 'cm', 'stix', 'stixsans', 'custom') fallback_to_cm = T.true class axes(TConfig): @@ -525,5 +525,5 @@ ############################################################################## if __name__ == "__main__": mplConfig = MPLConfig() - tconf2File(mplConfig, '../mpl-data/matplotlib.conf', force=True) - print 'Default matplotlib.conf created in ../mpl-data' + tconf2File(mplConfig, '../mpl-data/matplotlib.conf.template', force=True) + print 'matplotlib.conf.template created in ../mpl-data' Modified: branches/transforms/lib/matplotlib/config/rcsetup.py =================================================================== --- branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/config/rcsetup.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -203,7 +203,7 @@ parse_fontconfig_pattern(s) return s -validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'custom']) +validate_fontset = ValidateInStrings('fontset', ['cm', 'stix', 'stixsans', 'custom']) validate_verbose = ValidateInStrings('verbose',[ 'silent', 'helpful', 'debug', 'debug-annoying', Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-11-13 15:15:36 UTC (rev 4243) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-11-13 15:22:55 UTC (rev 4244) @@ -144,8 +144,7 @@ from matplotlib.ft2font import FT2Font, FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING from matplotlib.font_manager import findfont, FontProperties from matplotlib._mathtext_data import latex_to_bakoma, \ - latex_to_standard, tex2uni, tex2type1, uni2type1, \ - latex_to_cmex + latex_to_standard, tex2uni, latex_to_cmex, stix_virtual_fonts from matplotlib import get_data_path, rcParams #################### @@ -182,29 +181,6 @@ raise ValueError, message -#Not used, but might turn useful -def get_type1_name(symbol): - """get_type1_name(symbol) -> string - -Returns the the Type1 name of symbol. -symbol can be a single unicode character, or a TeX command (i.e. r'\pi'). - -""" - try:# This will succeed if symbol is a single unicode char - return uni2type1[ord(symbol)] - except TypeError: - pass - try:# Is symbol a TeX symbol (i.e. \alpha) - return tex2type1[symbol.strip("\\")] - except KeyError: - pass - # The symbol is already a Type1 name so return it - if isinstance(symbol, str): - return symbol - else: - # The user did not suply a valid symbol, show usage - raise ValueError, get_type1_name.__doc__ - class MathtextBackend(object): def __init__(self): self.fonts_object = None @@ -468,7 +444,7 @@ """ return 0. - def get_metrics(self, font, sym, fontsize, dpi): + def get_metrics(self, font, font_class, sym, fontsize, dpi): """ font: one of the TeX font names, tt, it, rm, cal, sf, bf or default (non-math) @@ -483,7 +459,7 @@ iceberg - the distance from the baseline to the top of the glyph. horiBearingY in Truetype parlance, height in TeX parlance """ - info = self._get_info(font, sym, fontsize, dpi) + info = self._get_info(font, font_class, sym, fontsize, dpi) return info.metrics def set_canvas_size(self, w, h, d): @@ -491,8 +467,8 @@ self.width, self.height, self.depth = ceil(w), ceil(h), ceil(d) self.mathtext_backend.set_canvas_size(self.width, self.height, self.depth) - def render_glyph(self, ox, oy, facename, sym, fontsize, dpi): - info = self._get_info(facename, sym, fontsize, dpi) + def render_glyph(self, ox, oy, facename, font_class, sym, fontsize, dpi): + info = self._get_info(facename, font_class, sym, fontsize, dpi) realpath, stat_key = get_realpath_and_stat(info.font.fname) used_characters = self.used_characters.setdefault( stat_key, (realpath, Set())) @@ -566,7 +542,10 @@ cached_font = self.fonts.get(basename) if cached_font is None: - font = FT2Font(basename) + try: + font = FT2Font(basename) + except RuntimeError: + return None cached_font = self.CachedFont(font) self.fonts[basename] = cached_font self.fonts[font.postscript_name] = cached_font @@ -578,15 +557,15 @@ return glyph.height/64.0/2.0 + 256.0/64.0 * dpi/72.0 return 0. - def _get_info (self, fontname, sym, fontsize, dpi, mark_as_used=True): + def _get_info(self, fontname, font_class, sym, fontsize, dpi): 'load the cmfont, metrics and glyph with caching' - key = fontname, sym, fontsize, dpi + key = fontname, font_class, sym, fontsize, dpi bunch = self.glyphd.get(key) if bunch is not None: return bunch cached_font, num, symbol_name, fontsize, slanted = \ - self._get_glyph(fontname, sym, fontsize) + self._get_glyph(fontname, font_class, sym, fontsize) font = cached_font.font font.set_size(fontsize, dpi) @@ -627,7 +606,7 @@ pclt = cached_font.font.get_sfnt_table('pclt') if pclt is None: # Some fonts don't store the xHeight, so we do a poor man's xHeight - metrics = self.get_metrics(font, 'x', fontsize, dpi) + metrics = self.get_metrics(font, 'it', 'x', fontsize, dpi) return metrics.iceberg xHeight = pclt['xHeight'] / 64.0 return xHeight @@ -636,11 +615,11 @@ cached_font = self._get_font(font) return max(1.0, cached_font.font.underline_thickness / 64.0 / fontsize * 10.0) - def get_kern(self, font1, sym1, fontsize1, - font2, sym2, fontsize2, dpi): + def get_kern(self, font1, fontclass1, sym1, fontsize1, + font2, fontclass2, sym2, fontsize2, dpi): if font1 == font2 and fontsize1 == fontsize2: - info1 = self._get_info(font1, sym1, fontsize1, dpi) - info2 = self._get_info(font2, sym2, fontsize2, dpi) + info1 = self._get_info(font1, fontclass1, sym1, fontsize1, dpi) + info2 = self._get_info(font2, fontclass2, sym2, fontsize2, dpi) font = info1.font return font.get_kerning(info1.num, info2.num, KERNING_DEFAULT) / 64.0 return 0.0 @@ -669,7 +648,7 @@ _slanted_symbols = Set(r"\int \oint".split()) - def _get_glyph(self, fontname, sym, fontsize): + def _get_glyph(self, fontname, font_class, sym, fontsize): symbol_name = None if fontname in self.fontmap and latex_to_bakoma.has_key(sym): basename, num = latex_to_bakoma[sym] @@ -680,11 +659,12 @@ elif len(sym) == 1: slanted = (fontname == "it") cached_font = self._get_font(fontname) - num = ord(sym) - gid = cached_font.charmap.get(num) - if gid is not None: - symbol_name = cached_font.font.get_glyph_name( - cached_font.charmap[num]) + if cached_font is not None: + num = ord(sym) + gid = cached_font.charmap.get(num) + if gid is not None: + symbol_name = cached_font.font.get_glyph_name( + cached_font.charmap[num]) if symbol_name is None: warn("Unrecognized symbol '%s'. Substituting with a dummy symbol." @@ -778,8 +758,11 @@ self.fontmap['ex'] = font _slanted_symbols = Set(r"\int \oint".split()) - - def _get_glyph(self, fontname, sym, fontsize): + + def _map_virtual_font(self, fontname, font_class, uniindex): + return fontname, uniindex + + def _get_glyph(self, fontname, font_class, sym, fontsize): found_symbol = False if self.use_cmex: @@ -798,6 +781,9 @@ sym.encode('ascii', 'backslashreplace'), MathTextWarning) + fontname, uniindex = self._map_virtual_font( + fontname, font_class, uniindex) + # Only characters in the "Letter" class should be italicized in 'it' # mode. Greek capital letters should be Roman. if found_symbol: @@ -805,26 +791,29 @@ if fontname == 'it': unistring = unichr(uniindex) - if (not unicodedata.category(unistring).startswith("L") + if (not unicodedata.category(unistring)[0] == "L" or unicodedata.name(unistring).startswith("GREEK CAPITAL")): new_fontname = 'rm' slanted = (new_fontname == 'it') or sym in self._slanted_symbols cached_font = self._get_font(new_fontname) - try: - glyphindex = cached_font.charmap[uniindex] - except KeyError: - warn("Font '%s' does not have a glyph for '%s'" % - (cached_font.font.postscript_name, - sym.encode('ascii', 'backslashreplace')), - MathTextWarning) - found_symbol = False + found_symbol = False + if cached_font is not None: + try: + glyphindex = cached_font.charmap[uniindex] + found_symbol = True + except KeyError: + warn("Font '%s' does not have a glyph for '%s'" % + (cached_font.font.postscript_name, + sym.encode('ascii', 'backslashreplace')), + MathTextWarning) if not found_symbol: if self.cm_fallback: warn("Substituting with a symbol from Computer Modern.", MathTextWarning) - return self.cm_fallback._get_glyph(fontname, sym, fontsize) + return self.cm_fallback._get_glyph( + fontname, 'it', sym, fontsize) else: warn("Substituting with a dummy symbol.", MathTextWarning) fontname = 'rm' @@ -845,10 +834,8 @@ class StixFonts(UnicodeFonts): _fontmap = { 'rm' : 'STIXGeneral', - 'tt' : 'VeraMono', 'it' : 'STIXGeneralItalic', 'bf' : 'STIXGeneralBol', - 'sf' : 'Vera', 'nonunirm' : 'STIXNonUni', 'nonuniit' : 'STIXNonUniIta', 'nonunibf' : 'STIXNonUniBol', @@ -865,6 +852,7 @@ cm_fallback = False def __init__(self, *args, **kwargs): + self._sans = kwargs.pop("sans", False) TruetypeFonts.__init__(self, *args, **kwargs) if not len(self.fontmap): for key, name in self._fontmap.iteritems(): @@ -872,20 +860,47 @@ self.fontmap[key] = fullpath self.fontmap[name] = fullpath - def _get_glyph(self, fontname, sym, fontsize): - # Handle calligraphic letters - if fontname == 'cal': - if len(sym) != 1 or ord(sym) < ord('A') or ord(sym) > ord('Z'): - raise ValueError(r"Sym '%s' is not available in \mathcal font" % sym) - fontname = 'nonuniit' - sym = unichr(ord(sym) + 0xe22d - ord('A')) + def _map_virtual_font(self, fontname, font_class, uniindex): + # Handle these "fonts" that are actually embedded in + # other fonts. + mapping = stix_virtual_fonts.get(fontname) + if self._sans and mapping is None: + mapping = stix_virtual_fonts['sf'] + doing_sans_conversion = True + else: + doing_sans_conversion = False + if mapping is not None: + if isinstance(mapping, dict): + mapping = mapping[font_class] + + # Binary search for the source glyph + lo = 0 + hi = len(mapping) + while lo < hi: + mid = (lo+hi)//2 + range = mapping[mid] + if uniindex < range[0]: + hi = mid + elif uniindex <= range[1]: + break + else: + lo = mid + 1 + + if uniindex >= range[0] and uniindex <= range[1]: + uniindex = uniindex - range[0] + range[3] + fontname = range[2] + elif not doing_sans_conversion: + # This will generate a dummy character + uniindex = 0x1 + fontname = 'it' + # Handle private use area glyphs if (fontname in ('it', 'rm', 'bf') and - len(sym) == 1 and ord(sym) >= 0xe000 and ord(sym) <= 0xf8ff): + uniindex >= 0xe000 and uniindex <= 0xf8ff): fontname = 'nonuni' + fontname - return UnicodeFonts._get_glyph(self, fontname, sym, fontsize) + return fontname, uniindex _size_alternatives = {} def get_sized_alternatives_for_symbol(self, fontname, sym): @@ -953,7 +968,7 @@ self.fonts[cached_font.get_fontname()] = cached_font return cached_font - def _get_info (self, fontname, sym, fontsize, dpi): + def _get_info (self, fontname, font_class, sym, f... [truncated message content] |
From: <md...@us...> - 2007-11-13 16:02:53
|
Revision: 4245 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4245&view=rev Author: mdboom Date: 2007-11-13 08:02:47 -0800 (Tue, 13 Nov 2007) Log Message: ----------- Bug fixes. Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-13 15:22:55 UTC (rev 4244) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-13 16:02:47 UTC (rev 4245) @@ -4504,7 +4504,7 @@ if norm is not None: assert(isinstance(norm, mcolors.Normalize)) if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) if aspect is None: aspect = rcParams['image.aspect'] - # self.set_aspect(aspect) + self.set_aspect(aspect) if X is None and Y is None: im = mimage.AxesImage(self, cmap, norm, interpolation, origin, extent, Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-13 15:22:55 UTC (rev 4244) +++ branches/transforms/src/_backend_agg.cpp 2007-11-13 16:02:47 UTC (rev 4245) @@ -282,7 +282,7 @@ double l, b, r, t; if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) { - rasterizer->clip_box((int)l + 1, (int)b + 1, (int)r + 1, (int)t + 1); + rasterizer->clip_box((int)l + 1, height - (int)(b + 1), (int)r + 1, height - (int)(t + 1)); } _VERBOSE("RendererAgg::set_clipbox done"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-14 18:44:56
|
Revision: 4286 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4286&view=rev Author: mdboom Date: 2007-11-14 10:44:39 -0800 (Wed, 14 Nov 2007) Log Message: ----------- New path-related utilities (used for an aborted attempt at fixing contouring -- may be useful in other contexts in the future). Modified Paths: -------------- branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/path.py branches/transforms/src/_path.cpp Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-11-14 18:43:35 UTC (rev 4285) +++ branches/transforms/lib/matplotlib/patches.py 2007-11-14 18:44:39 UTC (rev 4286) @@ -152,7 +152,7 @@ ACCEPTS: any matplotlib color """ self._facecolor = color - + def set_linewidth(self, w): """ Set the patch linewidth in points @@ -522,6 +522,28 @@ def get_patch_transform(self): return self._poly_transform +class PathPatch(Patch): + """ + A general polycurve path patch. + """ + def __str__(self): + return "Poly((%g, %g) ...)" % tuple(self._path.vertices[0]) + + def __init__(self, path, **kwargs): + """ + path is a Path object + + Valid kwargs are: + %(Patch)s + See Patch documentation for additional kwargs + """ + Patch.__init__(self, **kwargs) + self._path = path + __init__.__doc__ = cbook.dedent(__init__.__doc__) % artist.kwdocd + + def get_path(self): + return self._path + class Polygon(Patch): """ A general polygon patch. @@ -549,7 +571,7 @@ def _set_xy(self, vertices): self._path = Path(vertices) xy = property(_get_xy, _set_xy) - + class Wedge(Patch): def __str__(self): return "Wedge(%g,%g)"%self.xy[0] Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-14 18:43:35 UTC (rev 4285) +++ branches/transforms/lib/matplotlib/path.py 2007-11-14 18:44:39 UTC (rev 4286) @@ -11,8 +11,8 @@ from matplotlib.numerix import npyma as ma from matplotlib._path import point_in_path, get_path_extents, \ - point_in_path_collection -import matplotlib._path as _path + point_in_path_collection, get_path_collection_extents, \ + path_in_path from matplotlib.cbook import simple_linear_interpolation KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0 @@ -128,6 +128,30 @@ self.codes = codes self.vertices = vertices + #@staticmethod + def make_compound_path(*args): + """ + Make a compound path from a list of Path objects. Only + polygons (not curves) are supported. + """ + for p in args: + assert p.codes is None + + lengths = [len(x) for x in args] + total_length = sum(lengths) + + vertices = npy.vstack([x.vertices for x in args]) + vertices.reshape((total_length, 2)) + + codes = Path.LINETO * npy.ones(total_length) + i = 0 + for length in lengths: + codes[i] = Path.MOVETO + i += length + + return Path(vertices, codes) + make_compound_path = staticmethod(make_compound_path) + def __repr__(self): return "Path(%s, %s)" % (self.vertices, self.codes) @@ -186,9 +210,18 @@ """ if transform is None: from transforms import IdentityTransform - transform = IdentityTransform + transform = IdentityTransform() return point_in_path(point[0], point[1], self, transform.frozen()) + def contains_path(self, path, transform=None): + """ + Returns True if this path completely contains the given path. + """ + if transform is None: + from transforms import IdentityTransform + transform = IdentityTransform() + return path_in_path(self, IdentityTransform(), path, transform) + def get_extents(self, transform=None): """ Returns the extents (xmin, ymin, xmax, ymax) of the path. @@ -408,8 +441,9 @@ return cls.arc(theta1, theta2, True) wedge = classmethod(wedge) +_get_path_collection_extents = get_path_collection_extents 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)) + return Bbox.from_extents(*_get_path_collection_extents(*args)) Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-11-14 18:43:35 UTC (rev 4285) +++ branches/transforms/src/_path.cpp 2007-11-14 18:44:39 UTC (rev 4286) @@ -9,6 +9,8 @@ #include "agg_path_storage.h" #include "agg_trans_affine.h" +// MGDTODO: Un-CXX-ify this module + // the extension module class _path_module : public Py::ExtensionModule<_path_module> { @@ -26,6 +28,10 @@ "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)"); + add_varargs_method("path_in_path", &_path_module::path_in_path, + "point_in_path_collection(a, atrans, b, btrans)"); + add_varargs_method("clip_path_to_rect", &_path_module::clip_path_to_rect, + "clip_path_to_rect(path, bbox, inside)"); initialize("Helper functions for paths"); } @@ -39,6 +45,8 @@ 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); + Py::Object path_in_path(const Py::Tuple& args); + Py::Object clip_path_to_rect(const Py::Tuple& args); }; // @@ -85,11 +93,14 @@ double x, y; path.rewind(0); - unsigned code = path.vertex(&x, &y); - if (code == agg::path_cmd_stop) - return false; + inside_flag = 0; + + unsigned code = 0; while (true) { + if (code != agg::path_cmd_move_to) + code = path.vertex(&x, &y); + sx = vtx0 = x; sy = vty0 = y; @@ -104,11 +115,11 @@ 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) { + if (code == agg::path_cmd_stop || (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. @@ -146,26 +157,37 @@ break; } + yflag1 = (vty1 >= ty); + if (yflag0 != yflag1) { + if ( ((vty1-ty) * (vtx0-vtx1) >= + (vtx1-tx) * (vty0-vty1)) == yflag1 ) { + inside_flag ^= 1; + } + } + if (inside_flag != 0) return true; if (code == agg::path_cmd_stop) - return false; + break; } - return false; + return (inside_flag != 0); } -bool point_in_path(double x, double y, PathIterator& path, agg::trans_affine& trans) { +inline bool point_in_path(double x, double y, PathIterator& path, const agg::trans_affine& trans) { typedef agg::conv_transform<PathIterator> transformed_path_t; typedef agg::conv_curve<transformed_path_t> curve_t; + if (path.total_vertices() < 3) + return false; + 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) { +inline bool point_on_path(double x, double y, double r, PathIterator& path, const 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; @@ -204,7 +226,7 @@ return Py::Int(0); } -void get_path_extents(PathIterator& path, agg::trans_affine& trans, +void get_path_extents(PathIterator& path, const 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; @@ -393,6 +415,248 @@ return result; } +bool path_in_path(PathIterator& a, const agg::trans_affine& atrans, + PathIterator& b, const agg::trans_affine& btrans) { + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef agg::conv_curve<transformed_path_t> curve_t; + + if (a.total_vertices() < 3) + return false; + + transformed_path_t b_path_trans(b, btrans); + curve_t b_curved(b_path_trans); + + double x, y; + b_curved.rewind(0); + while (b_curved.vertex(&x, &y) != agg::path_cmd_stop) { + if (!::point_in_path(x, y, a, atrans)) + return false; + } + + return true; +} + +Py::Object _path_module::path_in_path(const Py::Tuple& args) { + args.verify_length(4); + + PathIterator a(args[0]); + agg::trans_affine atrans = py_to_agg_transformation_matrix(args[1]); + PathIterator b(args[2]); + agg::trans_affine btrans = py_to_agg_transformation_matrix(args[3]); + + return Py::Int(::path_in_path(a, atrans, b, btrans)); +} + +/** The clip_path_to_rect code here is a clean-room implementation of the + Sutherland-Hodgman clipping algorithm described here: + + http://en.wikipedia.org/wiki/Sutherland-Hodgman_clipping_algorithm +*/ + +typedef std::vector<std::pair<double, double> > Polygon; + +namespace clip_to_rect_filters { + /* There are four different passes needed to create/remove vertices + (one for each side of the rectangle). The differences between those + passes are encapsulated in these functor classes. + */ + struct bisectx { + double m_x; + + bisectx(double x) : m_x(x) {} + + void bisect(double sx, double sy, double px, double py, double* bx, double* by) const { + *bx = m_x; + double dx = px - sx; + double dy = py - sy; + *by = sy + dy * ((m_x - sx) / dx); + } + }; + + struct xlt : public bisectx { + xlt(double x) : bisectx(x) {} + + bool operator()(double x, double y) const { + return x <= m_x; + } + }; + + struct xgt : public bisectx { + xgt(double x) : bisectx(x) {} + + bool operator()(double x, double y) const { + return x >= m_x; + } + }; + + struct bisecty { + double m_y; + + bisecty(double y) : m_y(y) {} + + void bisect(double sx, double sy, double px, double py, double* bx, double* by) const { + *by = m_y; + double dx = px - sx; + double dy = py - sy; + *bx = sx + dx * ((m_y - sy) / dy); + } + }; + + struct ylt : public bisecty { + ylt(double y) : bisecty(y) {} + + bool operator()(double x, double y) const { + return y <= m_y; + } + }; + + struct ygt : public bisecty { + ygt(double y) : bisecty(y) {} + + bool operator()(double x, double y) const { + return y >= m_y; + } + }; +} + +template<class Filter> +void clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter) { + double sx, sy, px, py, bx, by; + bool sinside, pinside; + result.clear(); + + if (polygon.size() == 0) + return; + + sx = polygon.back().first; + sy = polygon.back().second; + for (Polygon::const_iterator i = polygon.begin(); i != polygon.end(); ++i) { + px = i->first; + py = i->second; + + sinside = filter(sx, sy); + pinside = filter(px, py); + + if (sinside) { + if (pinside) { + result.push_back(std::make_pair(px, py)); + } else { + filter.bisect(sx, sy, px, py, &bx, &by); + result.push_back(std::make_pair(bx, by)); + } + } else { + if (pinside) { + filter.bisect(sx, sy, px, py, &bx, &by); + result.push_back(std::make_pair(bx, by)); + result.push_back(std::make_pair(px, py)); + } + } + + sx = px; sy = py; + } +} + +void clip_to_rect(PathIterator& path, + double x0, double y0, double x1, double y1, + bool inside, std::vector<Polygon>& results) { + double xmin, ymin, xmax, ymax; + if (x0 < x1) { + xmin = x0; xmax = x1; + } else { + xmin = x1; xmax = x0; + } + + if (y0 < y1) { + ymin = y0; ymax = y1; + } else { + ymin = y1; ymax = y0; + } + + if (!inside) { + std::swap(xmin, xmax); + std::swap(ymin, ymax); + } + + Polygon polygon1, polygon2; + double x, y; + unsigned code = 0; + path.rewind(0); + + while (true) { + polygon1.clear(); + while (true) { + if (code == agg::path_cmd_move_to) + polygon1.push_back(std::make_pair(x, y)); + + code = path.vertex(&x, &y); + + if (code == agg::path_cmd_stop) + break; + + if (code != agg::path_cmd_move_to) + polygon1.push_back(std::make_pair(x, y)); + + if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { + break; + } else if (code == agg::path_cmd_move_to) { + break; + } + } + + // The result of each step is fed into the next (note the + // swapping of polygon1 and polygon2 at each step). + clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::xlt(xmax)); + clip_to_rect_one_step(polygon2, polygon1, clip_to_rect_filters::xgt(xmin)); + clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::ylt(ymax)); + clip_to_rect_one_step(polygon2, polygon1, clip_to_rect_filters::ygt(ymin)); + + if (polygon1.size()) + results.push_back(polygon1); + + if (code == agg::path_cmd_stop) + break; + } +} + +Py::Object _path_module::clip_path_to_rect(const Py::Tuple &args) { + args.verify_length(3); + + PathIterator path(args[0]); + Py::Object bbox_obj = args[1]; + bool inside = Py::Int(args[2]); + + double x0, y0, x1, y1; + if (!py_convert_bbox(bbox_obj.ptr(), x0, y0, x1, y1)) + throw Py::TypeError("Argument 2 to clip_to_rect must be a Bbox object."); + + std::vector<Polygon> results; + + ::clip_to_rect(path, x0, y0, x1, y1, inside, results); + + // MGDTODO: Not exception safe + int dims[2]; + dims[1] = 2; + PyObject* py_results = PyList_New(results.size()); + for (std::vector<Polygon>::const_iterator p = results.begin(); p != results.end(); ++p) { + size_t size = p->size(); + dims[0] = p->size(); + PyArrayObject* pyarray = (PyArrayObject*)PyArray_FromDims(2, dims, PyArray_DOUBLE); + for (size_t i = 0; i < size; ++i) { + ((double *)pyarray->data)[2*i] = (*p)[i].first; + ((double *)pyarray->data)[2*i+1] = (*p)[i].second; + } + // MGDTODO: Error check + PyList_SetItem(py_results, p - results.begin(), (PyObject *)pyarray); + } + + return Py::Object(py_results, true); +} + +struct XY { + double x; + double y; +}; + extern "C" DL_EXPORT(void) init_path(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-14 19:46:39
|
Revision: 4292 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4292&view=rev Author: mdboom Date: 2007-11-14 11:46:37 -0800 (Wed, 14 Nov 2007) Log Message: ----------- Merged revisions 4244-4289 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4248 | dsdale | 2007-11-13 11:39:12 -0500 (Tue, 13 Nov 2007) | 2 lines modify formatting of comments in matplotlib.conf ........ r4249 | dsdale | 2007-11-13 13:10:32 -0500 (Tue, 13 Nov 2007) | 2 lines fixed some formatting issues in tconfig ........ r4264 | efiring | 2007-11-14 02:45:12 -0500 (Wed, 14 Nov 2007) | 2 lines A step towards a fast rectilinear pcolor version ........ r4267 | mdboom | 2007-11-14 08:58:08 -0500 (Wed, 14 Nov 2007) | 3 lines Fix bug when clicking "Cancel" in the save dialog in TkAgg backend. (Thanks Michael Zell). ........ r4268 | mdboom | 2007-11-14 09:00:56 -0500 (Wed, 14 Nov 2007) | 2 lines Fix bug in specgram. (Thanks Glen W. Mabey!) ........ r4275 | jdh2358 | 2007-11-14 11:39:47 -0500 (Wed, 14 Nov 2007) | 2 lines added glen's Fc specteal patch ........ r4278 | efiring | 2007-11-14 13:10:00 -0500 (Wed, 14 Nov 2007) | 2 lines Use mpl standard import idiom in image.py ........ r4287 | mdboom | 2007-11-14 14:06:52 -0500 (Wed, 14 Nov 2007) | 2 lines Fix placement of rotated text in Wx backend (thanks Michael Day). ........ r4288 | jdh2358 | 2007-11-14 14:11:54 -0500 (Wed, 14 Nov 2007) | 2 lines fixed is_string_like and removed is_file_like ........ r4289 | mdboom | 2007-11-14 14:25:46 -0500 (Wed, 14 Nov 2007) | 2 lines Refactored a bunch of places to use "is_writable_file_like". ........ Modified Paths: -------------- branches/transforms/API_CHANGES branches/transforms/lib/matplotlib/__init__.py branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/backends/backend_gtk.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_tkagg.py branches/transforms/lib/matplotlib/backends/backend_wx.py branches/transforms/lib/matplotlib/cbook.py branches/transforms/lib/matplotlib/cm.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/colorbar.py branches/transforms/lib/matplotlib/config/matplotlib.conf.default branches/transforms/lib/matplotlib/config/mplconfig.py branches/transforms/lib/matplotlib/config/mpltraits.py branches/transforms/lib/matplotlib/config/tconfig.py branches/transforms/lib/matplotlib/image.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.template branches/transforms/lib/matplotlib/numerix/__init__.py branches/transforms/lib/matplotlib/pylab.py branches/transforms/setup.py branches/transforms/src/_image.cpp branches/transforms/src/_image.h Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4243 + /trunk/matplotlib:1-4289 Modified: branches/transforms/API_CHANGES =================================================================== --- branches/transforms/API_CHANGES 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/API_CHANGES 2007-11-14 19:46:37 UTC (rev 4292) @@ -169,6 +169,9 @@ END OF TRANSFORMS REFACTORING + Changed cbook.is_file_like to cbook.is_writable_file_like and + corrected behavior. + Moved mlab.csv2rec -> recutils.csv2rec Added ax kwarg to pyplot.colorbar and Figure.colorbar so that Modified: branches/transforms/lib/matplotlib/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/__init__.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/__init__.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -118,8 +118,7 @@ def is_string_like(obj): - if hasattr(obj, 'shape'): return 0 # this is a workaround - # for a bug in numeric<23.1 + if hasattr(obj, 'shape'): return 0 try: obj + '' except (TypeError, ValueError): return 0 return 1 Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -4413,7 +4413,7 @@ origin=None, extent=None) IMSHOW(I) - plot image I to current axes, resampling to scale to axes - size (I may be numarray/Numeric array or PIL image) + size (I may be numpy array or PIL image) IMSHOW(I, X, Y) - plot image I to current axes, with nonuniform X and Y axes. (I, X and Y may be @@ -4988,10 +4988,10 @@ return n, bins, cbook.silent_list('Patch', patches) hist.__doc__ = cbook.dedent(hist.__doc__) % martist.kwdocd - def psd(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none, + def psd(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, **kwargs): """ - PSD(x, NFFT=256, Fs=2, detrend=mlab.detrend_none, + PSD(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, **kwargs) The power spectral density by Welches average periodogram method. The @@ -5002,22 +5002,27 @@ with a scaling to correct for power loss due to windowing. Fs is the sampling frequency. - NFFT is the length of the fft segment; must be a power of 2 + * NFFT is the length of the fft segment; must be a power of 2 - Fs is the sampling frequency. + * Fs is the sampling frequency. - detrend - the function applied to each segment before fft-ing, + * Fc is the center frequency of x (defaults to 0), which offsets + the yextents of the image to reflect the frequency range used + when a signal is acquired and then filtered and downsampled to + baseband. + + * detrend - the function applied to each segment before fft-ing, designed to remove the mean or linear trend. Unlike in matlab, where the detrend parameter is a vector, in matplotlib is it a function. The mlab module defines detrend_none, detrend_mean, detrend_linear, but you can use a custom function as well. - window - the function used to window the segments. window is a + * window - the function used to window the segments. window is a function, unlike in matlab(TM) where it is a vector. mlab defines window_none, window_hanning, but you can use a custom function as well. - noverlap gives the length of the overlap between segments. + * noverlap gives the length of the overlap between segments. Returns the tuple Pxx, freqs @@ -5035,6 +5040,7 @@ if not self._hold: self.cla() pxx, freqs = mlab.psd(x, NFFT, Fs, detrend, window, noverlap) pxx.shape = len(freqs), + freqs += Fc self.plot(freqs, 10*npy.log10(pxx), **kwargs) self.set_xlabel('Frequency') @@ -5052,10 +5058,10 @@ return pxx, freqs psd.__doc__ = cbook.dedent(psd.__doc__) % martist.kwdocd - def csd(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none, + def csd(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, **kwargs): """ - CSD(x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none, + CSD(x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=window_hanning, noverlap=0, **kwargs) The cross spectral density Pxy by Welches average periodogram method. @@ -5081,6 +5087,7 @@ pxy, freqs = mlab.csd(x, y, NFFT, Fs, detrend, window, noverlap) pxy.shape = len(freqs), # pxy is complex + freqs += Fc self.plot(freqs, 10*npy.log10(npy.absolute(pxy)), **kwargs) self.set_xlabel('Frequency') @@ -5097,11 +5104,10 @@ return pxy, freqs csd.__doc__ = cbook.dedent(csd.__doc__) % martist.kwdocd - def cohere(self, x, y, NFFT=256, Fs=2, detrend=mlab.detrend_none, + def cohere(self, x, y, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=0, **kwargs): """ - COHERE(x, y, NFFT=256, Fs=2, - detrend = mlab.detrend_none, + COHERE(x, y, NFFT=256, Fs=2, Fc=0, detrend = mlab.detrend_none, window = mlab.window_hanning, noverlap=0, **kwargs) cohere the coherence between x and y. Coherence is the normalized @@ -5126,6 +5132,7 @@ """ if not self._hold: self.cla() cxy, freqs = mlab.cohere(x, y, NFFT, Fs, detrend, window, noverlap) + freqs += Fc self.plot(freqs, cxy, **kwargs) self.set_xlabel('Frequency') @@ -5135,11 +5142,11 @@ return cxy, freqs cohere.__doc__ = cbook.dedent(cohere.__doc__) % martist.kwdocd - def specgram(self, x, NFFT=256, Fs=2, detrend=mlab.detrend_none, + def specgram(self, x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window=mlab.window_hanning, noverlap=128, cmap = None, xextent=None): """ - SPECGRAM(x, NFFT=256, Fs=2, detrend=mlab.detrend_none, + SPECGRAM(x, NFFT=256, Fs=2, Fc=0, detrend=mlab.detrend_none, window = mlab.window_hanning, noverlap=128, cmap=None, xextent=None) @@ -5181,7 +5188,8 @@ if xextent is None: xextent = 0, npy.amax(bins) xmin, xmax = xextent - extent = xmin, xmax, npy.amin(freqs), npy.amax(freqs) + freqs += Fc + extent = xmin, xmax, freqs[0], freqs[-1] im = self.imshow(Z, cmap, extent=extent) self.axis('auto') Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -19,8 +19,6 @@ * allow save to file handle * integrate screen dpi w/ ppi and text - -INSTALLING """ from __future__ import division import os, sys, weakref Modified: branches/transforms/lib/matplotlib/backends/backend_gtk.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_gtk.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -19,7 +19,7 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK -from matplotlib.cbook import is_string_like, enumerate +from matplotlib.cbook import is_string_like, is_writable_file_like, enumerate from matplotlib.colors import colorConverter from matplotlib.figure import Figure from matplotlib.widgets import SubplotTool @@ -370,7 +370,7 @@ pixbuf.save(filename, format) except gobject.GError, exc: error_msg_gtk('Save figure failure:\n%s' % (exc,), parent=self) - elif hasattr(filename, 'write') and callable(filename.write): + elif is_writable_file_like(filename): if hasattr(pixbuf, 'save_to_callback'): def save_callback(buf, data=None): data.write(buf) Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -24,7 +24,8 @@ from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, get_realpath_and_stat +from matplotlib.cbook import Bunch, enumerate, is_string_like, reverse_dict, \ + get_realpath_and_stat, is_writable_file_like from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM @@ -333,7 +334,7 @@ self.passed_in_file_object = False if is_string_like(filename): fh = file(filename, 'wb') - elif hasattr(filename, 'write') and callable(filename.write): + elif is_writable_file_like(filename): fh = filename self.passed_in_file_object = True else: Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -15,7 +15,8 @@ from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat +from matplotlib.cbook import is_string_like, izip, get_realpath_and_stat, \ + is_writable_file_like from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font @@ -873,7 +874,7 @@ if is_string_like(outfile): title = outfile tmpfile = os.path.join(gettempdir(), md5.md5(outfile).hexdigest()) - elif hasattr(outfile, 'write') and callable(outfile.write): + elif is_writable_file_like(outfile): title = None tmpfile = os.path.join(gettempdir(), md5.md5(str(hash(outfile))).hexdigest()) passed_in_file_object = True Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -5,7 +5,7 @@ from matplotlib import verbose, __version__, rcParams from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import is_string_like +from matplotlib.cbook import is_string_like, is_writable_file_like from matplotlib.colors import rgb2hex from matplotlib.figure import Figure from matplotlib.font_manager import findfont, FontProperties @@ -503,7 +503,7 @@ def print_svg(self, filename, *args, **kwargs): if is_string_like(filename): fh_to_close = svgwriter = codecs.open(filename, 'w', 'utf-8') - elif hasattr(filename, 'write') and callable(filename.write): + elif is_writable_file_like(filename): svgwriter = codecs.EncodedFile(filename, 'utf-8') fh_to_close = None else: @@ -514,7 +514,7 @@ if is_string_like(filename): gzipwriter = gzip.GzipFile(filename, 'w') fh_to_close = svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') - elif hasattr(filename, 'write') and callable(filename.write): + elif is_writable_file_like(filename): fh_to_close = gzipwriter = gzip.GzipFile(fileobj=filename, mode='w') svgwriter = codecs.EncodedFile(gzipwriter, 'utf-8') else: Modified: branches/transforms/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_tkagg.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_tkagg.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -680,7 +680,7 @@ defaultextension = self.canvas.get_default_filetype() ) - if fname == "" : + if fname == "" or fname == (): return else: try: Modified: branches/transforms/lib/matplotlib/backends/backend_wx.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/backends/backend_wx.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -152,7 +152,7 @@ cursors from matplotlib._pylab_helpers import Gcf from matplotlib.artist import Artist -from matplotlib.cbook import exception_to_str, is_string_like +from matplotlib.cbook import exception_to_str, is_string_like, is_writable_file_like from matplotlib.figure import Figure from matplotlib.path import Path from matplotlib.text import _process_text_args, Text @@ -343,8 +343,10 @@ if angle == 0.0: gfx_ctx.DrawText(s, x, y) else: - angle = angle * (math.pi / 180.0) - gfx_ctx.DrawRotatedText(s, x, y, angle) + angle = angle / 180.0 * math.pi + xo = h * math.sin(rads) + yo = h * math.cos(rads) + gfx_ctx.DrawRotatedText(s, x - xo, y - yo, angle) gc.unselect() @@ -976,7 +978,7 @@ # the error on a call or print_figure may not work because # printing can be qued and called from realize raise RuntimeError('Could not save figure to %s\n' % (filename)) - elif hasattr(filename, 'write') and callable(filename.write): + elif is_writable_file_like(filename): if not self.bitmap.ConvertToImage().SaveStream(filename, filetype): DEBUG_MSG('print_figure() file save error', 4, self) raise RuntimeError('Could not save figure to %s\n' % (filename)) Modified: branches/transforms/lib/matplotlib/cbook.py =================================================================== --- branches/transforms/lib/matplotlib/cbook.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/cbook.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -209,20 +209,14 @@ def is_string_like(obj): - if hasattr(obj, 'shape'): return 0 # this is a workaround - # for a bug in numeric<23.1 + if hasattr(obj, 'shape'): return 0 try: obj + '' except (TypeError, ValueError): return 0 return 1 +def is_writable_file_like(obj): + return hasattr(filename, 'write') and callable(filename.write) -def is_file_like(obj): - if hasattr(obj, 'shape'): return 0 # this is a workaround - # for a bug in numeric<23.1 - try: obj + '' - except (TypeError, ValueError): return 0 - return 1 - def is_scalar(obj): return is_string_like(obj) or not iterable(obj) Modified: branches/transforms/lib/matplotlib/cm.py =================================================================== --- branches/transforms/lib/matplotlib/cm.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/cm.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -56,7 +56,7 @@ return x def set_array(self, A): - 'Set the image array from numeric/numarray A' + 'Set the image array from numpy array A' self._A = A def get_array(self): Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -364,7 +364,7 @@ thus (meshWidth * meshHeight) quadrilaterals in the mesh. The mesh need not be regular and the polygons need not be convex. A quadrilateral mesh is represented by a - (2 x ((meshWidth + 1) * (meshHeight + 1))) Numeric array + (2 x ((meshWidth + 1) * (meshHeight + 1))) numpy array 'coordinates' where each row is the X and Y coordinates of one of the vertices. To define the function that maps from a data point to Modified: branches/transforms/lib/matplotlib/colorbar.py =================================================================== --- branches/transforms/lib/matplotlib/colorbar.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/colorbar.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -508,7 +508,7 @@ N = len(b) ii = npy.minimum(npy.searchsorted(b, xn), N-1) i0 = npy.maximum(ii - 1, 0) - #db = b[ii] - b[i0] (does not work with Numeric) + #db = b[ii] - b[i0] db = npy.take(b, ii) - npy.take(b, i0) db = npy.where(i0==ii, 1.0, db) #dy = y[ii] - y[i0] Modified: branches/transforms/lib/matplotlib/config/matplotlib.conf.default =================================================================== --- branches/transforms/lib/matplotlib/config/matplotlib.conf.default 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/config/matplotlib.conf.default 2007-11-14 19:46:37 UTC (rev 4292) @@ -1,7 +1,7 @@ # MPLConfig - plaintext (in .conf format) # This is a sample matplotlib configuration file. It should be placed -# in HOME/.matplotlib/matplotlibrc (unix/linux like systems) and +# in HOME/.matplotlib (unix/linux like systems) and # C:\Documents and Settings\yourname\.matplotlib (win32 systems) # # By default, the installer will overwrite the existing file in the install Modified: branches/transforms/lib/matplotlib/config/mplconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/config/mplconfig.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -23,7 +23,7 @@ class MPLConfig(TConfig): """ This is a sample matplotlib configuration file. It should be placed - in HOME/.matplotlib/matplotlibrc (unix/linux like systems) and + in HOME/.matplotlib (unix/linux like systems) and C:\Documents and Settings\yourname\.matplotlib (win32 systems) By default, the installer will overwrite the existing file in the install @@ -43,11 +43,11 @@ the default values listed herein. Colors: for the color values below, you can either use - - a matplotlib color string, such as r, k, or b + - a matplotlib color string, such as r | k | b - an rgb tuple, such as (1.0, 0.5, 0.0) - a hex string, such as #ff00ff or ff00ff - a scalar grayscale intensity such as 0.75 - - a legal html color name, eg red, blue, darkslategray + - a legal html color name, eg red | blue | darkslategray Interactivity: see http://matplotlib.sourceforge.net/interactive.html. @@ -63,8 +63,6 @@ units = T.false class backend(TConfig): - """Valid backends are: 'GTKAgg', 'GTKCairo', 'QtAgg', 'Qt4Agg', - 'TkAgg', 'Agg', 'Cairo', 'PS', 'PDF', 'SVG'""" use = T.Trait('Agg', mplT.BackendHandler()) class cairo(TConfig): Modified: branches/transforms/lib/matplotlib/config/mpltraits.py =================================================================== --- branches/transforms/lib/matplotlib/config/mpltraits.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/config/mpltraits.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -24,18 +24,22 @@ class BackendHandler(T.TraitHandler): """ """ - backends = {'tkagg': 'TkAgg', + backends = {'agg': 'Agg', + 'cairo': 'Cairo', + 'cocoaagg': 'CocoaAgg', + 'fltkagg': 'FltkAgg', + 'gtk': 'GTK', 'gtkagg': 'GTKAgg', 'gtkcairo': 'GTKCairo', + 'pdf': 'Pdf', + 'ps': 'PS', 'qt4agg': 'Qt4Agg', 'qtagg': 'QtAgg', - 'wxagg': 'WXAgg', - 'agg': 'Agg', - 'cairo': 'Cairo', - 'ps': 'PS', - 'pdf': 'Pdf', 'svg': 'SVG', - 'template': 'Template' } + 'template': 'Template', + 'tkagg': 'TkAgg', + 'wx': 'WX', + 'wxagg': 'WXAgg'} def validate(self, object, name, value): try: @@ -46,7 +50,7 @@ def info(self): be = self.backends.keys() be.sort - return "one of %s"% ', '.join(['%s'%i for i in be]) + return "one of: %s"% ' | '.join(['%s'%i for i in be]) class BoolHandler(T.TraitHandler): @@ -73,7 +77,7 @@ return self.error(object, name, value) def info(self): - return "one of %s"% ', '.join(['%s'%i for i in self.bools.keys()]) + return "one of: %s"% ' | '.join(['%s'%i for i in self.bools.keys()]) flexible_true = T.Trait(True, BoolHandler()) flexible_false = T.Trait(False, BoolHandler()) Modified: branches/transforms/lib/matplotlib/config/tconfig.py =================================================================== --- branches/transforms/lib/matplotlib/config/tconfig.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/config/tconfig.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -76,6 +76,50 @@ # Utility functions ############################################################################ +def get_split_ind(seq, N): + """seq is a list of words. Return the index into seq such that + len(' '.join(seq[:ind])<=N + """ + + sLen = 0 + # todo: use Alex's xrange pattern from the cbook for efficiency + for (word, ind) in zip(seq, range(len(seq))): + sLen += len(word) + 1 # +1 to account for the len(' ') + if sLen>=N: return ind + return len(seq) + +def wrap(prefix, text, cols, max_lines=6): + 'wrap text with prefix at length cols' + pad = ' '*len(prefix.expandtabs()) + available = cols - len(pad) + + seq = text.split(' ') + Nseq = len(seq) + ind = 0 + lines = [] + while ind<Nseq: + lastInd = ind + ind += get_split_ind(seq[ind:], available) + lines.append(seq[lastInd:ind]) + + num_lines = len(lines) + abbr_end = max_lines // 2 + abbr_start = max_lines - abbr_end + lines_skipped = False + for i in range(num_lines): + if i == 0: + # add the prefix to the first line, pad with spaces otherwise + ret = prefix + ' '.join(lines[i]) + '\n' + elif i < abbr_start or i > num_lines-abbr_end-1: + ret += pad + ' '.join(lines[i]) + '\n' + else: + if not lines_skipped: + lines_skipped = True + ret += ' <...snipped %d lines...> \n' % (num_lines-max_lines) +# for line in lines[1:]: +# ret += pad + ' '.join(line) + '\n' + return ret[:-1] + def dedent(txt): """A modified version of textwrap.dedent, specialized for docstrings. @@ -115,44 +159,6 @@ return ''.join(lines) -def short_str(txt,line_length=80,max_lines=6): - """Shorten a text input if necessary. - """ - - assert max_lines%2==0,"max_lines must be even" - - if txt.count('\n') <= 1: - # Break up auto-generated text that can be *very* long but in just one - # line. - ltxt = len(txt) - max_len = line_length*max_lines - chunk = max_lines/2 - - if ltxt > max_len: - out = [] - for n in range(chunk): - out.append(txt[line_length*n:line_length*(n+1)]) - - out.append(' <...snipped %d chars...> ' % (ltxt-max_len)) - - for n in range(-chunk-1,0,1): - # Special-casing for the last step of the loop, courtesy of - # Python's idiotic string slicign semantics when the second - # argument is 0. Argh. - end = line_length*(n+1) - if end==0: end = None - out.append(txt[line_length*n:end]) - - txt = '\n'.join(out) - else: - nlines = ltxt/line_length - out = [ txt[line_length*n:line_length*(n+1)] - for n in range(nlines+1)] - if out: - txt = '\n'.join(out) - return txt - - def configObj2Str(cobj): """Dump a Configobj instance to a string.""" outstr = StringIO() @@ -463,7 +469,7 @@ # Get a short version of info with lines of max. 78 chars, so # that after commenting them out (with '# ') they are at most # 80-chars long. - out.append(comment(short_str(info,78-len(indent)),indent)) + out.append(comment(wrap('',info.replace('\n', ' '),78-len(indent)),indent)) except (KeyError,AttributeError): pass out.append(indent+('%s = %r' % (s,v))) Modified: branches/transforms/lib/matplotlib/image.py =================================================================== --- branches/transforms/lib/matplotlib/image.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/image.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -7,18 +7,23 @@ import os import numpy as npy -from matplotlib.numerix import npyma as ma +import matplotlib.numerix.npyma as ma + from matplotlib import rcParams -from artist import Artist -from colors import colorConverter -import cm -import _image +from matplotlib import artist as martist +from matplotlib import colors as mcolors +from matplotlib import cm +# For clarity, names from _image are given explicitly in this module: +from matplotlib import _image -from _image import * -class AxesImage(Artist, cm.ScalarMappable): +# For user convenience, the names from _image are also imported into +# the image namespace: +from matplotlib._image import * +class AxesImage(martist.Artist, cm.ScalarMappable): + def __init__(self, ax, cmap = None, norm = None, @@ -43,7 +48,7 @@ Additional kwargs are matplotlib.artist properties """ - Artist.__init__(self) + martist.Artist.__init__(self) cm.ScalarMappable.__init__(self, norm, cmap) if origin is None: origin = rcParams['image.origin'] @@ -99,7 +104,7 @@ ACCEPTS: float """ - Artist.set_alpha(self, alpha) + martist.Artist.set_alpha(self, alpha) self._imcache = None def changed(self): @@ -133,7 +138,8 @@ else: im = self._imcache - bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0) + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) im.set_bg( *bg) # image input dimensions @@ -229,18 +235,18 @@ """ retained for backwards compatibility - use set_data instead - ACCEPTS: numeric/numarray/PIL Image A""" + ACCEPTS: numpy array A or PIL Image""" # This also needs to be here to override the inherited # cm.ScalarMappable.set_array method so it is not invoked # by mistake. self.set_data(A) - + def set_extent(self, extent): """extent is data axes (left, right, bottom, top) for making image plots """ self._extent = extent - + xmin, xmax, ymin, ymax = extent corners = (xmin, ymin), (xmax, ymax) self.axes.update_datalim(corners) @@ -330,10 +336,9 @@ height *= magnification im = _image.pcolor(self._Ax, self._Ay, self._A, height, width, - (x0, x0+v_width, y0, y0+v_height), - ) - - bg = colorConverter.to_rgba(self.axes.get_frame().get_facecolor(), 0) + (x0, x0+v_width, y0, y0+v_height)) + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) im.set_bg(*bg) return im @@ -402,7 +407,7 @@ -class FigureImage(Artist, cm.ScalarMappable): +class FigureImage(martist.Artist, cm.ScalarMappable): def __init__(self, fig, cmap = None, norm = None, @@ -416,7 +421,7 @@ norm is a colors.Normalize instance to map luminance to 0-1 """ - Artist.__init__(self) + martist.Artist.__init__(self) cm.ScalarMappable.__init__(self, norm, cmap) if origin is None: origin = rcParams['image.origin'] self.origin = origin @@ -464,7 +469,8 @@ x = self.to_rgba(self._A, self._alpha) im = _image.fromarray(x, 1) - im.set_bg( *colorConverter.to_rgba(self.figure.get_facecolor(), 0) ) + fc = self.figure.get_facecolor() + im.set_bg( *mcolors.colorConverter.to_rgba(fc, 0) ) im.is_grayscale = (self.cmap.name == "gray" and len(self._A.shape) == 2) if self.origin=='upper': Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -229,7 +229,7 @@ """ Artist.__init__(self) - #convert sequences to numeric arrays + #convert sequences to numpy arrays if not iterable(xdata): raise RuntimeError('xdata must be a sequence') if not iterable(ydata): Modified: branches/transforms/lib/matplotlib/mlab.py =================================================================== --- branches/transforms/lib/matplotlib/mlab.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/mlab.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -353,7 +353,7 @@ # zero pad x up to NFFT if it is shorter than NFFT if len(x)<NFFT: n = len(x) - x = resize(x, (NFFT,)) + x = npy.resize(x, (NFFT,)) x[n:] = 0 @@ -533,7 +533,7 @@ Cxy, Phase, freqs = cohere_pairs( X, ij, ...) Compute the coherence for all pairs in ij. X is a - numSamples,numCols Numeric array. ij is a list of tuples (i,j). + numSamples,numCols numpy array. ij is a list of tuples (i,j). Each tuple is a pair of indexes into the columns of X for which you want to compute coherence. For example, if X has 64 columns, and you want to compute all nonredundant pairs, define ij as @@ -894,7 +894,7 @@ Example 1 : ## 2D system - # Numeric solution + def derivs6(x,t): d1 = x[0] + 2*x[1] d2 = -3*x[0] + 4*x[1] @@ -1480,8 +1480,7 @@ """ A set of convenient utilities for numerical work. -Most of this module requires Numerical Python or is meant to be used with it. -See http://www.pfdubois.com/numpy for details. +Most of this module requires numpy or is meant to be used with it. Copyright (c) 2001-2004, Fernando Perez. <Fer...@co...> All rights reserved. @@ -1754,7 +1753,7 @@ #from numpy import fromfunction as fromfunction_kw def fromfunction_kw(function, dimensions, **kwargs): - """Drop-in replacement for fromfunction() from Numerical Python. + """Drop-in replacement for fromfunction() from numpy Allows passing keyword arguments to the desired function. @@ -1938,12 +1937,8 @@ ### end mlab2 functions -#Classes for manipulating and viewing numpy record arrays +#helpers for loading, saving, manipulating and viewing numpy record arrays - - - - def safe_isnan(x): 'isnan for arbitrary types' try: b = npy.isnan(x) @@ -2236,10 +2231,10 @@ # a series of classes for describing the format intentions of various rec views class FormatObj: def tostr(self, x): - return str(self.toval(x)) + return self.toval(x) def toval(self, x): - return x + return str(x) class FormatString(FormatObj): Modified: branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.template =================================================================== --- branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.template 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/mpl-data/matplotlib.conf.template 2007-11-14 19:46:37 UTC (rev 4292) @@ -21,11 +21,11 @@ # the default values listed herein. # # Colors: for the color values below, you can either use -# - a matplotlib color string, such as r, k, or b +# - a matplotlib color string, such as r | k | b # - an rgb tuple, such as (1.0, 0.5, 0.0) # - a hex string, such as #ff00ff or ff00ff # - a scalar grayscale intensity such as 0.75 -# - a legal html color name, eg red, blue, darkslategray +# - a legal html color name, eg red | blue | darkslategray # # Interactivity: see http://matplotlib.sourceforge.net/interactive.html. # @@ -33,20 +33,19 @@ # a value of type 'str' datapath = '/usr/lib64/python2.5/site-packages/matplotlib/mpl-data' -# one of 0, on, false, 1, no, n, y, off, yes, true +# one of: 0 | on | false | 1 | no | n | y | off | yes | true interactive = False # a value of type 'bool' maskedarray = False # 'numpy' or 'numeric' or 'numarray' numerix = 'numpy' -# 'Africa/Abidjan' or 'Africa/Accra' or 'Africa/Addis_Ababa' or 'Africa/Algiers' -# or 'Africa/Asmara' or 'Africa/Asmera' or 'Africa/Bamako' or 'Africa/Bangui' o -# r 'Africa/Banjul' or 'Africa/Bissau' or 'Africa/Blantyre' or 'Africa/Brazzavil -# <...snipped 10590 chars...> -# or 'Turkey' or 'UCT' or 'US/Alaska' or 'US/Aleutian' or 'US/Arizona' or 'US/Ce -# ntral' or 'US/East-Indiana' or 'US/Eastern' or 'US/Hawaii' or 'US/Indiana-Star -# ke' or 'US/Michigan' or 'US/Mountain' or 'US/Pacific' or 'US/Pacific-New' or ' -# US/Samoa' or 'UTC' or 'Universal' or 'W-SU' or 'WET' or 'Zulu' or 'posixrules' +# 'Africa/Abidjan' or 'Africa/Accra' or 'Africa/Addis_Ababa' or +# 'Africa/Algiers' or 'Africa/Asmara' or 'Africa/Asmera' or 'Africa/Bamako' or +# 'Africa/Bangui' or 'Africa/Banjul' or 'Africa/Bissau' or 'Africa/Blantyre' +# <...snipped 156 lines...> +# 'US/Michigan' or 'US/Mountain' or 'US/Pacific' or 'US/Pacific-New' or +# 'US/Samoa' or 'UTC' or 'Universal' or 'W-SU' or 'WET' or 'Zulu' or +# 'posixrules' timezone = 'UTC' # 'toolbar2' or None toolbar = 'toolbar2' @@ -64,23 +63,23 @@ # name like 'orange', a hex color like '#efefef', a grayscale intensity # like '0.5', or an RGBA tuple (1,0,0,1) facecolor = 'white' - # one of 0, on, false, 1, no, n, y, off, yes, true + # one of: 0 | on | false | 1 | no | n | y | off | yes | true grid = False - # one of 0, on, false, 1, no, n, y, off, yes, true + # one of: 0 | on | false | 1 | no | n | y | off | yes | true hold = True # any valid matplotlib color, eg an abbreviation like 'r' for red, a full # name like 'orange', a hex color like '#efefef', a grayscale intensity # like '0.5', or an RGBA tuple (1,0,0,1) labelcolor = 'black' - # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or 'medium' - # or 'large' or 'x-large' or 'xx-large' + # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or + # 'medium' or 'large' or 'x-large' or 'xx-large' labelsize = 'medium' # a value of type 'float' linewidth = 1.0 - # one of 0, on, false, 1, no, n, y, off, yes, true + # one of: 0 | on | false | 1 | no | n | y | off | yes | true polargrid = True - # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or 'medium' - # or 'large' or 'x-large' or 'xx-large' + # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or + # 'medium' or 'large' or 'x-large' or 'xx-large' titlesize = 'large' [[formatter]] @@ -88,10 +87,8 @@ limits = [-7.0, 7.0] [backend] - # Valid backends are: 'GTKAgg', 'GTKCairo', 'QtAgg', 'Qt4Agg', - # 'TkAgg', 'Agg', 'Cairo', 'PS', 'PDF', 'SVG' - # one of ps, qt4agg, tkagg, gtkagg, agg, cairo, gtkcairo, wxagg, qtagg, temp - # late, svg, pdf + # one of: ps | qt4agg | fltkagg | gtkagg | agg | cairo | gtk | gtkcairo | + # wxagg | tkagg | qtagg | template | svg | cocoaagg | pdf | wx use = 'Agg' [[cairo]] @@ -111,10 +108,10 @@ [[ps]] # 3 or 42 fonttype = 3 - # 'auto' or 'letter' or 'legal' or 'ledger' or 'A0' or 'A1' or 'A2' or ' - # A3' or 'A4' or 'A5' or 'A6' or 'A7' or 'A8' or 'A9' or 'A10' or 'B0' o - # r 'B1' or 'B2' or 'B3' or 'B4' or 'B5' or 'B6' or 'B7' or 'B8' or 'B9' - # or 'B10' + # 'auto' or 'letter' or 'legal' or 'ledger' or 'A0' or 'A1' or 'A2' or + # 'A3' or 'A4' or 'A5' or 'A6' or 'A7' or 'A8' or 'A9' or 'A10' or + # 'B0' or 'B1' or 'B2' or 'B3' or 'B4' or 'B5' or 'B6' or 'B7' or 'B8' + # or 'B9' or 'B10' papersize = 'letter' # a value of type 'bool' useafm = False @@ -191,16 +188,16 @@ serif = ['Bitstream Vera Serif', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif'] # a value of type 'float' size = 12.0 - # 'ultra-condensed' or 'extra-condensed' or 'condensed' or 'semi-condensed' - # or 'normal' or 'semi-expanded' or 'expanded' or 'extra-expanded' or 'ultra - # -expanded' or 'wider' or 'narrower' + # 'ultra-condensed' or 'extra-condensed' or 'condensed' or + # 'semi-condensed' or 'normal' or 'semi-expanded' or 'expanded' or + # 'extra-expanded' or 'ultra-expanded' or 'wider' or 'narrower' stretch = 'normal' # 'normal' or 'italic' or 'oblique' style = 'normal' # 'normal' or 'small-caps' variant = 'normal' - # 'normal' or 'bold' or 'bolder' or 'lighter' or 100 or 200 or 300 or 400 or - # 500 or 600 or 700 or 800 or 900 + # 'normal' or 'bold' or 'bolder' or 'lighter' or 100 or 200 or 300 or 400 + # or 500 or 600 or 700 or 800 or 900 weight = 'normal' [grid] @@ -216,18 +213,18 @@ [image] # a value of type 'float' or 'equal' or 'auto' aspect = 'equal' - # 'Accent' or 'Accent_r' or 'Blues' or 'Blues_r' or 'BrBG' or 'BrBG_r' or 'B - # uGn' or 'BuGn_r' or 'BuPu' or 'BuPu_r' or 'Dark2' or 'Dark2_r' or 'GnBu' o - # r 'GnBu_r' or 'Greens' or 'Greens_r' or 'Greys' or 'Greys_r' or 'OrRd' or - # <...snipped 1010 chars...> - # ist_stern' or 'gist_stern_r' or 'gist_yarg' or 'gist_yarg_r' or 'gray' or - # 'gray_r' or 'hot' or 'hot_r' or 'hsv' or 'hsv_r' or 'jet' or 'jet_r' or 'p - # ink' or 'pink_r' or 'prism' or 'prism_r' or 'spectral' or 'spectral_r' or - # 'spring' or 'spring_r' or 'summer' or 'summer_r' or 'winter' or 'winter_r' + # 'Accent' or 'Accent_r' or 'Blues' or 'Blues_r' or 'BrBG' or 'BrBG_r' or + # 'BuGn' or 'BuGn_r' or 'BuPu' or 'BuPu_r' or 'Dark2' or 'Dark2_r' or + # 'GnBu' or 'GnBu_r' or 'Greens' or 'Greens_r' or 'Greys' or 'Greys_r' or + # <...snipped 16 lines...> + # 'pink_r' or 'prism' or 'prism_r' or 'spectral' or 'spectral_r' or + # 'spring' or 'spring_r' or 'summer' or 'summer_r' or 'winter' or + # 'winter_r' cmap = 'jet' - # 'bilinear' or 'nearest' or 'bicubic' or 'spline16' or 'spline36' or 'hanni - # ng' or 'hamming' or 'hermite' or 'kaiser' or 'quadric' or 'catrom' or 'gau - # ssian' or 'bessel' or 'mitchell' or 'sinc' or 'lanczos' or 'blackman' + # 'bilinear' or 'nearest' or 'bicubic' or 'spline16' or 'spline36' or + # 'hanning' or 'hamming' or 'hermite' or 'kaiser' or 'quadric' or 'catrom' + # or 'gaussian' or 'bessel' or 'mitchell' or 'sinc' or 'lanczos' or + # 'blackman' interpolation = 'bilinear' # a value of type 'int' lut = 256 @@ -237,8 +234,8 @@ [legend] # a value of type 'float' axespad = 0.02 - # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or 'medium' - # or 'large' or 'x-large' or 'xx-large' + # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or + # 'medium' or 'large' or 'x-large' or 'xx-large' fontsize = 'medium' # a value of type 'float' handlelen = 0.050000000000000003 @@ -248,9 +245,9 @@ isaxes = True # a value of type 'float' labelsep = 0.01 - # 'best' or 'upper right' or 'upper left' or 'lower left' or 'lower right' o - # r 'right' or 'center left' or 'center right' or 'lower center' or 'upper c - # enter' or 'center' + # 'best' or 'upper right' or 'upper left' or 'lower left' or 'lower right' + # or 'right' or 'center left' or 'center right' or 'lower center' or + # 'upper center' or 'center' loc = 'upper right' # a value of type 'float' markerscale = 1.0 @@ -276,9 +273,9 @@ linestyle = '-' # a value of type 'float' linewidth = 1.0 - # 'None' or 'o' or '.' or ',' or '^' or 'v' or '<' or '>' or 's' or '+' or ' - # x' or 'D' or 'd' or '1' or '2' or '3' or '4' or 'h' or 'H' or 'p' or '|' o - # r '_' + # 'None' or 'o' or '.' or ',' or '^' or 'v' or '<' or '>' or 's' or '+' or + # 'x' or 'D' or 'd' or '1' or '2' or '3' or '4' or 'h' or 'H' or 'p' or + # '|' or '_' marker = 'None' # a value of type 'float' markeredgewidth = 0.5 @@ -290,27 +287,27 @@ solid_joinstyle = 'miter' [mathtext] - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. bf = 'serif:bold' - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. cal = 'cursive' # a value of type 'bool' fallback_to_cm = True # 'cm' or 'stix' or 'stixsans' or 'custom' fontset = 'cm' - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. it = 'serif:oblique' - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. rm = 'serif' - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. sf = 'sans' - # A fontconfig pattern. See the fontconfig user manual for more information - # . + # A fontconfig pattern. See the fontconfig user manual for more + # information. tt = 'monospace' [patch] @@ -370,8 +367,8 @@ color = 'black' # 'in' or 'out' direction = 'in' - # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or 'medium' - # or 'large' or 'x-large' or 'xx-large' + # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or + # 'medium' or 'large' or 'x-large' or 'xx-large' labelsize = 'small' [[major]] @@ -393,8 +390,8 @@ color = 'black' # 'in' or 'out' direction = 'in' - # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or 'medium' - # or 'large' or 'x-large' or 'xx-large' + # a value of type 'float' or 'xx-small' or 'x-small' or 'small' or + # 'medium' or 'large' or 'x-large' or 'xx-large' labelsize = 'small' [[major]] Modified: branches/transforms/lib/matplotlib/numerix/__init__.py =================================================================== --- branches/transforms/lib/matplotlib/numerix/__init__.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/numerix/__init__.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -35,8 +35,10 @@ use_maskedarray = True if a == "--ma": use_maskedarray = False -del a +try: del a +except NameError: pass + if which[0] is None: try: # In theory, rcParams always has *some* value for numerix. which = rcParams['numerix'], "rc" Modified: branches/transforms/lib/matplotlib/pylab.py =================================================================== --- branches/transforms/lib/matplotlib/pylab.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/lib/matplotlib/pylab.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -191,11 +191,6 @@ __end -Credits: The plotting commands were provided by -John D. Hunter <jdh...@ac...> - -Most of the other commands are from Numeric, MLab and FFT, with the -exception of those in mlab.py provided by matplotlib. """ import sys, warnings Modified: branches/transforms/setup.py =================================================================== --- branches/transforms/setup.py 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/setup.py 2007-11-14 19:46:37 UTC (rev 4292) @@ -169,7 +169,6 @@ if options['build_gtk']: if hasgtk or (options['build_gtk'] is True): build_gdk(ext_modules, packages) - rc['backend'] = 'GTK' if options['build_gtkagg']: if hasgtk or (options['build_gtkagg'] is True): options['build_agg'] = 1 @@ -264,15 +263,16 @@ distrib = setup(name="matplotlib", version= __version__, - description = "Matlab(TM) style python plotting package", + description = "Python plotting package", author = "John D. Hunter", author_email="jd...@gm...", url = "http://matplotlib.sourceforge.net", long_description = """ matplotlib strives to produce publication quality 2D graphics - using matlab plotting for inspiration. Although the main lib is - object oriented, there is a functional interface "pylab" - for people coming from Matlab. + for interactive graphing, scientific publishing, user interface + development and web application servers targeting multiple user + interfaces and hardcopy output formats. There is a 'pylab' mode + which emulates matlab graphics """, packages = packages, platforms='any', Modified: branches/transforms/src/_image.cpp =================================================================== --- branches/transforms/src/_image.cpp 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/src/_image.cpp 2007-11-14 19:46:37 UTC (rev 4292) @@ -1403,8 +1403,8 @@ // Create output Image* imo = new Image; imo->rowsIn = rows; + imo->colsIn = cols; imo->rowsOut = rows; - imo->colsIn = cols; imo->colsOut = cols; size_t NUMBYTES(rows * cols * 4); agg::int8u *buffer = new agg::int8u[NUMBYTES]; @@ -1499,6 +1499,227 @@ return Py::asObject(imo); } +void _bin_indices(int *irows, int nrows, double *y, int ny, + double sc, double offs) +{ + int i; + if (sc*(y[ny-1] - y[0]) > 0) + { + int ii = 0; + int iilast = ny-1; + int iy0 = (int)floor(sc * (y[ii] - offs)); + int iy1 = (int)floor(sc * (y[ii+1] - offs)); + for (i=0; i<nrows && i<iy0; i++) { + irows[i] = -1; + } + for (; i<nrows; i++) { + while (i > iy1 && ii < iilast) { + ii++; + iy0 = iy1; + iy1 = (int)floor(sc * (y[ii+1] - offs)); + } + if (i >= iy0 && i <= iy1) irows[i] = ii; + else break; + } + for (; i<nrows; i++) { + irows[i] = -1; + } + } + else + { + int iilast = ny-1; + int ii = iilast; + int iy0 = (int)floor(sc * (y[ii] - offs)); + int iy1 = (int)floor(sc * (y[ii-1] - offs)); + for (i=0; i<nrows && i<iy0; i++) { + irows[i] = -1; + } + for (; i<nrows; i++) { + while (i > iy1 && ii > 1) { + ii--; + iy0 = iy1; + iy1 = (int)floor(sc * (y[ii-1] - offs)); + } + if (i >= iy0 && i <= iy1) irows[i] = ii-1; + else break; + } + for (; i<nrows; i++) { + irows[i] = -1; + } + } +} + +char __image_module_pcolor2__doc__[] = +"pcolor2(x, y, data, rows, cols, bounds, bg)\n" +"\n" +"Generate a pseudo-color image from data on a non-uniform grid\n" +"specified by its cell boundaries.\n" +"bounds = (x_left, x_right, y_bot, y_top)\n" +"bg = ndarray of 4 uint8 representing background rgba\n" +; +Py::Object +_image_module::pcolor2(const Py::Tuple& args) { + _VERBOSE("_image_module::pcolor2"); + + if (args.length() != 7) + throw Py::TypeError("Incorrect number of arguments (6 expected)"); + + Py::Object xp = args[0]; + Py::Object yp = args[1]; + Py::Object dp = args[2]; + int rows = Py::Int(args[3]); + int cols = Py::Int(args[4]); + Py::Tuple bounds = args[5]; + Py::Object bgp = args[6]; + + if (bounds.length() !=4) + throw Py::TypeError("Incorrect number of bounds (4 expected)"); + double x_left = Py::Float(bounds[0]); + double x_right = Py::Float(bounds[1]); + double y_bot = Py::Float(bounds[2]); + double y_top = Py::Float(bounds[3]); + + // Check we have something to output to + if (rows == 0 || cols ==0) + throw Py::ValueError("rows or cols is zero; there are no pixels"); + + // Get numpy arrays + PyArrayObject *x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), + PyArray_DOUBLE, 1, 1); + if (x == NULL) + throw Py::ValueError("x is of incorrect type (wanted 1D double)"); + PyArrayObject *y = (PyArrayObject *) PyArray_ContiguousFromObject(yp.ptr(), + PyArray_DOUBLE, 1, 1); + if (y == NULL) { + Py_XDECREF(x); + throw Py::ValueError("y is of incorrect type (wanted 1D double)"); + } + PyArrayObject *d = (PyArrayObject *) PyArray_ContiguousFromObject(dp.ptr(), + PyArray_UBYTE, 3, 3); + if (d == NULL) { + Py_XDECREF(x); + Py_XDECREF(y); + throw Py::ValueError("data is of incorrect type (wanted 3D uint8)"); + } + if (d->dimensions[2] != 4) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + throw Py::ValueError("data must be in RGBA format"); + } + + // Check dimensions match + int nx = x->dimensions[0]; + int ny = y->dimensions[0]; + if (nx != d->dimensions[1]+1 || ny != d->dimensions[0]+1) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + throw Py::ValueError("data and axis bin boundary dimensions are incompatible"); + } + + PyArrayObject *bg = (PyArrayObject *) PyArray_ContiguousFromObject(bgp.ptr(), + PyArray_UBYTE, 1, 1); + if (bg == NULL) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + throw Py::ValueError("bg is of incorrect type (wanted 1D uint8)"); + } + if (bg->dimensions[0] != 4) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + Py_XDECREF(bg); + throw Py::ValueError("bg must be in RGBA format"); + } + + + // Allocate memory for pointer arrays + int * irows = reinterpret_cast<int*>(PyMem_Malloc(sizeof(int)*rows)); + if (irows == NULL) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + Py_XDECREF(bg); + throw Py::MemoryError("Cannot allocate memory for lookup table"); + } + int * jcols = reinterpret_cast<int*>(PyMem_Malloc(sizeof(int*)*cols)); + if (jcols == NULL) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + Py_XDECREF(bg); + PyMem_Free(irows); + throw Py::MemoryError("Cannot allocate memory for lookup table"); + } + + // Create output + Image* imo = new Image; + imo->rowsIn = rows; + imo->rowsOut = rows; + imo->colsIn = cols; + imo->colsOut = cols; + size_t NUMBYTES(rows * cols * 4); + agg::int8u *buffer = new agg::int8u[NUMBYTES]; + if (buffer == NULL) { + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + Py_XDECREF(bg); + PyMem_Free(irows); + PyMem_Free(jcols); + throw Py::MemoryError("Could not allocate memory for image"); + } + + // Calculate the pointer arrays to map input x to output x + int i, j; + double *x0 = reinterpret_cast<double*>(x->data); + double *y0 = reinterpret_cast<double*>(y->data); + double sx = cols/(x_right - x_left); + double sy = rows/(y_top - y_bot); + _bin_indices(jcols, cols, x0, nx, sx, x_left); + _bin_indices(irows, rows, y0, ny, sy, y_bot); + + // Copy data to output buffer + agg::int8u * position = buffer; + unsigned char *start = reinterpret_cast<unsigned char*>(d->data); + unsigned char *bgptr = reinterpret_cast<unsigned char*>(bg->data); + int s0 = d->strides[0]; + int s1 = d->strides[1]; + + for (i=0; i<rows; i++) + { + for (j=0; j<cols; j++) + { + if (irows[i] == -1 || jcols[j] == -1) { + memcpy(position, bgptr, 4*sizeof(agg::int8u)); + } + else { + memcpy(position, (start + s0*irows[i] + s1*jcols[j]), + 4*sizeof(agg::int8u)); + } + position += 4; + } + } + + // Attach output buffer to output buffer + imo->rbufOut = new agg::rendering_buffer; + imo->bufferOut = buffer; + imo->rbufOut->attach(imo->bufferOut, imo->colsOut, imo->rowsOut, imo->colsOut * imo->BPP); + + Py_XDECREF(x); + Py_XDECREF(y); + Py_XDECREF(d); + Py_XDECREF(bg); + PyMem_Free(irows); + PyMem_Free(jcols); + + return Py::asObject(imo); +} + + + #if defined(_MSC_VER) DL_EXPORT(void) #elif defined(__cplusplus) @@ -1532,7 +1753,7 @@ d["SINC"] = Py::Int(Image::SINC); d["LANCZOS"] = Py::Int(Image::LANCZOS); d["BLACKMAN"] = Py::Int(Image::BLACKMAN); - + d["ASPECT_FREE"] = Py::Int(Image::ASPECT_FREE); d["ASPECT_PRESERVE"] = Py::Int(Image::ASPECT_PRESERVE); Modified: branches/transforms/src/_image.h =================================================================== --- branches/transforms/src/_image.h 2007-11-14 19:45:49 UTC (rev 4291) +++ branches/transforms/src/_image.h 2007-11-14 19:46:37 UTC (rev 4292) @@ -134,6 +134,8 @@ "from_images"); add_varargs_method("pcolor", &_image_module::pcolor, "pcolor"); + add_varargs_method("pcolor2", &_image_module::pcolor2, + "pcolor2"); initialize( "The _image module" ); } @@ -145,11 +147,13 @@ Py::Object fromarray (const Py::Tuple &args); Py::Object fromarray2 (const Py::Tuple &args); Py::Object pcolor (const Py::Tuple &args); + Py::Object pcolor2 (const Py::Tuple &args); Py::Object readpng (const Py::Tuple &args); Py::Object from_images (const Py::Tuple &args); static char _image_module_fromarray__doc__[]; static char _image_module_pcolor__doc__[]; + static char _image_module_pcolor2__doc__[]; static char _image_module_fromarray2__doc__[]; static char _image_module_frombyte__doc__[]; static char _image_module_frombuffer__doc__[]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-15 15:18:46
|
Revision: 4305 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4305&view=rev Author: mdboom Date: 2007-11-15 07:18:42 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Speed improvements. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py branches/transforms/lib/matplotlib/transforms.py branches/transforms/src/_backend_agg.cpp branches/transforms/src/_path.cpp Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-15 15:15:21 UTC (rev 4304) +++ branches/transforms/lib/matplotlib/path.py 2007-11-15 15:18:42 UTC (rev 4305) @@ -160,31 +160,33 @@ def iter_segments(self): """ - Iterates over all of the endpoints in the path. Unlike - iterating directly over the vertices array, curve control - points are skipped over. + Iterates over all of the curve segments in the path. """ - i = 0 - NUM_VERTICES = self.NUM_VERTICES vertices = self.vertices codes = self.codes + len_vertices = len(vertices) + NUM_VERTICES = self.NUM_VERTICES + MOVETO = self.MOVETO + LINETO = self.LINETO + CLOSEPOLY = self.CLOSEPOLY + STOP = self.STOP + if not len(vertices): return if codes is None: - code = self.MOVETO - yield vertices[0], self.MOVETO - i = 1 + yield vertices[0], MOVETO for v in vertices[1:]: - yield v, self.LINETO + yield v, LINETO else: - while i < len(vertices): + i = 0 + while i < len_vertices: code = codes[i] - if code == self.CLOSEPOLY: + if code == CLOSEPOLY: yield [], code i += 1 - elif code == self.STOP: + elif code == STOP: return else: num_vertices = NUM_VERTICES[code] Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-11-15 15:15:21 UTC (rev 4304) +++ branches/transforms/lib/matplotlib/transforms.py 2007-11-15 15:18:42 UTC (rev 4305) @@ -25,6 +25,7 @@ import numpy as npy from matplotlib.numerix import npyma as ma +from matplotlib._path import affine_transform from numpy.linalg import inv from weakref import WeakKeyDictionary @@ -1206,10 +1207,13 @@ 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.dot(mtx[0:2, 0:2], points.transpose()) + mtx[0:2, 2:] - return points.transpose() + return points.transpose() + return affine_transform(points, mtx) + def transform_point(self, point): + mtx = self.get_matrix() + return affine_transform(point, mtx) + if DEBUG: _transform = transform def transform(self, points): @@ -1251,7 +1255,7 @@ Affine2DBase.__init__(self) if matrix is None: matrix = npy.identity(3) - else: + elif DEBUG: matrix = npy.asarray(matrix, npy.float_) assert matrix.shape == (3, 3) self._mtx = matrix @@ -1276,7 +1280,9 @@ b d f 0 0 1 """ - return Affine2D(Affine2D.matrix_from_values(a, b, c, d, e, f)) + return Affine2D( + npy.array([a, c, e, b, d, f, 0.0, 0.0, 1.0], npy.float_) + .reshape((3,3))) from_values = staticmethod(from_values) def get_matrix(self): Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-15 15:15:21 UTC (rev 4304) +++ branches/transforms/src/_backend_agg.cpp 2007-11-15 15:18:42 UTC (rev 4305) @@ -282,8 +282,8 @@ double l, b, r, t; if (py_convert_bbox(cliprect.ptr(), l, b, r, t)) { - rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)) + 1, - int(round(r)) + 1, height - int(round(t)) + 1); + rasterizer->clip_box(int(round(l)) + 1, height - int(round(b)), + int(round(r)), height - int(round(t))); } _VERBOSE("RendererAgg::set_clipbox done"); @@ -526,8 +526,6 @@ strokeCache = new agg::int8u[strokeSize]; // or any container scanlines.serialize(strokeCache); - theRasterizer->reset_clipping(); - rendererBase->reset_clipping(true); set_clipbox(gc.cliprect, rendererBase); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); @@ -536,34 +534,41 @@ agg::serialized_scanlines_adaptor_aa8 sa; agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; - while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { - //render the fill - if (face.first) { - if (has_clippath) { - pixfmt_amask_type pfa(*pixFmt, *alphaMask); - amask_ren_type r(pfa); - amask_aa_renderer_type ren(r); + if (face.first) { + // render the fill + if (has_clippath) { + pixfmt_amask_type pfa(*pixFmt, *alphaMask); + amask_ren_type r(pfa); + amask_aa_renderer_type ren(r); + ren.color(face.second); + while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { sa.init(fillCache, fillSize, x, y); - ren.color(face.second); agg::render_scanlines(sa, sl, ren); - } else { + } + } else { + rendererAA->color(face.second); + while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { sa.init(fillCache, fillSize, x, y); - rendererAA->color(face.second); agg::render_scanlines(sa, sl, *rendererAA); } } - - //render the stroke - if (has_clippath) { - pixfmt_amask_type pfa(*pixFmt, *alphaMask); - amask_ren_type r(pfa); - amask_aa_renderer_type ren(r); + path_quantized.rewind(0); + } + + //render the stroke + if (has_clippath) { + pixfmt_amask_type pfa(*pixFmt, *alphaMask); + amask_ren_type r(pfa); + amask_aa_renderer_type ren(r); + ren.color(gc.color); + while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { sa.init(strokeCache, strokeSize, x, y); - ren.color(gc.color); agg::render_scanlines(sa, sl, ren); - } else { + } + } else { + rendererAA->color(gc.color); + while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { sa.init(strokeCache, strokeSize, x, y); - rendererAA->color(gc.color); agg::render_scanlines(sa, sl, *rendererAA); } } @@ -880,8 +885,6 @@ GCAgg gc = GCAgg(gc_obj, dpi); facepair_t face = _get_rgba_face(face_obj, gc.alpha); - theRasterizer->reset_clipping(); - rendererBase->reset_clipping(true); set_clipbox(gc.cliprect, theRasterizer); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-11-15 15:15:21 UTC (rev 4304) +++ branches/transforms/src/_path.cpp 2007-11-15 15:18:42 UTC (rev 4305) @@ -11,6 +11,13 @@ // MGDTODO: Un-CXX-ify this module +struct XY { + double x; + double y; + + XY(double x_, double y_) : x(x_), y(y_) {} +}; + // the extension module class _path_module : public Py::ExtensionModule<_path_module> { @@ -32,7 +39,9 @@ "point_in_path_collection(a, atrans, b, btrans)"); add_varargs_method("clip_path_to_rect", &_path_module::clip_path_to_rect, "clip_path_to_rect(path, bbox, inside)"); - + add_varargs_method("affine_transform", &_path_module::affine_transform, + "affine_transform(vertices, transform)"); + initialize("Helper functions for paths"); } @@ -47,6 +56,7 @@ Py::Object point_in_path_collection(const Py::Tuple& args); Py::Object path_in_path(const Py::Tuple& args); Py::Object clip_path_to_rect(const Py::Tuple& args); + Py::Object affine_transform(const Py::Tuple& args); }; // @@ -97,7 +107,7 @@ inside_flag = 0; unsigned code = 0; - while (true) { + do { if (code != agg::path_cmd_move_to) code = path.vertex(&x, &y); @@ -111,7 +121,7 @@ vty1 = x; inside_flag = 0; - while (true) { + do { code = path.vertex(&x, &y); // The following cases denote the beginning on a new subpath @@ -151,12 +161,9 @@ vtx1 = x; vty1 = y; + } while (code != agg::path_cmd_stop && + (code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); - if (code == agg::path_cmd_stop || - (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) - break; - } - yflag1 = (vty1 >= ty); if (yflag0 != yflag1) { if ( ((vty1-ty) * (vtx0-vtx1) >= @@ -167,11 +174,8 @@ if (inside_flag != 0) return true; + } while (code != agg::path_cmd_stop); - if (code == agg::path_cmd_stop) - break; - } - return (inside_flag != 0); } @@ -453,7 +457,7 @@ http://en.wikipedia.org/wiki/Sutherland-Hodgman_clipping_algorithm */ -typedef std::vector<std::pair<double, double> > Polygon; +typedef std::vector<XY> Polygon; namespace clip_to_rect_filters { /* There are four different passes needed to create/remove vertices @@ -476,7 +480,7 @@ struct xlt : public bisectx { xlt(double x) : bisectx(x) {} - bool operator()(double x, double y) const { + bool is_inside(double x, double y) const { return x <= m_x; } }; @@ -484,7 +488,7 @@ struct xgt : public bisectx { xgt(double x) : bisectx(x) {} - bool operator()(double x, double y) const { + bool is_inside(double x, double y) const { return x >= m_x; } }; @@ -505,7 +509,7 @@ struct ylt : public bisecty { ylt(double y) : bisecty(y) {} - bool operator()(double x, double y) const { + bool is_inside(double x, double y) const { return y <= m_y; } }; @@ -513,7 +517,7 @@ struct ygt : public bisecty { ygt(double y) : bisecty(y) {} - bool operator()(double x, double y) const { + bool is_inside(double x, double y) const { return y >= m_y; } }; @@ -528,29 +532,23 @@ if (polygon.size() == 0) return; - sx = polygon.back().first; - sy = polygon.back().second; + sx = polygon.back().x; + sy = polygon.back().y; for (Polygon::const_iterator i = polygon.begin(); i != polygon.end(); ++i) { - px = i->first; - py = i->second; + px = i->x; + py = i->y; - sinside = filter(sx, sy); - pinside = filter(px, py); + sinside = filter.is_inside(sx, sy); + pinside = filter.is_inside(px, py); - if (sinside) { - if (pinside) { - result.push_back(std::make_pair(px, py)); - } else { - filter.bisect(sx, sy, px, py, &bx, &by); - result.push_back(std::make_pair(bx, by)); - } - } else { - if (pinside) { - filter.bisect(sx, sy, px, py, &bx, &by); - result.push_back(std::make_pair(bx, by)); - result.push_back(std::make_pair(px, py)); - } + if (sinside ^ pinside) { + filter.bisect(sx, sy, px, py, &bx, &by); + result.push_back(XY(bx, by)); } + + if (pinside) { + result.push_back(XY(px, py)); + } sx = px; sy = py; } @@ -582,11 +580,12 @@ unsigned code = 0; path.rewind(0); - while (true) { + do { + // Grab the next subpath and store it in polygon1 polygon1.clear(); - while (true) { + do { if (code == agg::path_cmd_move_to) - polygon1.push_back(std::make_pair(x, y)); + polygon1.push_back(XY(x, y)); code = path.vertex(&x, &y); @@ -594,15 +593,9 @@ break; if (code != agg::path_cmd_move_to) - polygon1.push_back(std::make_pair(x, y)); + polygon1.push_back(XY(x, y)); + } while ((code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly); - if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) { - break; - } else if (code == agg::path_cmd_move_to) { - break; - } - } - // The result of each step is fed into the next (note the // swapping of polygon1 and polygon2 at each step). clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::xlt(xmax)); @@ -610,12 +603,10 @@ clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::ylt(ymax)); clip_to_rect_one_step(polygon2, polygon1, clip_to_rect_filters::ygt(ymin)); + // Empty polygons aren't very useful, so skip them if (polygon1.size()) results.push_back(polygon1); - - if (code == agg::path_cmd_stop) - break; - } + } while (code != agg::path_cmd_stop); } Py::Object _path_module::clip_path_to_rect(const Py::Tuple &args) { @@ -633,30 +624,118 @@ ::clip_to_rect(path, x0, y0, x1, y1, inside, results); - // MGDTODO: Not exception safe int dims[2]; dims[1] = 2; PyObject* py_results = PyList_New(results.size()); - for (std::vector<Polygon>::const_iterator p = results.begin(); p != results.end(); ++p) { - size_t size = p->size(); - dims[0] = p->size(); - PyArrayObject* pyarray = (PyArrayObject*)PyArray_FromDims(2, dims, PyArray_DOUBLE); - for (size_t i = 0; i < size; ++i) { - ((double *)pyarray->data)[2*i] = (*p)[i].first; - ((double *)pyarray->data)[2*i+1] = (*p)[i].second; + if (!py_results) + throw Py::RuntimeError("Error creating results list"); + try { + for (std::vector<Polygon>::const_iterator p = results.begin(); p != results.end(); ++p) { + size_t size = p->size(); + dims[0] = p->size(); + PyArrayObject* pyarray = (PyArrayObject*)PyArray_FromDims(2, dims, PyArray_DOUBLE); + for (size_t i = 0; i < size; ++i) { + ((double *)pyarray->data)[2*i] = (*p)[i].x; + ((double *)pyarray->data)[2*i+1] = (*p)[i].y; + } + if (PyList_SetItem(py_results, p - results.begin(), (PyObject *)pyarray) != -1) { + throw Py::RuntimeError("Error creating results list"); + } } - // MGDTODO: Error check - PyList_SetItem(py_results, p - results.begin(), (PyObject *)pyarray); + } catch (...) { + Py_XDECREF(py_results); + throw; } return Py::Object(py_results, true); } -struct XY { - double x; - double y; -}; +Py::Object _path_module::affine_transform(const Py::Tuple& args) { + args.verify_length(2); + + Py::Object vertices_obj = args[0]; + Py::Object transform_obj = args[1]; + PyArrayObject* vertices = NULL; + PyArrayObject* transform = NULL; + PyArrayObject* result = NULL; + + try { + vertices = (PyArrayObject*)PyArray_FromObject + (vertices_obj.ptr(), PyArray_DOUBLE, 1, 2); + if (!vertices || + (PyArray_NDIM(vertices) == 2 && PyArray_DIM(vertices, 1) != 2) || + (PyArray_NDIM(vertices) == 1 && PyArray_DIM(vertices, 0) != 2)) + throw Py::ValueError("Invalid vertices array."); + + transform = (PyArrayObject*) PyArray_FromObject + (transform_obj.ptr(), PyArray_DOUBLE, 2, 2); + if (!transform || PyArray_NDIM(transform) != 2 || PyArray_DIM(transform, 0) != 3 || PyArray_DIM(transform, 1) != 3) + throw Py::ValueError("Invalid transform."); + + double a, b, c, d, e, f; + { + size_t stride0 = PyArray_STRIDE(transform, 0); + size_t stride1 = PyArray_STRIDE(transform, 1); + char* row0 = PyArray_BYTES(transform); + char* row1 = row0 + stride0; + + a = *(double*)(row0); + row0 += stride1; + c = *(double*)(row0); + row0 += stride1; + e = *(double*)(row0); + + b = *(double*)(row1); + row1 += stride1; + d = *(double*)(row1); + row1 += stride1; + f = *(double*)(row1); + } + + result = (PyArrayObject*)PyArray_FromDims + (PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE); + if (PyArray_NDIM(vertices) == 2) { + size_t n = PyArray_DIM(vertices, 0); + char* vertex_in = PyArray_BYTES(vertices); + double* vertex_out = (double*)PyArray_DATA(result); + size_t stride0 = PyArray_STRIDE(vertices, 0); + size_t stride1 = PyArray_STRIDE(vertices, 1); + double x; + double y; + + for (size_t i = 0; i < n; ++i) { + x = *(double*)(vertex_in); + y = *(double*)(vertex_in + stride1); + + *vertex_out++ = a*x + c*y + e; + *vertex_out++ = b*x + d*y + f; + + vertex_in += stride0; + } + } else { + char* vertex_in = PyArray_BYTES(vertices); + double* vertex_out = (double*)PyArray_DATA(result); + size_t stride0 = PyArray_STRIDE(vertices, 0); + double x; + double y; + x = *(double*)(vertex_in); + y = *(double*)(vertex_in + stride0); + *vertex_out++ = a*x + c*y + e; + *vertex_out++ = b*x + d*y + f; + } + } catch (...) { + Py_XDECREF(vertices); + Py_XDECREF(transform); + Py_XDECREF(result); + } + + Py_XDECREF(vertices); + Py_XDECREF(transform); + + return Py::Object((PyObject*)result, true); +} + extern "C" DL_EXPORT(void) init_path(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-15 17:17:18
|
Revision: 4309 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4309&view=rev Author: mdboom Date: 2007-11-15 09:17:02 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Bugfixes (getting some examples to work again). Modified Paths: -------------- branches/transforms/examples/scatter_star_poly.py branches/transforms/lib/matplotlib/path.py branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/examples/scatter_star_poly.py =================================================================== --- branches/transforms/examples/scatter_star_poly.py 2007-11-15 17:08:39 UTC (rev 4308) +++ branches/transforms/examples/scatter_star_poly.py 2007-11-15 17:17:02 UTC (rev 4309) @@ -9,7 +9,7 @@ pylab.subplot(322) pylab.scatter(x,y,s=80,marker=(5,0)) -verts = zip([-1.,1.,1.],[-1.,-1.,1.]) +verts = zip([-1.,1.,1.,-1.],[-1.,-1.,1.,-1.]) pylab.subplot(323) pylab.scatter(x,y,s=80,marker=(verts,0)) # equivalent: Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-15 17:08:39 UTC (rev 4308) +++ branches/transforms/lib/matplotlib/path.py 2007-11-15 17:17:02 UTC (rev 4309) @@ -112,11 +112,11 @@ # MOVETO commands to the codes array accordingly. if mask is not ma.nomask: mask1d = ma.mask_or(mask[:, 0], mask[:, 1]) - vertices = ma.compress(npy.invert(mask1d), vertices, 0) if codes is None: codes = self.LINETO * npy.ones( - vertices.shape[0], self.code_type) + len(vertices), self.code_type) codes[0] = self.MOVETO + vertices = ma.compress(npy.invert(mask1d), vertices, 0) codes = npy.where(npy.concatenate((mask1d[-1:], mask1d[:-1])), self.MOVETO, codes) codes = ma.masked_array(codes, mask=mask1d).compressed() @@ -273,7 +273,7 @@ path = cls._unit_regular_polygons.get(numVertices) if path is None: theta = (2*npy.pi/numVertices * - npy.arange(numVertices).reshape((numVertices, 1))) + npy.arange(numVertices + 1).reshape((numVertices + 1, 1))) # This initial rotation is to make sure the polygon always # "points-up" theta += npy.pi / 2.0 @@ -293,11 +293,11 @@ path = cls._unit_regular_stars.get((numVertices, innerCircle)) if path is None: ns2 = numVertices * 2 - theta = (2*npy.pi/ns2 * npy.arange(ns2)) + theta = (2*npy.pi/ns2 * npy.arange(ns2 + 1)) # This initial rotation is to make sure the polygon always # "points-up" theta += npy.pi / 2.0 - r = npy.ones(ns2) + r = npy.ones(ns2 + 1) r[1::2] = innerCircle verts = npy.vstack((r*npy.cos(theta), r*npy.sin(theta))).transpose() path = Path(verts) Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-15 17:08:39 UTC (rev 4308) +++ branches/transforms/src/_backend_agg.cpp 2007-11-15 17:17:02 UTC (rev 4309) @@ -1044,21 +1044,22 @@ class PathListGenerator { const Py::SeqBase<Py::Object>& m_paths; + size_t m_npaths; public: typedef PathIterator path_iterator; inline PathListGenerator(const Py::SeqBase<Py::Object>& paths) : - m_paths(paths) { + m_paths(paths), m_npaths(paths.size()) { } inline size_t num_paths() const { - return m_paths.size(); + return m_npaths; } inline path_iterator operator()(size_t i) const { - return PathIterator(m_paths[i]); + return PathIterator(m_paths[i % m_npaths]); } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-15 18:35:32
|
Revision: 4314 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4314&view=rev Author: mdboom Date: 2007-11-15 10:35:30 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Fix colorbar drawing. Modified Paths: -------------- branches/transforms/lib/matplotlib/colorbar.py branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/lib/matplotlib/colorbar.py =================================================================== --- branches/transforms/lib/matplotlib/colorbar.py 2007-11-15 18:32:22 UTC (rev 4313) +++ branches/transforms/lib/matplotlib/colorbar.py 2007-11-15 18:35:30 UTC (rev 4314) @@ -205,6 +205,8 @@ self.outline = lines.Line2D(x, y, color=mpl.rcParams['axes.edgecolor'], linewidth=mpl.rcParams['axes.linewidth']) ax.add_artist(self.outline) + self.outline.set_clip_box(None) + self.outline.set_clip_path(None) c = mpl.rcParams['axes.facecolor'] self.patch = patches.Polygon(zip(x,y), edgecolor=c, facecolor=c, Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-15 18:32:22 UTC (rev 4313) +++ branches/transforms/src/_backend_agg.cpp 2007-11-15 18:35:30 UTC (rev 4314) @@ -466,9 +466,6 @@ typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; - rendererBase->reset_clipping(true); - theRasterizer->reset_clipping(); - args.verify_length(5, 6); Py::Object gc_obj = args[0]; @@ -525,7 +522,9 @@ unsigned strokeSize = scanlines.byte_size(); strokeCache = new agg::int8u[strokeSize]; // or any container scanlines.serialize(strokeCache); - + + theRasterizer->reset_clipping(); + rendererBase->reset_clipping(true); set_clipbox(gc.cliprect, rendererBase); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); @@ -885,6 +884,8 @@ GCAgg gc = GCAgg(gc_obj, dpi); facepair_t face = _get_rgba_face(face_obj, gc.alpha); + theRasterizer->reset_clipping(); + rendererBase->reset_clipping(true); set_clipbox(gc.cliprect, theRasterizer); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-15 18:39:38
|
Revision: 4318 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4318&view=rev Author: mdboom Date: 2007-11-15 10:39:36 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Merged revisions 4290-4317 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4290 | mdboom | 2007-11-14 14:43:31 -0500 (Wed, 14 Nov 2007) | 2 lines Fix flush callback in PNG file-like object writing. ........ r4315 | mdboom | 2007-11-15 13:36:27 -0500 (Thu, 15 Nov 2007) | 2 lines Clean up error message. ........ r4316 | mdboom | 2007-11-15 13:36:51 -0500 (Thu, 15 Nov 2007) | 2 lines Have backend_driver report times for each individual test. ........ r4317 | mdboom | 2007-11-15 13:37:57 -0500 (Thu, 15 Nov 2007) | 1 line Add tool to compare two different outputs of backend_driver.py ........ Modified Paths: -------------- branches/transforms/examples/backend_driver.py branches/transforms/src/_backend_agg.cpp Added Paths: ----------- branches/transforms/unit/compare_backend_driver_results.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4289 + /trunk/matplotlib:1-4317 Modified: branches/transforms/examples/backend_driver.py =================================================================== --- branches/transforms/examples/backend_driver.py 2007-11-15 18:37:57 UTC (rev 4317) +++ branches/transforms/examples/backend_driver.py 2007-11-15 18:39:36 UTC (rev 4318) @@ -123,9 +123,7 @@ os.system(' '.join(arglist)) def drive(backend, python=['python'], switches = []): - exclude = failbackend.get(backend, []) - switchstring = ' '.join(switches) # Strip off the format specifier, if any. if backend.startswith('cairo'): _backend = 'cairo' @@ -136,7 +134,7 @@ print '\tSkipping %s, known to fail on backend: %s'%backend continue - print '\tdriving %s %s' % (fname, switchstring) + print ('\tdriving %-40s' % (fname)), basename, ext = os.path.splitext(fname) outfile = basename + '_%s'%backend tmpfile_name = '_tmp_%s.py' % basename @@ -169,7 +167,10 @@ tmpfile.write('savefig("%s", dpi=150)' % outfile) tmpfile.close() + start_time = time.time() run(python + [tmpfile_name, switchstring]) + end_time = time.time() + print (end_time - start_time) #os.system('%s %s %s' % (python, tmpfile_name, switchstring)) os.remove(tmpfile_name) @@ -193,7 +194,8 @@ if not backends: backends = default_backends for backend in backends: - print 'testing %s' % backend + switchstring = ' '.join(switches) + print 'testing %s %s' % (backend, switchstring) t0 = time.time() drive(backend, python, switches) t1 = time.time() Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-15 18:37:57 UTC (rev 4317) +++ branches/transforms/src/_backend_agg.cpp 2007-11-15 18:39:36 UTC (rev 4318) @@ -1269,7 +1269,7 @@ static void flush_png_data(png_structp png_ptr) { PyObject* py_file_obj = (PyObject*)png_get_io_ptr(png_ptr); - PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "write"); + PyObject* flush_method = PyObject_GetAttrString(py_file_obj, "flush"); if (flush_method) { PyObject_CallFunction(flush_method, ""); } @@ -1297,7 +1297,7 @@ if ((fp = PyFile_AsFile(py_fileobj.ptr())) == NULL) { PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); if (!(write_method && PyCallable_Check(write_method))) - throw Py::TypeError("Object does not appear to be a Python file-like object"); + throw Py::TypeError("Object does not appear to be a path or a Python file-like object"); } } Copied: branches/transforms/unit/compare_backend_driver_results.py (from rev 4317, trunk/matplotlib/unit/compare_backend_driver_results.py) =================================================================== --- branches/transforms/unit/compare_backend_driver_results.py (rev 0) +++ branches/transforms/unit/compare_backend_driver_results.py 2007-11-15 18:39:36 UTC (rev 4318) @@ -0,0 +1,71 @@ +import sys + +def parse_results(filename): + results = {} + fd = open(filename, 'r') + section = "???" + for line in fd.readlines(): + line = line.strip() + if line.startswith("testing"): + section = line.split(" ", 1)[1] + results.setdefault(section, {}) + elif line.startswith("driving"): + driving, test, time = [x.strip() for x in line.split()] + time = float(time) + results[section][test] = time + fd.close() + return results + + +def check_results_are_compatible(results_a, results_b): + for section in results_a.keys(): + if not section in results_b: + raise RuntimeError("Backend '%s' in first set, but not in second" % section) + + for section in results_b.keys(): + if not section in results_a: + raise RuntimeError("Backend '%s' in second set, but not in first" % section) + + +def compare_results(results_a, results_b): + check_results_are_compatible(results_a, results_b) + + sections = results_a.keys() + sections.sort() + for section in results_a.keys(): + print "backend %s" % section + print " %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff") + print " " + '-' * 69 + deltas = [] + section_a = results_a[section] + section_b = results_b[section] + for test in section_a.keys(): + if test not in section_b: + deltas.append([None, None, section_a[test], None, test]) + else: + time_a = section_a[test] + time_b = section_b[test] + deltas.append([time_b / time_a, time_b - time_a, time_a, time_b, test]) + for test in section_b.keys(): + if test not in section_a: + deltas.append([None, None, None, section_b[test], test]) + + deltas.sort() + for diff, delta, time_a, time_b, test in deltas: + if diff is None: + if time_a is None: + print " %-40s ??? % 6.3f ??? ???" % (test, time_b) + else: + print " %-40s % 6.3f ??? ??? ???" % (test, time_a) + else: + print " %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100) + + +if __name__ == '__main__': + results_a_filename = sys.argv[-2] + results_b_filename = sys.argv[-1] + + results_a = parse_results(results_a_filename) + results_b = parse_results(results_b_filename) + + compare_results(results_a, results_b) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-15 21:14:03
|
Revision: 4324 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4324&view=rev Author: mdboom Date: 2007-11-15 13:13:52 -0800 (Thu, 15 Nov 2007) Log Message: ----------- Speed up auto-legend. Modified Paths: -------------- branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/patches.py branches/transforms/lib/matplotlib/transforms.py branches/transforms/src/_path.cpp Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-11-15 21:12:54 UTC (rev 4323) +++ branches/transforms/lib/matplotlib/legend.py 2007-11-15 21:13:52 UTC (rev 4324) @@ -340,29 +340,26 @@ bboxes = [] lines = [] - inv = ax.transAxes.inverted().transform + inverse_transform = ax.transAxes.inverted() for handle in ax.lines: assert isinstance(handle, Line2D) data = handle.get_xydata() trans = handle.get_transform() tdata = trans.transform(data) - averts = inv(tdata) + averts = inverse_transform.transform(tdata) lines.append(averts) for handle in ax.patches: assert isinstance(handle, Patch) - path = handle.get_path() - trans = handle.get_transform() - tpath = trans.transform_path(path) - tverts = tpath.vertices - averts = inv(tverts) + if isinstance(handle, Rectangle): + transform = handle.get_data_transform() + inverse_transform + bboxes.append(handle._bbox.transformed(transform)) + else: + transform = handle.get_transform() + inverse_transform + bboxes.append(handle.get_path().get_extents(transform)) - bbox = Bbox.unit() - bbox.update_from_data_xy(averts, True) - bboxes.append(bbox) - return [vertices, bboxes, lines] def draw_frame(self, b): Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-11-15 21:12:54 UTC (rev 4323) +++ branches/transforms/lib/matplotlib/patches.py 2007-11-15 21:13:52 UTC (rev 4324) @@ -103,6 +103,9 @@ self.set_figure(other.get_figure()) self.set_alpha(other.get_alpha()) + def get_extents(self): + return self.get_path().get_extents(self.get_transform()) + def get_transform(self): return self._combined_transform Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-11-15 21:12:54 UTC (rev 4323) +++ branches/transforms/lib/matplotlib/transforms.py 2007-11-15 21:13:52 UTC (rev 4324) @@ -32,6 +32,7 @@ import cbook from path import Path +from _path import count_bboxes_overlapping_bbox DEBUG = False if DEBUG: @@ -93,16 +94,16 @@ Invalidate this transform node and all of its parents. Should be called anytime the transform changes. """ - # Shortcut: If self is already invalid, that means its parents - # are as well, so we don't need to do anything. - if self._invalid or not len(self._parents): - return - # If we are an affine transform being changed, we can set the # flag to INVALID_AFFINE_ONLY value = ((self.is_affine or self.is_bbox) and self.INVALID_AFFINE or self.INVALID) + + # Shortcut: If self is already invalid, that means its parents + # are as well, so we don't need to do anything. + if self._invalid == value or not len(self._parents): + return # Invalidate all ancestors of self using pseudo-recursion. parent = None @@ -194,10 +195,12 @@ read-only access to its data. """ is_bbox = True - - def __init__(self): - TransformNode.__init__(self) + #* Redundant: Removed for performance + # + # def __init__(self): + # TransformNode.__init__(self) + if DEBUG: def _check(points): if ma.isMaskedArray(points): @@ -896,10 +899,12 @@ # True if this transform is separable in the x- and y- dimensions. is_separable = False - - def __init__(self): - TransformNode.__init__(self) + #* Redundant: Removed for performance + # + # def __init__(self): + # TransformNode.__init__(self) + def __add__(self, other): """ Composes two transforms together such that self is followed by other. @@ -1171,8 +1176,10 @@ input_dims = 2 output_dims = 2 - def __init__(self): - AffineBase.__init__(self) + #* Redundant: Removed for performance + # + # def __init__(self): + # Affine2DBase.__init__(self) def frozen(self): return Affine2D(self.get_matrix().copy()) Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-11-15 21:12:54 UTC (rev 4323) +++ branches/transforms/src/_path.cpp 2007-11-15 21:13:52 UTC (rev 4324) @@ -41,6 +41,8 @@ "clip_path_to_rect(path, bbox, inside)"); add_varargs_method("affine_transform", &_path_module::affine_transform, "affine_transform(vertices, transform)"); + add_varargs_method("count_bboxes_overlapping_bbox", &_path_module::count_bboxes_overlapping_bbox, + "count_bboxes_overlapping_bbox(bbox, bboxes)"); initialize("Helper functions for paths"); } @@ -57,6 +59,7 @@ Py::Object path_in_path(const Py::Tuple& args); Py::Object clip_path_to_rect(const Py::Tuple& args); Py::Object affine_transform(const Py::Tuple& args); + Py::Object count_bboxes_overlapping_bbox(const Py::Tuple& args); }; // @@ -736,6 +739,46 @@ return Py::Object((PyObject*)result, true); } +Py::Object _path_module::count_bboxes_overlapping_bbox(const Py::Tuple& args) { + args.verify_length(2); + + Py::Object bbox = args[0]; + Py::SeqBase<Py::Object> bboxes = args[1]; + + double ax0, ay0, ax1, ay1; + double bx0, by0, bx1, by1; + long count = 0; + + if (py_convert_bbox(bbox.ptr(), ax0, ay0, ax1, ay1)) { + if (ax1 < ax0) + std::swap(ax0, ax1); + if (ay1 < ay0) + std::swap(ay0, ay1); + + size_t num_bboxes = bboxes.size(); + for (size_t i = 0; i < num_bboxes; ++i) { + Py::Object bbox_b = bboxes[i]; + if (py_convert_bbox(bbox_b.ptr(), bx0, by0, bx1, by1)) { + if (bx1 < bx0) + std::swap(bx0, bx1); + if (by1 < by0) + std::swap(by0, by1); + if (not ((bx1 <= ax0) or + (by1 <= ay0) or + (bx0 >= ax1) or + (by0 >= ay1))) + ++count; + } else { + throw Py::ValueError("Non-bbox object in bboxes list"); + } + } + } else { + throw Py::ValueError("First argument to count_bboxes_overlapping_bbox must be a Bbox object."); + } + + return Py::Int(count); +} + extern "C" DL_EXPORT(void) init_path(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-16 13:28:47
|
Revision: 4330 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4330&view=rev Author: mdboom Date: 2007-11-16 05:28:44 -0800 (Fri, 16 Nov 2007) Log Message: ----------- Merged revisions 4318-4329 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4325 | dsdale | 2007-11-15 16:23:27 -0500 (Thu, 15 Nov 2007) | 4 lines added npy.seterr(invalid='ignore') to beginning of axes.py, to silence repeated warnings created by finding extrema of arrays containing nans (discovered during calls to errorbar) ........ r4328 | efiring | 2007-11-16 02:47:51 -0500 (Fri, 16 Nov 2007) | 2 lines ScalarMappable.to_rgba can return uint8 instead of float64 ........ r4329 | dsdale | 2007-11-16 08:16:12 -0500 (Fri, 16 Nov 2007) | 2 lines removed numpy.seterr(invalid='ignore') from axes.py ........ Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/cm.py branches/transforms/lib/matplotlib/colors.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4317 + /trunk/matplotlib:1-4329 Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-16 13:16:12 UTC (rev 4329) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-16 13:28:44 UTC (rev 4330) @@ -2597,7 +2597,6 @@ self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs) - if not iterable(x): x = [x] if not iterable(ymin): ymin = [ymin] if not iterable(ymax): ymax = [ymax] Modified: branches/transforms/lib/matplotlib/cm.py =================================================================== --- branches/transforms/lib/matplotlib/cm.py 2007-11-16 13:16:12 UTC (rev 4329) +++ branches/transforms/lib/matplotlib/cm.py 2007-11-16 13:28:44 UTC (rev 4330) @@ -45,14 +45,18 @@ 'set the colorbar image and axes associated with mappable' self.colorbar = im, ax - def to_rgba(self, x, alpha=1.0): + def to_rgba(self, x, alpha=1.0, bytes=False): '''Return a normalized rgba array corresponding to x. If x is already an rgb or rgba array, return it unchanged. ''' - if hasattr(x, 'shape') and len(x.shape)>2: return x + try: + if x.ndim == 3 and (x.shape[2] == 3 or x.shape[2] == 4): + return x + except AttributeError: + pass x = ma.asarray(x) x = self.norm(x) - x = self.cmap(x, alpha) + x = self.cmap(x, alpha=alpha, bytes=bytes) return x def set_array(self, A): Modified: branches/transforms/lib/matplotlib/colors.py =================================================================== --- branches/transforms/lib/matplotlib/colors.py 2007-11-16 13:16:12 UTC (rev 4329) +++ branches/transforms/lib/matplotlib/colors.py 2007-11-16 13:28:44 UTC (rev 4330) @@ -407,7 +407,7 @@ self._isinit = False - def __call__(self, X, alpha=1.0): + def __call__(self, X, alpha=1.0, bytes=False): """ X is either a scalar or an array (of any dimension). If scalar, a tuple of rgba values is returned, otherwise @@ -416,6 +416,8 @@ If they are floating point, then they must be in the interval (0.0, 1.0). Alpha must be a scalar. + If bytes is False, the rgba values will be floats on a + 0-1 scale; if True, they will be uint8, 0-255. """ if not self._isinit: self._init() @@ -440,7 +442,11 @@ npy.putmask(xa, xa<0, self._i_under) if mask_bad is not None and mask_bad.shape == xa.shape: npy.putmask(xa, mask_bad, self._i_bad) - rgba = self._lut[xa] + if bytes: + lut = (self._lut * 255).astype(npy.uint8) + else: + lut = self._lut + rgba = lut[xa] if vtype == 'scalar': rgba = tuple(rgba[0,:]) return rgba This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-16 15:54:04
|
Revision: 4333 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4333&view=rev Author: mdboom Date: 2007-11-16 07:53:57 -0800 (Fri, 16 Nov 2007) Log Message: ----------- Upgrade to Agg 2.4; Stop building Agg SWIG wrappers and remove small dependency on them. Modified Paths: -------------- branches/transforms/lib/matplotlib/mpl.py branches/transforms/setup.py branches/transforms/setupext.py branches/transforms/src/_backend_agg.cpp branches/transforms/src/_backend_agg.h branches/transforms/src/_image.cpp Added Paths: ----------- branches/transforms/agg24/ branches/transforms/agg24/include/ branches/transforms/agg24/include/agg_alpha_mask_u8.h branches/transforms/agg24/include/agg_arc.h branches/transforms/agg24/include/agg_array.h branches/transforms/agg24/include/agg_arrowhead.h branches/transforms/agg24/include/agg_basics.h branches/transforms/agg24/include/agg_bezier_arc.h branches/transforms/agg24/include/agg_bitset_iterator.h branches/transforms/agg24/include/agg_blur.h branches/transforms/agg24/include/agg_bounding_rect.h branches/transforms/agg24/include/agg_bspline.h branches/transforms/agg24/include/agg_clip_liang_barsky.h branches/transforms/agg24/include/agg_color_gray.h branches/transforms/agg24/include/agg_color_rgba.h branches/transforms/agg24/include/agg_config.h branches/transforms/agg24/include/agg_conv_adaptor_vcgen.h branches/transforms/agg24/include/agg_conv_adaptor_vpgen.h branches/transforms/agg24/include/agg_conv_bspline.h branches/transforms/agg24/include/agg_conv_clip_polygon.h branches/transforms/agg24/include/agg_conv_clip_polyline.h branches/transforms/agg24/include/agg_conv_close_polygon.h branches/transforms/agg24/include/agg_conv_concat.h branches/transforms/agg24/include/agg_conv_contour.h branches/transforms/agg24/include/agg_conv_curve.h branches/transforms/agg24/include/agg_conv_dash.h branches/transforms/agg24/include/agg_conv_gpc.h branches/transforms/agg24/include/agg_conv_marker.h branches/transforms/agg24/include/agg_conv_marker_adaptor.h branches/transforms/agg24/include/agg_conv_segmentator.h branches/transforms/agg24/include/agg_conv_shorten_path.h branches/transforms/agg24/include/agg_conv_smooth_poly1.h branches/transforms/agg24/include/agg_conv_stroke.h branches/transforms/agg24/include/agg_conv_transform.h branches/transforms/agg24/include/agg_conv_unclose_polygon.h branches/transforms/agg24/include/agg_curves.h branches/transforms/agg24/include/agg_dda_line.h branches/transforms/agg24/include/agg_ellipse.h branches/transforms/agg24/include/agg_ellipse_bresenham.h branches/transforms/agg24/include/agg_embedded_raster_fonts.h branches/transforms/agg24/include/agg_font_cache_manager.h branches/transforms/agg24/include/agg_gamma_functions.h branches/transforms/agg24/include/agg_gamma_lut.h branches/transforms/agg24/include/agg_glyph_raster_bin.h branches/transforms/agg24/include/agg_gradient_lut.h branches/transforms/agg24/include/agg_gsv_text.h branches/transforms/agg24/include/agg_image_accessors.h branches/transforms/agg24/include/agg_image_filters.h branches/transforms/agg24/include/agg_line_aa_basics.h branches/transforms/agg24/include/agg_math.h branches/transforms/agg24/include/agg_math_stroke.h branches/transforms/agg24/include/agg_path_length.h branches/transforms/agg24/include/agg_path_storage.h branches/transforms/agg24/include/agg_path_storage_integer.h branches/transforms/agg24/include/agg_pattern_filters_rgba.h branches/transforms/agg24/include/agg_pixfmt_amask_adaptor.h branches/transforms/agg24/include/agg_pixfmt_gray.h branches/transforms/agg24/include/agg_pixfmt_rgb.h branches/transforms/agg24/include/agg_pixfmt_rgb_packed.h branches/transforms/agg24/include/agg_pixfmt_rgba.h branches/transforms/agg24/include/agg_pixfmt_transposer.h branches/transforms/agg24/include/agg_rasterizer_cells_aa.h branches/transforms/agg24/include/agg_rasterizer_compound_aa.h branches/transforms/agg24/include/agg_rasterizer_outline.h branches/transforms/agg24/include/agg_rasterizer_outline_aa.h branches/transforms/agg24/include/agg_rasterizer_scanline_aa.h branches/transforms/agg24/include/agg_rasterizer_sl_clip.h branches/transforms/agg24/include/agg_renderer_base.h branches/transforms/agg24/include/agg_renderer_markers.h branches/transforms/agg24/include/agg_renderer_mclip.h branches/transforms/agg24/include/agg_renderer_outline_aa.h branches/transforms/agg24/include/agg_renderer_outline_image.h branches/transforms/agg24/include/agg_renderer_primitives.h branches/transforms/agg24/include/agg_renderer_raster_text.h branches/transforms/agg24/include/agg_renderer_scanline.h branches/transforms/agg24/include/agg_rendering_buffer.h branches/transforms/agg24/include/agg_rendering_buffer_dynarow.h branches/transforms/agg24/include/agg_rounded_rect.h branches/transforms/agg24/include/agg_scanline_bin.h branches/transforms/agg24/include/agg_scanline_boolean_algebra.h branches/transforms/agg24/include/agg_scanline_p.h branches/transforms/agg24/include/agg_scanline_storage_aa.h branches/transforms/agg24/include/agg_scanline_storage_bin.h branches/transforms/agg24/include/agg_scanline_u.h branches/transforms/agg24/include/agg_shorten_path.h branches/transforms/agg24/include/agg_simul_eq.h branches/transforms/agg24/include/agg_span_allocator.h branches/transforms/agg24/include/agg_span_converter.h branches/transforms/agg24/include/agg_span_gouraud.h branches/transforms/agg24/include/agg_span_gouraud_gray.h branches/transforms/agg24/include/agg_span_gouraud_rgba.h branches/transforms/agg24/include/agg_span_gradient.h branches/transforms/agg24/include/agg_span_gradient_alpha.h branches/transforms/agg24/include/agg_span_image_filter.h branches/transforms/agg24/include/agg_span_image_filter_gray.h branches/transforms/agg24/include/agg_span_image_filter_rgb.h branches/transforms/agg24/include/agg_span_image_filter_rgba.h branches/transforms/agg24/include/agg_span_interpolator_adaptor.h branches/transforms/agg24/include/agg_span_interpolator_linear.h branches/transforms/agg24/include/agg_span_interpolator_persp.h branches/transforms/agg24/include/agg_span_interpolator_trans.h branches/transforms/agg24/include/agg_span_pattern_gray.h branches/transforms/agg24/include/agg_span_pattern_rgb.h branches/transforms/agg24/include/agg_span_pattern_rgba.h branches/transforms/agg24/include/agg_span_solid.h branches/transforms/agg24/include/agg_span_subdiv_adaptor.h branches/transforms/agg24/include/agg_trans_affine.h branches/transforms/agg24/include/agg_trans_bilinear.h branches/transforms/agg24/include/agg_trans_double_path.h branches/transforms/agg24/include/agg_trans_perspective.h branches/transforms/agg24/include/agg_trans_single_path.h branches/transforms/agg24/include/agg_trans_viewport.h branches/transforms/agg24/include/agg_trans_warp_magnifier.h branches/transforms/agg24/include/agg_vcgen_bspline.h branches/transforms/agg24/include/agg_vcgen_contour.h branches/transforms/agg24/include/agg_vcgen_dash.h branches/transforms/agg24/include/agg_vcgen_markers_term.h branches/transforms/agg24/include/agg_vcgen_smooth_poly1.h branches/transforms/agg24/include/agg_vcgen_stroke.h branches/transforms/agg24/include/agg_vcgen_vertex_sequence.h branches/transforms/agg24/include/agg_vertex_sequence.h branches/transforms/agg24/include/agg_vpgen_clip_polygon.h branches/transforms/agg24/include/agg_vpgen_clip_polyline.h branches/transforms/agg24/include/agg_vpgen_segmentator.h branches/transforms/agg24/include/ctrl/ branches/transforms/agg24/include/ctrl/agg_bezier_ctrl.h branches/transforms/agg24/include/ctrl/agg_cbox_ctrl.h branches/transforms/agg24/include/ctrl/agg_ctrl.h branches/transforms/agg24/include/ctrl/agg_gamma_ctrl.h branches/transforms/agg24/include/ctrl/agg_gamma_spline.h branches/transforms/agg24/include/ctrl/agg_polygon_ctrl.h branches/transforms/agg24/include/ctrl/agg_rbox_ctrl.h branches/transforms/agg24/include/ctrl/agg_scale_ctrl.h branches/transforms/agg24/include/ctrl/agg_slider_ctrl.h branches/transforms/agg24/include/ctrl/agg_spline_ctrl.h branches/transforms/agg24/include/platform/ branches/transforms/agg24/include/platform/agg_platform_support.h branches/transforms/agg24/include/platform/mac/ branches/transforms/agg24/include/platform/mac/agg_mac_pmap.h branches/transforms/agg24/include/platform/win32/ branches/transforms/agg24/include/platform/win32/agg_win32_bmp.h branches/transforms/agg24/include/util/ branches/transforms/agg24/include/util/agg_color_conv.h branches/transforms/agg24/include/util/agg_color_conv_rgb16.h branches/transforms/agg24/include/util/agg_color_conv_rgb8.h branches/transforms/agg24/src/ branches/transforms/agg24/src/ChangeLog branches/transforms/agg24/src/agg_arc.cpp branches/transforms/agg24/src/agg_arrowhead.cpp branches/transforms/agg24/src/agg_bezier_arc.cpp branches/transforms/agg24/src/agg_bspline.cpp branches/transforms/agg24/src/agg_curves.cpp branches/transforms/agg24/src/agg_embedded_raster_fonts.cpp branches/transforms/agg24/src/agg_gsv_text.cpp branches/transforms/agg24/src/agg_image_filters.cpp branches/transforms/agg24/src/agg_line_aa_basics.cpp branches/transforms/agg24/src/agg_line_profile_aa.cpp branches/transforms/agg24/src/agg_rounded_rect.cpp branches/transforms/agg24/src/agg_sqrt_tables.cpp branches/transforms/agg24/src/agg_trans_affine.cpp branches/transforms/agg24/src/agg_trans_double_path.cpp branches/transforms/agg24/src/agg_trans_single_path.cpp branches/transforms/agg24/src/agg_trans_warp_magnifier.cpp branches/transforms/agg24/src/agg_vcgen_bspline.cpp branches/transforms/agg24/src/agg_vcgen_contour.cpp branches/transforms/agg24/src/agg_vcgen_dash.cpp branches/transforms/agg24/src/agg_vcgen_markers_term.cpp branches/transforms/agg24/src/agg_vcgen_smooth_poly1.cpp branches/transforms/agg24/src/agg_vcgen_stroke.cpp branches/transforms/agg24/src/agg_vpgen_clip_polygon.cpp branches/transforms/agg24/src/agg_vpgen_clip_polyline.cpp branches/transforms/agg24/src/agg_vpgen_segmentator.cpp branches/transforms/agg24/src/authors branches/transforms/agg24/src/copying branches/transforms/agg24/src/ctrl/ branches/transforms/agg24/src/ctrl/agg_bezier_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_cbox_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_gamma_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_gamma_spline.cpp branches/transforms/agg24/src/ctrl/agg_polygon_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_rbox_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_scale_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_slider_ctrl.cpp branches/transforms/agg24/src/ctrl/agg_spline_ctrl.cpp branches/transforms/agg24/src/platform/ branches/transforms/agg24/src/platform/AmigaOS/ branches/transforms/agg24/src/platform/AmigaOS/agg_platform_support.cpp branches/transforms/agg24/src/platform/BeOS/ branches/transforms/agg24/src/platform/BeOS/agg_platform_support.cpp branches/transforms/agg24/src/platform/X11/ branches/transforms/agg24/src/platform/X11/agg_platform_support.cpp branches/transforms/agg24/src/platform/mac/ branches/transforms/agg24/src/platform/mac/agg_mac_pmap.cpp branches/transforms/agg24/src/platform/mac/agg_platform_support.cpp branches/transforms/agg24/src/platform/sdl/ branches/transforms/agg24/src/platform/sdl/agg_platform_support.cpp branches/transforms/agg24/src/platform/win32/ branches/transforms/agg24/src/platform/win32/agg_platform_support.cpp branches/transforms/agg24/src/platform/win32/agg_win32_bmp.cpp Removed Paths: ------------- branches/transforms/agg23/ Added: branches/transforms/agg24/include/agg_alpha_mask_u8.h =================================================================== --- branches/transforms/agg24/include/agg_alpha_mask_u8.h (rev 0) +++ branches/transforms/agg24/include/agg_alpha_mask_u8.h 2007-11-16 15:53:57 UTC (rev 4333) @@ -0,0 +1,499 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mc...@an... +// mcs...@ya... +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// scanline_u8 class +// +//---------------------------------------------------------------------------- +#ifndef AGG_ALPHA_MASK_U8_INCLUDED +#define AGG_ALPHA_MASK_U8_INCLUDED + +#include <string.h> +#include "agg_basics.h" +#include "agg_rendering_buffer.h" + +namespace agg +{ + //===================================================one_component_mask_u8 + struct one_component_mask_u8 + { + static unsigned calculate(const int8u* p) { return *p; } + }; + + + //=====================================================rgb_to_gray_mask_u8 + template<unsigned R, unsigned G, unsigned B> + struct rgb_to_gray_mask_u8 + { + static unsigned calculate(const int8u* p) + { + return (p[R]*77 + p[G]*150 + p[B]*29) >> 8; + } + }; + + //==========================================================alpha_mask_u8 + template<unsigned Step=1, unsigned Offset=0, class MaskF=one_component_mask_u8> + class alpha_mask_u8 + { + public: + typedef int8u cover_type; + typedef alpha_mask_u8<Step, Offset, MaskF> self_type; + enum cover_scale_e + { + cover_shift = 8, + cover_none = 0, + cover_full = 255 + }; + + alpha_mask_u8() : m_rbuf(0) {} + explicit alpha_mask_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} + + void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } + + MaskF& mask_function() { return m_mask_function; } + const MaskF& mask_function() const { return m_mask_function; } + + + //-------------------------------------------------------------------- + cover_type pixel(int x, int y) const + { + if(x >= 0 && y >= 0 && + x < (int)m_rbuf->width() && + y < (int)m_rbuf->height()) + { + return (cover_type)m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset); + } + return 0; + } + + //-------------------------------------------------------------------- + cover_type combine_pixel(int x, int y, cover_type val) const + { + if(x >= 0 && y >= 0 && + x < (int)m_rbuf->width() && + y < (int)m_rbuf->height()) + { + return (cover_type)((cover_full + val * + m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset)) >> + cover_shift); + } + return 0; + } + + + //-------------------------------------------------------------------- + void fill_hspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(y < 0 || y > ymax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(x < 0) + { + count += x; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -x * sizeof(cover_type)); + covers -= x; + x = 0; + } + + if(x + count > xmax) + { + int rest = x + count - xmax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers++ = (cover_type)m_mask_function.calculate(mask); + mask += Step; + } + while(--count); + } + + + //-------------------------------------------------------------------- + void combine_hspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(y < 0 || y > ymax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(x < 0) + { + count += x; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -x * sizeof(cover_type)); + covers -= x; + x = 0; + } + + if(x + count > xmax) + { + int rest = x + count - xmax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers = (cover_type)((cover_full + (*covers) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++covers; + mask += Step; + } + while(--count); + } + + //-------------------------------------------------------------------- + void fill_vspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(x < 0 || x > xmax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(y < 0) + { + count += y; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -y * sizeof(cover_type)); + covers -= y; + y = 0; + } + + if(y + count > ymax) + { + int rest = y + count - ymax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers++ = (cover_type)m_mask_function.calculate(mask); + mask += m_rbuf->stride(); + } + while(--count); + } + + //-------------------------------------------------------------------- + void combine_vspan(int x, int y, cover_type* dst, int num_pix) const + { + int xmax = m_rbuf->width() - 1; + int ymax = m_rbuf->height() - 1; + + int count = num_pix; + cover_type* covers = dst; + + if(x < 0 || x > xmax) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + + if(y < 0) + { + count += y; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers, 0, -y * sizeof(cover_type)); + covers -= y; + y = 0; + } + + if(y + count > ymax) + { + int rest = y + count - ymax - 1; + count -= rest; + if(count <= 0) + { + memset(dst, 0, num_pix * sizeof(cover_type)); + return; + } + memset(covers + count, 0, rest * sizeof(cover_type)); + } + + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *covers = (cover_type)((cover_full + (*covers) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++covers; + mask += m_rbuf->stride(); + } + while(--count); + } + + + private: + alpha_mask_u8(const self_type&); + const self_type& operator = (const self_type&); + + rendering_buffer* m_rbuf; + MaskF m_mask_function; + }; + + + typedef alpha_mask_u8<1, 0> alpha_mask_gray8; //----alpha_mask_gray8 + + typedef alpha_mask_u8<3, 0> alpha_mask_rgb24r; //----alpha_mask_rgb24r + typedef alpha_mask_u8<3, 1> alpha_mask_rgb24g; //----alpha_mask_rgb24g + typedef alpha_mask_u8<3, 2> alpha_mask_rgb24b; //----alpha_mask_rgb24b + + typedef alpha_mask_u8<3, 2> alpha_mask_bgr24r; //----alpha_mask_bgr24r + typedef alpha_mask_u8<3, 1> alpha_mask_bgr24g; //----alpha_mask_bgr24g + typedef alpha_mask_u8<3, 0> alpha_mask_bgr24b; //----alpha_mask_bgr24b + + typedef alpha_mask_u8<4, 0> alpha_mask_rgba32r; //----alpha_mask_rgba32r + typedef alpha_mask_u8<4, 1> alpha_mask_rgba32g; //----alpha_mask_rgba32g + typedef alpha_mask_u8<4, 2> alpha_mask_rgba32b; //----alpha_mask_rgba32b + typedef alpha_mask_u8<4, 3> alpha_mask_rgba32a; //----alpha_mask_rgba32a + + typedef alpha_mask_u8<4, 1> alpha_mask_argb32r; //----alpha_mask_argb32r + typedef alpha_mask_u8<4, 2> alpha_mask_argb32g; //----alpha_mask_argb32g + typedef alpha_mask_u8<4, 3> alpha_mask_argb32b; //----alpha_mask_argb32b + typedef alpha_mask_u8<4, 0> alpha_mask_argb32a; //----alpha_mask_argb32a + + typedef alpha_mask_u8<4, 2> alpha_mask_bgra32r; //----alpha_mask_bgra32r + typedef alpha_mask_u8<4, 1> alpha_mask_bgra32g; //----alpha_mask_bgra32g + typedef alpha_mask_u8<4, 0> alpha_mask_bgra32b; //----alpha_mask_bgra32b + typedef alpha_mask_u8<4, 3> alpha_mask_bgra32a; //----alpha_mask_bgra32a + + typedef alpha_mask_u8<4, 3> alpha_mask_abgr32r; //----alpha_mask_abgr32r + typedef alpha_mask_u8<4, 2> alpha_mask_abgr32g; //----alpha_mask_abgr32g + typedef alpha_mask_u8<4, 1> alpha_mask_abgr32b; //----alpha_mask_abgr32b + typedef alpha_mask_u8<4, 0> alpha_mask_abgr32a; //----alpha_mask_abgr32a + + typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgb24gray; //----alpha_mask_rgb24gray + typedef alpha_mask_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgr24gray; //----alpha_mask_bgr24gray + typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_rgba32gray; //----alpha_mask_rgba32gray + typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > alpha_mask_argb32gray; //----alpha_mask_argb32gray + typedef alpha_mask_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_bgra32gray; //----alpha_mask_bgra32gray + typedef alpha_mask_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > alpha_mask_abgr32gray; //----alpha_mask_abgr32gray + + + + //==========================================================amask_no_clip_u8 + template<unsigned Step=1, unsigned Offset=0, class MaskF=one_component_mask_u8> + class amask_no_clip_u8 + { + public: + typedef int8u cover_type; + typedef amask_no_clip_u8<Step, Offset, MaskF> self_type; + enum cover_scale_e + { + cover_shift = 8, + cover_none = 0, + cover_full = 255 + }; + + amask_no_clip_u8() : m_rbuf(0) {} + explicit amask_no_clip_u8(rendering_buffer& rbuf) : m_rbuf(&rbuf) {} + + void attach(rendering_buffer& rbuf) { m_rbuf = &rbuf; } + + MaskF& mask_function() { return m_mask_function; } + const MaskF& mask_function() const { return m_mask_function; } + + + //-------------------------------------------------------------------- + cover_type pixel(int x, int y) const + { + return (cover_type)m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset); + } + + + //-------------------------------------------------------------------- + cover_type combine_pixel(int x, int y, cover_type val) const + { + return (cover_type)((cover_full + val * + m_mask_function.calculate( + m_rbuf->row_ptr(y) + x * Step + Offset)) >> + cover_shift); + } + + + //-------------------------------------------------------------------- + void fill_hspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst++ = (cover_type)m_mask_function.calculate(mask); + mask += Step; + } + while(--num_pix); + } + + + + //-------------------------------------------------------------------- + void combine_hspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst = (cover_type)((cover_full + (*dst) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++dst; + mask += Step; + } + while(--num_pix); + } + + + //-------------------------------------------------------------------- + void fill_vspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst++ = (cover_type)m_mask_function.calculate(mask); + mask += m_rbuf->stride(); + } + while(--num_pix); + } + + + //-------------------------------------------------------------------- + void combine_vspan(int x, int y, cover_type* dst, int num_pix) const + { + const int8u* mask = m_rbuf->row_ptr(y) + x * Step + Offset; + do + { + *dst = (cover_type)((cover_full + (*dst) * + m_mask_function.calculate(mask)) >> + cover_shift); + ++dst; + mask += m_rbuf->stride(); + } + while(--num_pix); + } + + private: + amask_no_clip_u8(const self_type&); + const self_type& operator = (const self_type&); + + rendering_buffer* m_rbuf; + MaskF m_mask_function; + }; + + + typedef amask_no_clip_u8<1, 0> amask_no_clip_gray8; //----amask_no_clip_gray8 + + typedef amask_no_clip_u8<3, 0> amask_no_clip_rgb24r; //----amask_no_clip_rgb24r + typedef amask_no_clip_u8<3, 1> amask_no_clip_rgb24g; //----amask_no_clip_rgb24g + typedef amask_no_clip_u8<3, 2> amask_no_clip_rgb24b; //----amask_no_clip_rgb24b + + typedef amask_no_clip_u8<3, 2> amask_no_clip_bgr24r; //----amask_no_clip_bgr24r + typedef amask_no_clip_u8<3, 1> amask_no_clip_bgr24g; //----amask_no_clip_bgr24g + typedef amask_no_clip_u8<3, 0> amask_no_clip_bgr24b; //----amask_no_clip_bgr24b + + typedef amask_no_clip_u8<4, 0> amask_no_clip_rgba32r; //----amask_no_clip_rgba32r + typedef amask_no_clip_u8<4, 1> amask_no_clip_rgba32g; //----amask_no_clip_rgba32g + typedef amask_no_clip_u8<4, 2> amask_no_clip_rgba32b; //----amask_no_clip_rgba32b + typedef amask_no_clip_u8<4, 3> amask_no_clip_rgba32a; //----amask_no_clip_rgba32a + + typedef amask_no_clip_u8<4, 1> amask_no_clip_argb32r; //----amask_no_clip_argb32r + typedef amask_no_clip_u8<4, 2> amask_no_clip_argb32g; //----amask_no_clip_argb32g + typedef amask_no_clip_u8<4, 3> amask_no_clip_argb32b; //----amask_no_clip_argb32b + typedef amask_no_clip_u8<4, 0> amask_no_clip_argb32a; //----amask_no_clip_argb32a + + typedef amask_no_clip_u8<4, 2> amask_no_clip_bgra32r; //----amask_no_clip_bgra32r + typedef amask_no_clip_u8<4, 1> amask_no_clip_bgra32g; //----amask_no_clip_bgra32g + typedef amask_no_clip_u8<4, 0> amask_no_clip_bgra32b; //----amask_no_clip_bgra32b + typedef amask_no_clip_u8<4, 3> amask_no_clip_bgra32a; //----amask_no_clip_bgra32a + + typedef amask_no_clip_u8<4, 3> amask_no_clip_abgr32r; //----amask_no_clip_abgr32r + typedef amask_no_clip_u8<4, 2> amask_no_clip_abgr32g; //----amask_no_clip_abgr32g + typedef amask_no_clip_u8<4, 1> amask_no_clip_abgr32b; //----amask_no_clip_abgr32b + typedef amask_no_clip_u8<4, 0> amask_no_clip_abgr32a; //----amask_no_clip_abgr32a + + typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgb24gray; //----amask_no_clip_rgb24gray + typedef amask_no_clip_u8<3, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgr24gray; //----amask_no_clip_bgr24gray + typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_rgba32gray; //----amask_no_clip_rgba32gray + typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<0, 1, 2> > amask_no_clip_argb32gray; //----amask_no_clip_argb32gray + typedef amask_no_clip_u8<4, 0, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_bgra32gray; //----amask_no_clip_bgra32gray + typedef amask_no_clip_u8<4, 1, rgb_to_gray_mask_u8<2, 1, 0> > amask_no_clip_abgr32gray; //----amask_no_clip_abgr32gray + + +} + + + +#endif Added: branches/transforms/agg24/include/agg_arc.h =================================================================== --- branches/transforms/agg24/include/agg_arc.h (rev 0) +++ branches/transforms/agg24/include/agg_arc.h 2007-11-16 15:53:57 UTC (rev 4333) @@ -0,0 +1,74 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mc...@an... +// mcs...@ya... +// http://www.antigrain.com +//---------------------------------------------------------------------------- +// +// Arc vertex generator +// +//---------------------------------------------------------------------------- + +#ifndef AGG_ARC_INCLUDED +#define AGG_ARC_INCLUDED + +#include <math.h> +#include "agg_basics.h" + +namespace agg +{ + + //=====================================================================arc + // + // See Implementation agg_arc.cpp + // + class arc + { + public: + arc() : m_scale(1.0), m_initialized(false) {} + arc(double x, double y, + double rx, double ry, + double a1, double a2, + bool ccw=true); + + void init(double x, double y, + double rx, double ry, + double a1, double a2, + bool ccw=true); + + void approximation_scale(double s); + double approximation_scale() const { return m_scale; } + + void rewind(unsigned); + unsigned vertex(double* x, double* y); + + private: + void normalize(double a1, double a2, bool ccw); + + double m_x; + double m_y; + double m_rx; + double m_ry; + double m_angle; + double m_start; + double m_end; + double m_scale; + double m_da; + bool m_ccw; + bool m_initialized; + unsigned m_path_cmd; + }; + + +} + + +#endif Added: branches/transforms/agg24/include/agg_array.h =================================================================== --- branches/transforms/agg24/include/agg_array.h (rev 0) +++ branches/transforms/agg24/include/agg_array.h 2007-11-16 15:53:57 UTC (rev 4333) @@ -0,0 +1,1119 @@ +//---------------------------------------------------------------------------- +// Anti-Grain Geometry - Version 2.4 +// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) +// +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. +// This software is provided "as is" without express or implied +// warranty, and with no claim as to its suitability for any purpose. +// +//---------------------------------------------------------------------------- +// Contact: mc...@an... +// mcs...@ya... +// http://www.antigrain.com +//---------------------------------------------------------------------------- +#ifndef AGG_ARRAY_INCLUDED +#define AGG_ARRAY_INCLUDED + +#include <stddef.h> +#include <string.h> +#include "agg_basics.h" + +namespace agg +{ + + //-------------------------------------------------------pod_array_adaptor + template<class T> class pod_array_adaptor + { + public: + typedef T value_type; + pod_array_adaptor(T* array, unsigned size) : + m_array(array), m_size(size) {} + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T* m_array; + unsigned m_size; + }; + + + //---------------------------------------------------------pod_auto_array + template<class T, unsigned Size> class pod_auto_array + { + public: + typedef T value_type; + typedef pod_auto_array<T, Size> self_type; + + pod_auto_array() {} + explicit pod_auto_array(const T* c) + { + memcpy(m_array, c, sizeof(T) * Size); + } + + const self_type& operator = (const T* c) + { + memcpy(m_array, c, sizeof(T) * Size); + return *this; + } + + static unsigned size() { return Size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T m_array[Size]; + }; + + + //--------------------------------------------------------pod_auto_vector + template<class T, unsigned Size> class pod_auto_vector + { + public: + typedef T value_type; + typedef pod_auto_vector<T, Size> self_type; + + pod_auto_vector() : m_size(0) {} + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void add(const T& v) { m_array[m_size++] = v; } + void push_back(const T& v) { m_array[m_size++] = v; } + void inc_size(unsigned size) { m_size += size; } + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + private: + T m_array[Size]; + unsigned m_size; + }; + + + //---------------------------------------------------------------pod_array + template<class T> class pod_array + { + public: + typedef T value_type; + typedef pod_array<T> self_type; + + ~pod_array() { pod_allocator<T>::deallocate(m_array, m_size); } + pod_array() : m_array(0), m_size(0) {} + + pod_array(unsigned size) : + m_array(pod_allocator<T>::allocate(size)), + m_size(size) + {} + + pod_array(const self_type& v) : + m_array(pod_allocator<T>::allocate(v.m_size)), + m_size(v.m_size) + { + memcpy(m_array, v.m_array, sizeof(T) * m_size); + } + + void resize(unsigned size) + { + if(size != m_size) + { + pod_allocator<T>::deallocate(m_array, m_size); + m_array = pod_allocator<T>::allocate(m_size = size); + } + } + const self_type& operator = (const self_type& v) + { + resize(v.size()); + memcpy(m_array, v.m_array, sizeof(T) * m_size); + return *this; + } + + unsigned size() const { return m_size; } + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + const T* data() const { return m_array; } + T* data() { return m_array; } + private: + T* m_array; + unsigned m_size; + }; + + + + //--------------------------------------------------------------pod_vector + // A simple class template to store Plain Old Data, a vector + // of a fixed size. The data is continous in memory + //------------------------------------------------------------------------ + template<class T> class pod_vector + { + public: + typedef T value_type; + + ~pod_vector() { pod_allocator<T>::deallocate(m_array, m_capacity); } + pod_vector() : m_size(0), m_capacity(0), m_array(0) {} + pod_vector(unsigned cap, unsigned extra_tail=0); + + // Copying + pod_vector(const pod_vector<T>&); + const pod_vector<T>& operator = (const pod_vector<T>&); + + // Set new capacity. All data is lost, size is set to zero. + void capacity(unsigned cap, unsigned extra_tail=0); + unsigned capacity() const { return m_capacity; } + + // Allocate n elements. All data is lost, + // but elements can be accessed in range 0...size-1. + void allocate(unsigned size, unsigned extra_tail=0); + + // Resize keeping the content. + void resize(unsigned new_size); + + void zero() + { + memset(m_array, 0, sizeof(T) * m_size); + } + + void add(const T& v) { m_array[m_size++] = v; } + void push_back(const T& v) { m_array[m_size++] = v; } + void insert_at(unsigned pos, const T& val); + void inc_size(unsigned size) { m_size += size; } + unsigned size() const { return m_size; } + unsigned byte_size() const { return m_size * sizeof(T); } + void serialize(int8u* ptr) const; + void deserialize(const int8u* data, unsigned byte_size); + const T& operator [] (unsigned i) const { return m_array[i]; } + T& operator [] (unsigned i) { return m_array[i]; } + const T& at(unsigned i) const { return m_array[i]; } + T& at(unsigned i) { return m_array[i]; } + T value_at(unsigned i) const { return m_array[i]; } + + const T* data() const { return m_array; } + T* data() { return m_array; } + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void cut_at(unsigned num) { if(num < m_size) m_size = num; } + + private: + unsigned m_size; + unsigned m_capacity; + T* m_array; + }; + + //------------------------------------------------------------------------ + template<class T> + void pod_vector<T>::capacity(unsigned cap, unsigned extra_tail) + { + m_size = 0; + if(cap > m_capacity) + { + pod_allocator<T>::deallocate(m_array, m_capacity); + m_capacity = cap + extra_tail; + m_array = m_capacity ? pod_allocator<T>::allocate(m_capacity) : 0; + } + } + + //------------------------------------------------------------------------ + template<class T> + void pod_vector<T>::allocate(unsigned size, unsigned extra_tail) + { + capacity(size, extra_tail); + m_size = size; + } + + + //------------------------------------------------------------------------ + template<class T> + void pod_vector<T>::resize(unsigned new_size) + { + if(new_size > m_size) + { + if(new_size > m_capacity) + { + T* data = pod_allocator<T>::allocate(new_size); + memcpy(data, m_array, m_size * sizeof(T)); + pod_allocator<T>::deallocate(m_array, m_capacity); + m_array = data; + } + } + else + { + m_size = new_size; + } + } + + //------------------------------------------------------------------------ + template<class T> pod_vector<T>::pod_vector(unsigned cap, unsigned extra_tail) : + m_size(0), + m_capacity(cap + extra_tail), + m_array(pod_allocator<T>::allocate(m_capacity)) {} + + //------------------------------------------------------------------------ + template<class T> pod_vector<T>::pod_vector(const pod_vector<T>& v) : + m_size(v.m_size), + m_capacity(v.m_capacity), + m_array(v.m_capacity ? pod_allocator<T>::allocate(v.m_capacity) : 0) + { + memcpy(m_array, v.m_array, sizeof(T) * v.m_size); + } + + //------------------------------------------------------------------------ + template<class T> const pod_vector<T>& + pod_vector<T>::operator = (const pod_vector<T>&v) + { + allocate(v.m_size); + if(v.m_size) memcpy(m_array, v.m_array, sizeof(T) * v.m_size); + return *this; + } + + //------------------------------------------------------------------------ + template<class T> void pod_vector<T>::serialize(int8u* ptr) const + { + if(m_size) memcpy(ptr, m_array, m_size * sizeof(T)); + } + + //------------------------------------------------------------------------ + template<class T> + void pod_vector<T>::deserialize(const int8u* data, unsigned byte_size) + { + byte_size /= sizeof(T); + allocate(byte_size); + if(byte_size) memcpy(m_array, data, byte_size * sizeof(T)); + } + + //------------------------------------------------------------------------ + template<class T> + void pod_vector<T>::insert_at(unsigned pos, const T& val) + { + if(pos >= m_size) + { + m_array[m_size] = val; + } + else + { + memmove(m_array + pos + 1, m_array + pos, (m_size - pos) * sizeof(T)); + m_array[pos] = val; + } + ++m_size; + } + + //---------------------------------------------------------------pod_bvector + // A simple class template to store Plain Old Data, similar to std::deque + // It doesn't reallocate memory but instead, uses blocks of data of size + // of (1 << S), that is, power of two. The data is NOT contiguous in memory, + // so the only valid access method is operator [] or curr(), prev(), next() + // + // There reallocs occure only when the pool of pointers to blocks needs + // to be extended (it happens very rarely). You can control the value + // of increment to reallocate the pointer buffer. See the second constructor. + // By default, the incremeent value equals (1 << S), i.e., the block size. + //------------------------------------------------------------------------ + template<class T, unsigned S=6> class pod_bvector + { + public: + enum block_scale_e + { + block_shift = S, + block_size = 1 << block_shift, + block_mask = block_size - 1 + }; + + typedef T value_type; + + ~pod_bvector(); + pod_bvector(); + pod_bvector(unsigned block_ptr_inc); + + // Copying + pod_bvector(const pod_bvector<T, S>& v); + const pod_bvector<T, S>& operator = (const pod_bvector<T, S>& v); + + void remove_all() { m_size = 0; } + void clear() { m_size = 0; } + void free_all() { free_tail(0); } + void free_tail(unsigned size); + void add(const T& val); + void push_back(const T& val) { add(val); } + void modify_last(const T& val); + void remove_last(); + + int allocate_continuous_block(unsigned num_elements); + + void add_array(const T* ptr, unsigned num_elem) + { + while(num_elem--) + { + add(*ptr++); + } + } + + template<class DataAccessor> void add_data(DataAccessor& data) + { + while(data.size()) + { + add(*data); + ++data; + } + } + + void cut_at(unsigned size) + { + if(size < m_size) m_size = size; + } + + unsigned size() const { return m_size; } + + const T& operator [] (unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T& operator [] (unsigned i) + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + const T& at(unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T& at(unsigned i) + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + T value_at(unsigned i) const + { + return m_blocks[i >> block_shift][i & block_mask]; + } + + const T& curr(unsigned idx) const + { + return (*this)[idx]; + } + + T& curr(unsigned idx) + { + return (*this)[idx]; + } + + const T& prev(unsigned idx) const + { + return (*this)[(idx + m_size - 1) % m_size]; + } + + T& prev(unsigned idx) + { + return (*this)[(idx + m_size - 1) % m_size]; + } + + const T& next(unsigned idx) const + { + return (*this)[(idx + 1) % m_size]; + } + + T& next(unsigned idx) + { + return (*this)[(idx + 1) % m_size]; + } + + const T& last() const + { + return (*this)[m_size - 1]; + } + + T& last() + { + return (*this)[m_size - 1]; + } + + unsigned byte_size() const; + void serialize(int8u* ptr) const; + void deserialize(const int8u* data, unsigned byte_size); + void deserialize(unsigned start, const T& empty_val, + const int8u* data, unsigned byte_size); + + template<class ByteAccessor> + void deserialize(ByteAccessor data) + { + remove_all(); + unsigned elem_size = data.size() / sizeof(T); + + for(unsigned i = 0; i < elem_size; ++i) + { + int8u* ptr = (int8u*)data_ptr(); + for(unsigned j = 0; j < sizeof(T); ++j) + { + *ptr++ = *data; + ++data; + } + ++m_size; + } + } + + template<class ByteAccessor> + void deserialize(unsigned start, const T& empty_val, ByteAccessor data) + { + while(m_size < start) + { + add(empty_val); + } + + unsigned elem_size = data.size() / sizeof(T); + for(unsigned i = 0; i < elem_size; ++i) + { + int8u* ptr; + if(start + i < m_size) + { + ptr = (int8u*)(&((*this)[start + i])); + } + else + { + ptr = (int8u*)data_ptr(); + ++m_size; + } + for(unsigned j = 0; j < sizeof(T); ++j) + { + *ptr++ = *data; + ++data; + } + } + } + + const T* block(unsigned nb) const { return m_blocks[nb]; } + + private: + void allocate_block(unsigned nb); + T* data_ptr(); + + unsigned m_size; + unsigned m_num_blocks; + unsigned m_max_blocks; + T** m_blocks; + unsigned m_block_ptr_inc; + }; + + + //------------------------------------------------------------------------ + template<class T, unsigned S> pod_bvector<T, S>::~pod_bvector() + { + if(m_num_blocks) + { + T** blk = m_blocks + m_num_blocks - 1; + while(m_num_blocks--) + { + pod_allocator<T>::deallocate(*blk, block_size); + --blk; + } + } + pod_allocator<T*>::deallocate(m_blocks, m_max_blocks); + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::free_tail(unsigned size) + { + if(size < m_size) + { + unsigned nb = (size + block_mask) >> block_shift; + while(m_num_blocks > nb) + { + pod_allocator<T>::deallocate(m_blocks[--m_num_blocks], block_size); + } + if(m_num_blocks == 0) + { + pod_allocator<T*>::deallocate(m_blocks, m_max_blocks); + m_blocks = 0; + m_max_blocks = 0; + } + m_size = size; + } + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> pod_bvector<T, S>::pod_bvector() : + m_size(0), + m_num_blocks(0), + m_max_blocks(0), + m_blocks(0), + m_block_ptr_inc(block_size) + { + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + pod_bvector<T, S>::pod_bvector(unsigned block_ptr_inc) : + m_size(0), + m_num_blocks(0), + m_max_blocks(0), + m_blocks(0), + m_block_ptr_inc(block_ptr_inc) + { + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + pod_bvector<T, S>::pod_bvector(const pod_bvector<T, S>& v) : + m_size(v.m_size), + m_num_blocks(v.m_num_blocks), + m_max_blocks(v.m_max_blocks), + m_blocks(v.m_max_blocks ? + pod_allocator<T*>::allocate(v.m_max_blocks) : + 0), + m_block_ptr_inc(v.m_block_ptr_inc) + { + unsigned i; + for(i = 0; i < v.m_num_blocks; ++i) + { + m_blocks[i] = pod_allocator<T>::allocate(block_size); + memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); + } + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + const pod_bvector<T, S>& + pod_bvector<T, S>::operator = (const pod_bvector<T, S>& v) + { + unsigned i; + for(i = m_num_blocks; i < v.m_num_blocks; ++i) + { + allocate_block(i); + } + for(i = 0; i < v.m_num_blocks; ++i) + { + memcpy(m_blocks[i], v.m_blocks[i], block_size * sizeof(T)); + } + m_size = v.m_size; + return *this; + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::allocate_block(unsigned nb) + { + if(nb >= m_max_blocks) + { + T** new_blocks = pod_allocator<T*>::allocate(m_max_blocks + m_block_ptr_inc); + + if(m_blocks) + { + memcpy(new_blocks, + m_blocks, + m_num_blocks * sizeof(T*)); + + pod_allocator<T*>::deallocate(m_blocks, m_max_blocks); + } + m_blocks = new_blocks; + m_max_blocks += m_block_ptr_inc; + } + m_blocks[nb] = pod_allocator<T>::allocate(block_size); + m_num_blocks++; + } + + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + inline T* pod_bvector<T, S>::data_ptr() + { + unsigned nb = m_size >> block_shift; + if(nb >= m_num_blocks) + { + allocate_block(nb); + } + return m_blocks[nb] + (m_size & block_mask); + } + + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + inline void pod_bvector<T, S>::add(const T& val) + { + *data_ptr() = val; + ++m_size; + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + inline void pod_bvector<T, S>::remove_last() + { + if(m_size) --m_size; + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::modify_last(const T& val) + { + remove_last(); + add(val); + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + int pod_bvector<T, S>::allocate_continuous_block(unsigned num_elements) + { + if(num_elements < block_size) + { + data_ptr(); // Allocate initial block if necessary + unsigned rest = block_size - (m_size & block_mask); + unsigned index; + if(num_elements <= rest) + { + // The rest of the block is good, we can use it + //----------------- + index = m_size; + m_size += num_elements; + return index; + } + + // New block + //--------------- + m_size += rest; + data_ptr(); + index = m_size; + m_size += num_elements; + return index; + } + return -1; // Impossible to allocate + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + unsigned pod_bvector<T, S>::byte_size() const + { + return m_size * sizeof(T); + } + + + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::serialize(int8u* ptr) const + { + unsigned i; + for(i = 0; i < m_size; i++) + { + memcpy(ptr, &(*this)[i], sizeof(T)); + ptr += sizeof(T); + } + } + + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::deserialize(const int8u* data, unsigned byte_size) + { + remove_all(); + byte_size /= sizeof(T); + for(unsigned i = 0; i < byte_size; ++i) + { + T* ptr = data_ptr(); + memcpy(ptr, data, sizeof(T)); + ++m_size; + data += sizeof(T); + } + } + + + // Replace or add a number of elements starting from "start" position + //------------------------------------------------------------------------ + template<class T, unsigned S> + void pod_bvector<T, S>::deserialize(unsigned start, const T& empty_val, + const int8u* data, unsigned byte_size) + { + while(m_size < start) + { + add(empty_val); + } + + byte_size /= sizeof(T); + for(unsigned i = 0; i < byte_size; ++i) + { + if(start + i < m_size) + { + memcpy(&((*this)[start + i]), data, sizeof(T)); + } + else + { + T* ptr = data_ptr(); + memcpy(ptr, data, sizeof(T)); + ++m_size; + } + data += sizeof(T); + } + } + + + //---------------------------------------------------------block_allocator + // Allocator for arbitrary POD data. Most usable in different cache + // systems for efficient memory allocations. + // Memory is allocated with blocks of fixed size ("block_size" in + // the constructor). If required size exceeds the block size the allocator + // creates a new block of the required size. However, the most efficient + // use is when the average reqired size is much less than the block size. + //------------------------------------------------------------------------ + class block_allocator + { + struct block_type + { + int8u* data; + unsigned size; + }; + + public: + void remove_all() + { + if(m_num_blocks) + { + block_type* blk = m_blocks + m_num_blocks - 1; + while(m_num_blocks--) + { + pod_allocator<int8u>::deallocate(blk->data, blk->size); + --blk; + } + pod_allocator<block_type>::deallocate(m_blocks, m_max_blocks); + } + m_num_blocks = 0; + m_max_blocks = 0; + m_blocks = 0; + m_buf_ptr = 0; + m_rest = 0; + } + + ~block_allocator() + { + remove_all(); + } + + block_allocator(unsigned block_size, unsigned block_ptr_inc=256-8) : + m_block_size(block_size), + m_block_ptr_inc(block_ptr_inc), + m_num_blocks(0), + m_max_blocks(0), + m_blocks... [truncated message content] |
From: <md...@us...> - 2007-11-16 17:48:22
|
Revision: 4340 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4340&view=rev Author: mdboom Date: 2007-11-16 09:48:05 -0800 (Fri, 16 Nov 2007) Log Message: ----------- Merged revisions 4330-4339 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4331 | mdboom | 2007-11-16 08:46:59 -0500 (Fri, 16 Nov 2007) | 2 lines Fix numerals in stixsans mode. ........ r4336 | jdh2358 | 2007-11-16 10:58:05 -0500 (Fri, 16 Nov 2007) | 2 lines fixed bug in polyfit, polyval deprecation ........ Modified Paths: -------------- branches/transforms/lib/matplotlib/_mathtext_data.py branches/transforms/lib/matplotlib/mlab.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4329 + /trunk/matplotlib:1-4339 Modified: branches/transforms/lib/matplotlib/_mathtext_data.py =================================================================== --- branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-16 17:09:18 UTC (rev 4339) +++ branches/transforms/lib/matplotlib/_mathtext_data.py 2007-11-16 17:48:05 UTC (rev 4340) @@ -2432,7 +2432,9 @@ ], 'it': [ - (0x0030, 0x0039, 'it', 0xe1b4), # 0-9 + # These numerals are actually upright. We don't actually + # want italic numerals ever. + (0x0030, 0x0039, 'rm', 0x1d7e2), # 0-9 (0x0041, 0x005a, 'it', 0x1d608), # A-Z (0x0061, 0x007a, 'it', 0x1d622), # a-z (0x0391, 0x03a9, 'it', 0xe1bf), # \Alpha-\Omega Modified: branches/transforms/lib/matplotlib/mlab.py =================================================================== --- branches/transforms/lib/matplotlib/mlab.py 2007-11-16 17:09:18 UTC (rev 4339) +++ branches/transforms/lib/matplotlib/mlab.py 2007-11-16 17:48:05 UTC (rev 4340) @@ -442,6 +442,7 @@ kw = dict(rowvar=False) return npy.corrcoef(*args, **kw) + def polyfit(*args, **kwargs): """ def polyfit(x,y,N) @@ -482,7 +483,7 @@ """ warnings.warn("use numpy.poyfit", DeprecationWarning) - return npy.polyfit(*args, **kw) + return npy.polyfit(*args, **kwargs) @@ -504,9 +505,8 @@ """ warnings.warn("use numpy.polyval", DeprecationWarning) - return npy.polyval(*args, **kw) + return npy.polyval(*args, **kwargs) - def vander(*args, **kwargs): """ X = vander(x,N=None) @@ -2262,7 +2262,8 @@ return x class FormatInt(FormatObj): - pass + def toval(self, x): + return x class FormatPercent(FormatFloat): def __init__(self, precision=4): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-20 14:52:26
|
Revision: 4393 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4393&view=rev Author: mdboom Date: 2007-11-20 06:52:24 -0800 (Tue, 20 Nov 2007) Log Message: ----------- Merged revisions 4340-4392 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4341 | jdh2358 | 2007-11-16 13:15:32 -0500 (Fri, 16 Nov 2007) | 2 lines removed a couple of pyc files ........ r4346 | dsdale | 2007-11-16 16:47:17 -0500 (Fri, 16 Nov 2007) | 2 lines fixed version checking for traits-3 ........ r4347 | mdboom | 2007-11-17 07:44:52 -0500 (Sat, 17 Nov 2007) | 1 line Bugfix: [1655313] axis label disappears when minor tick labels are hidden ........ r4374 | efiring | 2007-11-18 13:59:56 -0500 (Sun, 18 Nov 2007) | 11 lines Let to_rgba return uint8; track changes to cmap Images require rgba as 4 uint8s, so it is more efficient to generate these directly in to_rgba than to generate 4 doubles and convert them later. The tracking of changes in ScalarMappable was handling communication between objects, but was not keeping track of when to_rgba needs to be rerun. A dictionary was added to do this. ........ r4375 | efiring | 2007-11-18 14:01:39 -0500 (Sun, 18 Nov 2007) | 2 lines Remove trailing whitespace. ........ r4376 | efiring | 2007-11-18 14:02:55 -0500 (Sun, 18 Nov 2007) | 2 lines Use new update_dict from ScalarMappable in QuadMesh ........ r4377 | efiring | 2007-11-18 14:06:49 -0500 (Sun, 18 Nov 2007) | 7 lines Add experimental "pcolorfast" for fast interactive pcolor plots This will need more discussion and work, but it illustrates the potential for very fast pcolor-type plotting with all three grid types: uniform, irregular but rectilinear, and general quadrilateral. ........ r4379 | efiring | 2007-11-18 15:54:22 -0500 (Sun, 18 Nov 2007) | 2 lines Remove unnecessary data copying from draw_quad_mesh ........ r4383 | jdh2358 | 2007-11-19 16:43:24 -0500 (Mon, 19 Nov 2007) | 2 lines fixed a minor bug in csv2rec ........ r4387 | mdboom | 2007-11-20 08:13:22 -0500 (Tue, 20 Nov 2007) | 2 lines Speed improvement initializing mathtext parser. ........ r4391 | mdboom | 2007-11-20 08:29:20 -0500 (Tue, 20 Nov 2007) | 2 lines Fix problem with 0-line width drawing in Postscript. (Thanks Ben North). ........ Modified Paths: -------------- branches/transforms/lib/matplotlib/axes.py branches/transforms/lib/matplotlib/axis.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/cm.py branches/transforms/lib/matplotlib/collections.py branches/transforms/lib/matplotlib/image.py branches/transforms/lib/matplotlib/mlab.py branches/transforms/lib/matplotlib/pyparsing.py branches/transforms/setupext.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4339 + /trunk/matplotlib:1-4392 Modified: branches/transforms/lib/matplotlib/axes.py =================================================================== --- branches/transforms/lib/matplotlib/axes.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/axes.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -3774,8 +3774,8 @@ xs = [thisx for thisx, b in zip(xs, mask) if b] ys = [thisy for thisy, b in zip(ys, mask) if b] return xs, ys - + if capsize > 0: plot_kw = { 'ms':2*capsize, @@ -3801,16 +3801,16 @@ # can't use numpy logical indexing since left and # y are lists leftlo, ylo = xywhere(left, y, xlolims) - + caplines.extend( self.plot(leftlo, ylo, ls='None', marker=mlines.CARETLEFT, **plot_kw) ) xlolims = ~xlolims - leftlo, ylo = xywhere(left, y, xlolims) + leftlo, ylo = xywhere(left, y, xlolims) caplines.extend( self.plot(leftlo, ylo, 'k|', **plot_kw) ) else: caplines.extend( self.plot(left, y, 'k|', **plot_kw) ) if xuplims.any(): - + rightup, yup = xywhere(right, y, xuplims) caplines.extend( self.plot(rightup, yup, ls='None', marker=mlines.CARETRIGHT, **plot_kw) ) xuplims = ~xuplims @@ -3843,7 +3843,7 @@ if uplims.any(): xup, upperup = xywhere(x, upper, uplims) - + caplines.extend( self.plot(xup, upperup, ls='None', marker=mlines.CARETUP, **plot_kw) ) uplims = ~uplims xup, upperup = xywhere(x, upper, uplims) @@ -4835,6 +4835,177 @@ return collection pcolormesh.__doc__ = cbook.dedent(pcolormesh.__doc__) % martist.kwdocd + def pcolorfast(self, *args, **kwargs): + """ + Experimental; this is a version of pcolor that + does not draw lines, that provides the fastest + possible rendering with the Agg backend, and that + can handle any quadrilateral grid. + + pcolor(*args, **kwargs): pseudocolor plot of a 2-D array + + Function signatures + + pcolor(C, **kwargs) + pcolor(xr, yr, C, **kwargs) + pcolor(x, y, C, **kwargs) + pcolor(X, Y, C, **kwargs) + + C is the 2D array of color values corresponding to quadrilateral + cells. Let (nr, nc) be its shape. C may be a masked array. + + pcolor(C, **kwargs) is equivalent to + pcolor([0,nc], [0,nr], C, **kwargs) + + xr, yr specify the ranges of x and y corresponding to the rectangular + region bounding C. If xr = [x0, x1] and yr = [y0,y1] then + x goes from x0 to x1 as the second index of C goes from 0 to nc, + etc. (x0, y0) is the outermost corner of cell (0,0), and (x1, y1) + is the outermost corner of cell (nr-1, nc-1). All cells are + rectangles of the same size. This is the fastest version. + + x, y are 1D arrays of length nc+1 and nr+1, respectively, giving + the x and y boundaries of the cells. Hence the cells are + rectangular but the grid may be nonuniform. The speed is + intermediate. (The grid is checked, and if found to be + uniform the fast version is used.) + + X and Y are 2D arrays with shape (nr+1, nc+1) that specify + the (x,y) coordinates of the corners of the colored + quadrilaterals; the quadrilateral for C[i,j] has corners at + (X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]), + (X[i+1,j+1],Y[i+1,j+1]). The cells need not be rectangular. + This is the most general, but the slowest to render. It may + produce faster and more compact output using ps, pdf, and + svg backends, however. + + Note that the the column index corresponds to the x-coordinate, + and the row index corresponds to y; for details, see + the "Grid Orientation" section below. + + Optional keyword args are shown with their defaults below (you must + use kwargs for these): + + * cmap = cm.jet : a cm Colormap instance from cm + + * norm = Normalize() : mcolors.Normalize instance + is used to scale luminance data to 0,1. + + * vmin=None and vmax=None : vmin and vmax are used in conjunction + with norm to normalize luminance data. If either are None, the + min and max of the color array C is used. If you pass a norm + instance, vmin and vmax will be None + + * alpha=1.0 : the alpha blending value + + Return value is an image if a regular or rectangular grid + is specified, and a QuadMesh collection in the general + quadrilateral case. + + """ + + if not self._hold: self.cla() + + alpha = kwargs.pop('alpha', 1.0) + norm = kwargs.pop('norm', None) + cmap = kwargs.pop('cmap', None) + vmin = kwargs.pop('vmin', None) + vmax = kwargs.pop('vmax', None) + if norm is not None: assert(isinstance(norm, mcolors.Normalize)) + if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) + + C = args[-1] + nr, nc = C.shape + if len(args) == 1: + style = "image" + x = [0, nc+1] + y = [0, nr+1] + elif len(args) == 3: + x, y = args[:2] + x = npy.asarray(x) + y = npy.asarray(y) + if x.ndim == 1 and y.ndim == 1: + if x.size == 2 and y.size == 2: + style = "image" + else: + dx = npy.diff(x) + dy = npy.diff(y) + if (npy.ptp(dx) < 0.01*npy.abs(dx.mean()) and + npy.ptp(dy) < 0.01*npy.abs(dy.mean())): + style = "image" + style = "pcolorimage" + elif x.ndim == 2 and y.ndim == 2: + style = "quadmesh" + else: + raise TypeError("arguments do not match valid signatures") + else: + raise TypeError("need 1 argument or 3 arguments") + + if style == "quadmesh": + + # convert to one dimensional arrays + # This should also be moved to the QuadMesh class + C = ma.ravel(C) # data point in each cell is value at lower left corner + X = x.ravel() + Y = y.ravel() + Nx = nc+1 + Ny = nr+1 + + # The following needs to be cleaned up; the renderer + # requires separate contiguous arrays for X and Y, + # but the QuadMesh class requires the 2D array. + coords = npy.empty(((Nx * Ny), 2), npy.float64) + coords[:, 0] = X + coords[:, 1] = Y + + # The QuadMesh class can also be changed to + # handle relevant superclass kwargs; the initializer + # should do much more than it does now. + collection = mcoll.QuadMesh(nc, nr, coords, 0) + collection.set_alpha(alpha) + collection.set_array(C) + collection.set_cmap(cmap) + collection.set_norm(norm) + self.add_collection(collection) + xl, xr, yb, yt = X.min(), X.max(), Y.min(), Y.max() + ret = collection + + else: + # One of the image styles: + xl, xr, yb, yt = x[0], x[-1], y[0], y[-1] + if style == "image": + + im = mimage.AxesImage(self, cmap, norm, + interpolation='nearest', + origin='lower', + extent=(xl, xr, yb, yt), + **kwargs) + im.set_data(C) + im.set_alpha(alpha) + self.images.append(im) + ret = im + + if style == "pcolorimage": + im = mimage.PcolorImage(self, x, y, C, + cmap=cmap, + norm=norm, + alpha=alpha, + **kwargs) + self.images.append(im) + ret = im + + self._set_artist_props(ret) + if vmin is not None or vmax is not None: + ret.set_clim(vmin, vmax) + else: + ret.autoscale_None() + self.update_datalim(npy.array([[xl, yb], [xr, yt]])) + self.autoscale_view(tight=True) + return ret + + + + def contour(self, *args, **kwargs): kwargs['filled'] = False return mcontour.ContourSet(self, *args, **kwargs) @@ -4895,14 +5066,14 @@ ticks on bottom and the returned axes will have ticks on the top """ - + ax2 = self.figure.add_axes(self.get_position(), sharey=self, frameon=False) ax2.xaxis.tick_top() ax2.xaxis.set_label_position('top') self.xaxis.tick_bottom() return ax2 - + #### Data analysis Modified: branches/transforms/lib/matplotlib/axis.py =================================================================== --- branches/transforms/lib/matplotlib/axis.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/axis.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -620,10 +620,10 @@ tick.set_label2(label) tick.draw(renderer) - if tick.label1On: + if tick.label1On and tick.label1.get_visible(): extent = tick.label1.get_window_extent(renderer) ticklabelBoxes.append(extent) - if tick.label2On: + if tick.label2On and tick.label2.get_visible(): extent = tick.label2.get_window_extent(renderer) ticklabelBoxes2.append(extent) Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -787,6 +787,9 @@ if self.linewidth > 0 and stroke: self.set_color(*gc.get_rgb()[:3]) write("stroke\n") + else: + write("newpath\n") + if clippath: write("grestore\n") if cliprect: Modified: branches/transforms/lib/matplotlib/cm.py =================================================================== --- branches/transforms/lib/matplotlib/cm.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/cm.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -40,6 +40,7 @@ self.cmap = cmap self.observers = [] self.colorbar = None + self.update_dict = {'array':False} def set_colorbar(self, im, ax): 'set the colorbar image and axes associated with mappable' @@ -47,11 +48,26 @@ def to_rgba(self, x, alpha=1.0, bytes=False): '''Return a normalized rgba array corresponding to x. - If x is already an rgb or rgba array, return it unchanged. + If x is already an rgb array, insert alpha; if it is + already rgba, return it unchanged. + If bytes is True, return rgba as 4 uint8s instead of 4 floats. ''' try: - if x.ndim == 3 and (x.shape[2] == 3 or x.shape[2] == 4): - return x + if x.ndim == 3: + if x.shape[2] == 3: + if x.dtype == npy.uint8: + alpha = npy.array(alpha*255, npy.uint8) + m, n = npy.shape[:2] + xx = npy.empty(shape=(m,n,4), dtype = x.dtype) + xx[:,:,:3] = x + xx[:,:,3] = alpha + elif x.shape[2] == 4: + xx = x + else: + raise ValueError("third dimension must be 3 or 4") + if bytes and xx.dtype != npy.uint8: + xx = (xx * 255).astype(npy.uint8) + return xx except AttributeError: pass x = ma.asarray(x) @@ -62,6 +78,7 @@ def set_array(self, A): 'Set the image array from numpy array A' self._A = A + self.update_dict['array'] = True def get_array(self): 'Return the array' @@ -124,7 +141,23 @@ self.changed() + def add_checker(self, checker): + """ + Add an entry to a dictionary of boolean flags + that are set to True when the mappable is changed. + """ + self.update_dict[checker] = False + def check_update(self, checker): + """ + If mappable has changed since the last check, + return True; else return False + """ + if self.update_dict[checker]: + self.update_dict[checker] = False + return True + return False + def add_observer(self, mappable): """ whenever the norm, clim or cmap is set, call the notify @@ -158,3 +191,6 @@ """ for observer in self.observers: observer.notify(self) + for key in self.update_dict: + self.update_dict[key] = True + Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -441,7 +441,8 @@ else: offsets = npy.asarray(offsets, npy.float_) - self.update_scalarmappable() + if self.check_update('array'): + self.update_scalarmappable() clippath, clippath_trans = self.get_transformed_clip_path_and_affine() if clippath_trans is not None: Modified: branches/transforms/lib/matplotlib/image.py =================================================================== --- branches/transforms/lib/matplotlib/image.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/image.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -404,9 +404,107 @@ raise RuntimeError('Cannot change colors after loading data') cm.ScalarMappable.set_cmap(self, norm) +class PcolorImage(martist.Artist, cm.ScalarMappable): + def __init__(self, ax, + x=None, + y=None, + A=None, + cmap = None, + norm = None, + **kwargs + ): + """ + cmap defaults to its rc setting + cmap is a colors.Colormap instance + norm is a colors.Normalize instance to map luminance to 0-1 + Additional kwargs are matplotlib.artist properties + """ + martist.Artist.__init__(self) + cm.ScalarMappable.__init__(self, norm, cmap) + self.axes = ax + self._rgbacache = None + self.update(kwargs) + self.set_data(x, y, A) + + def make_image(self, magnification=1.0): + if self._A is None: + raise RuntimeError('You must first set the image array') + fc = self.axes.get_frame().get_facecolor() + bg = mcolors.colorConverter.to_rgba(fc, 0) + bg = (npy.array(bg)*255).astype(npy.uint8) + x0, y0, v_width, v_height = self.axes.viewLim.get_bounds() + l, b, width, height = self.axes.bbox.get_bounds() + width *= magnification + height *= magnification + if self.check_update('array'): + A = self.to_rgba(self._A, alpha=self._alpha, bytes=True) + self._rgbacache = A + if self._A.ndim == 2: + self.is_grayscale = self.cmap.is_gray() + else: + A = self._rgbacache + im = _image.pcolor2(self._Ax, self._Ay, A, + height, width, + (x0, x0+v_width, y0, y0+v_height), + bg) + im.is_grayscale = self.is_grayscale + return im + + def draw(self, renderer, *args, **kwargs): + if not self.get_visible(): return + im = self.make_image(renderer.get_image_magnification()) + l, b, widthDisplay, heightDisplay = self.axes.bbox.get_bounds() + renderer.draw_image(l, b, im, self.axes.bbox) + + + def set_data(self, x, y, A): + A = ma.asarray(A) + if x is None: + x = npy.arange(0, A.shape[1]+1, dtype=npy.float64) + else: + x = npy.asarray(x, npy.float64).ravel() + if y is None: + y = npy.arange(0, A.shape[0]+1, dtype=npy.float64) + else: + y = npy.asarray(y, npy.float64).ravel() + + if A.shape[:2] != (y.size-1, x.size-1): + print A.shape + print y.size + print x.size + raise ValueError("Axes don't match array shape") + if A.ndim not in [2, 3]: + raise ValueError("A must be 2D or 3D") + if A.ndim == 3 and A.shape[2] == 1: + A.shape = A.shape[:2] + self.is_grayscale = False + if A.ndim == 3: + if A.shape[2] in [3, 4]: + if (A[:,:,0] == A[:,:,1]).all() and (A[:,:,0] == A[:,:,2]).all(): + self.is_grayscale = True + else: + raise ValueError("3D arrays must have RGB or RGBA as last dim") + self._A = A + self._Ax = x + self._Ay = y + self.update_dict['array'] = True + + def set_array(self, *args): + raise NotImplementedError('Method not supported') + + def set_alpha(self, alpha): + """ + Set the alpha value used for blending - not supported on + all backends + + ACCEPTS: float + """ + martist.Artist.set_alpha(self, alpha) + self.update_dict['array'] = True + class FigureImage(martist.Artist, cm.ScalarMappable): def __init__(self, fig, cmap = None, Modified: branches/transforms/lib/matplotlib/mlab.py =================================================================== --- branches/transforms/lib/matplotlib/mlab.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/mlab.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -44,7 +44,7 @@ compute it for a lot of pairs. This function is optimized to do this efficiently by caching the direct FFTs. -= record array helper functions = += record array helper functions = rec2csv : store record array in CSV file rec2excel : store record array in excel worksheet - required pyExcelerator @@ -1261,8 +1261,6 @@ def splitfunc(x): return x.split(delimiter) - - converterseq = None for i,line in enumerate(fh): if i<skiprows: continue @@ -1958,13 +1956,13 @@ newrec[name] = arr return newrec.view(npy.recarray) - + def rec_drop_fields(rec, names): - 'return a new numpy record array with fields in names dropped' + 'return a new numpy record array with fields in names dropped' names = set(names) Nr = len(rec) - + newdtype = npy.dtype([(name, rec.dtype[name]) for name in rec.dtype.names if name not in names]) @@ -1974,7 +1972,7 @@ return newrec.view(npy.recarray) - + def rec_join(key, r1, r2): """ join record arrays r1 and r2 on key; key is a tuple of field @@ -1992,15 +1990,15 @@ def makekey(row): return tuple([row[name] for name in key]) - + names = list(r1.dtype.names) + [name for name in r2.dtype.names if name not in set(r1.dtype.names)] - - - r1d = dict([(makekey(row),i) for i,row in enumerate(r1)]) + + + r1d = dict([(makekey(row),i) for i,row in enumerate(r1)]) r2d = dict([(makekey(row),i) for i,row in enumerate(r2)]) - r1keys = set(r1d.keys()) + r1keys = set(r1d.keys()) r2keys = set(r2d.keys()) keys = r1keys & r2keys @@ -2008,7 +2006,7 @@ r1ind = [r1d[k] for k in keys] r2ind = [r2d[k] for k in keys] - + r1 = r1[r1ind] r2 = r2[r2ind] @@ -2028,15 +2026,15 @@ else: return (name, dt2.descr[0][1]) - - + + keydesc = [key_desc(name) for name in key] newdtype = npy.dtype(keydesc + [desc for desc in r1.dtype.descr if desc[0] not in key ] + [desc for desc in r2.dtype.descr if desc[0] not in key ] ) - - + + newrec = npy.empty(len(r1), dtype=newdtype) for field in r1.dtype.names: newrec[field] = r1[field] @@ -2089,7 +2087,7 @@ fh = cbook.to_filehandle(fname) - + class FH: """ for space delimited files, we want different behavior than @@ -2115,13 +2113,13 @@ return self.fix(self.fh.next()) def __iter__(self): - for line in self.fh: + for line in self.fh: yield self.fix(line) if delimiter==' ': fh = FH(fh) - reader = csv.reader(fh, delimiter=delimiter) + reader = csv.reader(fh, delimiter=delimiter) def process_skiprows(reader): if skiprows: for i, row in enumerate(reader): @@ -2155,7 +2153,7 @@ 'file' : 'file_', 'print' : 'print_', } - + def get_converters(reader): converters = None @@ -2209,6 +2207,7 @@ # reset the reader and start over fh.seek(0) + reader = csv.reader(fh, delimiter=delimiter) process_skiprows(reader) if needheader: skipheader = reader.next() @@ -2232,7 +2231,7 @@ class FormatObj: def tostr(self, x): return self.toval(x) - + def toval(self, x): return str(x) @@ -2255,12 +2254,12 @@ FormatFormatStr.__init__(self, '%%1.%df'%precision) self.precision = precision self.scale = scale - + def toval(self, x): if x is not None: x = x * self.scale return x - + class FormatInt(FormatObj): def toval(self, x): return x @@ -2292,20 +2291,20 @@ defaultformatd = { - npy.int16 : FormatInt(), + npy.int16 : FormatInt(), npy.int32 : FormatInt(), - npy.int64 : FormatInt(), + npy.int64 : FormatInt(), npy.float32 : FormatFloat(), - npy.float64 : FormatFloat(), + npy.float64 : FormatFloat(), npy.object_ : FormatObj(), - npy.string_ : FormatObj(), + npy.string_ : FormatObj(), } def get_formatd(r, formatd=None): 'build a formatd guaranteed to have a key for every dtype name' if formatd is None: formatd = dict() - + for i, name in enumerate(r.dtype.names): dt = r.dtype[name] format = formatd.get(name) @@ -2316,7 +2315,7 @@ def csvformat_factory(format): format = copy.deepcopy(format) - if isinstance(format, FormatFloat): + if isinstance(format, FormatFloat): format.scale = 1. # override scaling for storage format.fmt = '%g' # maximal precision return format @@ -2358,14 +2357,14 @@ """ format = copy.deepcopy(format) - - + + xlstyle = excel.XFStyle() - if isinstance(format, FormatFloat): + if isinstance(format, FormatFloat): zeros = ''.join(['0']*format.precision) xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros) elif isinstance(format, FormatInt): - xlstyle.num_format_str = '#,##;[RED]-#,##' + xlstyle.num_format_str = '#,##;[RED]-#,##' elif isinstance(format, FormatPercent): zeros = ''.join(['0']*format.precision) xlstyle.num_format_str = '0.%s%;[RED]-0.%s%'%(zeros, zeros) @@ -2374,7 +2373,7 @@ xlstyle = None format.xlstyle = xlstyle - + return format def rec2excel(r, ws, formatd=None, rownum=0): @@ -2412,7 +2411,7 @@ rownum+=1 - + ind = npy.arange(len(r.dtype.names)) for row in r: for i in ind: @@ -2470,7 +2469,7 @@ cell.set_property('foreground', 'black') - if isinstance(format, FormatFloat) or isinstance(format, FormatInt): + if isinstance(format, FormatFloat) or isinstance(format, FormatInt): format.cell = negative_red_cell format.xalign = 1. elif isinstance(format, FormatDate): @@ -2573,7 +2572,7 @@ self.clear() def clear(self): - self.iterd = dict() + self.iterd = dict() self.iters = [] # an ordered list of iters self.rownumd = dict() # a map from rownum -> symbol self.model.clear() @@ -2596,7 +2595,7 @@ thisiter = self.iterd[key] self.model.remove(thisiter) del self.datad[key] - del self.iterd[key] + del self.iterd[key] self.iters.remove(thisiter) for i, thisiter in enumerate(self.iters): @@ -2611,7 +2610,7 @@ del self.datad[key] - del self.iterd[key] + del self.iterd[key] self.rownumd[len(self.iters)] = key self.iters.remove(thisiter) @@ -2619,7 +2618,7 @@ if thiskey==key: del self.rownumd[rownum] def add_row(self, row): - thisiter = self.model.append() + thisiter = self.model.append() self.model.set(thisiter, *self.flat(row)) key = tuple(row) self.datad[key] = row @@ -2702,7 +2701,7 @@ win.add(scroll) win.show_all() scroll.win = win - + return scroll Modified: branches/transforms/lib/matplotlib/pyparsing.py =================================================================== --- branches/transforms/lib/matplotlib/pyparsing.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/lib/matplotlib/pyparsing.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -2845,22 +2845,18 @@ else: warnings.warn("Invalid argument to oneOf, expected string or list", SyntaxWarning, stacklevel=2) - + + symbols.sort(reverse=True) i = 0 while i < len(symbols)-1: cur = symbols[i] - for j,other in enumerate(symbols[i+1:]): + for j, other in enumerate(symbols[i+1:]): if ( isequal(other, cur) ): del symbols[i+j+1] + else: break - elif ( masks(cur, other) ): - del symbols[i+j+1] - symbols.insert(i,other) - cur = other - break - else: - i += 1 - + i += 1 + if not caseless and useRegex: #~ print strs,"->", "|".join( [ _escapeRegexChars(sym) for sym in symbols] ) try: Modified: branches/transforms/setupext.py =================================================================== --- branches/transforms/setupext.py 2007-11-20 13:50:04 UTC (rev 4392) +++ branches/transforms/setupext.py 2007-11-20 14:52:24 UTC (rev 4393) @@ -466,11 +466,16 @@ print_status("enthought.traits", "unknown and incompatible version: < 2.0") return False else: - if version.version.endswith('mpl'): + # traits 2 and 3 store their version strings in different places: + try: + version = version.version + except AttributeError: + version = version.__version__ + if version.endswith('mpl'): print_status("enthought.traits", "matplotlib will provide") return True else: - print_status("enthought.traits", version.version) + print_status("enthought.traits", version) return False except ImportError: if options['provide_traits']: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-20 17:44:33
|
Revision: 4395 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4395&view=rev Author: mdboom Date: 2007-11-20 09:44:27 -0800 (Tue, 20 Nov 2007) Log Message: ----------- Merged revisions 4393-4394 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4394 | mdboom | 2007-11-20 12:43:40 -0500 (Tue, 20 Nov 2007) | 3 lines Minor refactorings, comments, and one bugfix (to do with the alignment of wide accents with STIX fonts). ........ Modified Paths: -------------- branches/transforms/lib/matplotlib/mathtext.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4392 + /trunk/matplotlib:1-4394 Modified: branches/transforms/lib/matplotlib/mathtext.py =================================================================== --- branches/transforms/lib/matplotlib/mathtext.py 2007-11-20 17:43:40 UTC (rev 4394) +++ branches/transforms/lib/matplotlib/mathtext.py 2007-11-20 17:44:27 UTC (rev 4395) @@ -1707,6 +1707,7 @@ char = char_class(sym, state) Hlist.__init__(self, [char]) + self.width = char.width class Ship(object): """Once the boxes have been set up, this sends them to output. @@ -1742,11 +1743,14 @@ left_edge = self.cur_h self.cur_s += 1 self.max_push = max(self.cur_s, self.max_push) - + clamp = self.clamp + for p in box.children: if isinstance(p, Char): p.render(self.cur_h + self.off_h, self.cur_v + self.off_v) self.cur_h += p.width + elif isinstance(p, Kern): + self.cur_h += p.width elif isinstance(p, List): # @623 if len(p.children) == 0: @@ -1785,14 +1789,12 @@ if glue_sign == 1: # stretching if glue_spec.stretch_order == glue_order: cur_glue += glue_spec.stretch - cur_g = round(self.clamp(float(box.glue_set) * cur_glue)) + cur_g = round(clamp(float(box.glue_set) * cur_glue)) elif glue_spec.shrink_order == glue_order: cur_glue += glue_spec.shrink - cur_g = round(self.clamp(float(box.glue_set) * cur_glue)) + cur_g = round(clamp(float(box.glue_set) * cur_glue)) rule_width += cur_g self.cur_h += rule_width - elif isinstance(p, Kern): - self.cur_h += p.width self.cur_s -= 1 def vlist_out(self, box): @@ -1805,9 +1807,12 @@ left_edge = self.cur_h self.cur_v -= box.height top_edge = self.cur_v + clamp = self.clamp for p in box.children: - if isinstance(p, List): + if isinstance(p, Kern): + self.cur_v += p.width + elif isinstance(p, List): if len(p.children) == 0: self.cur_v += p.height + p.depth else: @@ -1840,14 +1845,12 @@ if glue_sign == 1: # stretching if glue_spec.stretch_order == glue_order: cur_glue += glue_spec.stretch - cur_g = round(self.clamp(float(box.glue_set) * cur_glue)) + cur_g = round(clamp(float(box.glue_set) * cur_glue)) elif glue_spec.shrink_order == glue_order: # shrinking cur_glue += glue_spec.shrink - cur_g = round(self.clamp(float(box.glue_set) * cur_glue)) + cur_g = round(clamp(float(box.glue_set) * cur_glue)) rule_height += cur_g self.cur_v += rule_height - elif isinstance(p, Kern): - self.cur_v += p.width elif isinstance(p, Char): raise RuntimeError("Internal mathtext error: Char node found in vlist") self.cur_s -= 1 @@ -1921,6 +1924,21 @@ _dropsub_symbols = Set(r'''\int \oint'''.split()) + _fontnames = Set("rm cal it tt sf bf default bb frak circled scr".split()) + + _function_names = Set(""" + arccos csc ker min arcsin deg lg Pr arctan det lim sec arg dim + liminf sin cos exp limsup sinh cosh gcd ln sup cot hom log tan + coth inf max tanh""".split()) + + _ambiDelim = Set(r""" + | \| / \backslash \uparrow \downarrow \updownarrow \Uparrow + \Downarrow \Updownarrow .""".split()) + + _leftDelim = Set(r"( [ { \lfloor \langle \lceil".split()) + + _rightDelim = Set(r") ] } \rfloor \rangle \rceil".split()) + def __init__(self): # All forward declarations are here font = Forward().setParseAction(self.font).setName("font") @@ -1944,15 +1962,10 @@ accent = oneOf(self._accent_map.keys() + list(self._wide_accents)) - function = oneOf("arccos csc ker min arcsin deg lg Pr arctan det " - "lim sec arg dim liminf sin cos exp limsup sinh " - "cosh gcd ln sup cot hom log tan coth inf max " - "tanh") + function = oneOf(list(self._function_names)) - fontname = oneOf("rm cal it tt sf bf") - latex2efont = oneOf("mathrm mathcal mathit mathtt mathsf mathbf " - "mathdefault mathbb mathfrak mathcircled " - "mathscr") + fontname = oneOf(list(self._fontnames)) + latex2efont = oneOf(['math' + x for x in self._fontnames]) space =(FollowedBy(bslash) + (Literal(r'\ ') @@ -1991,7 +2004,8 @@ ).setParseAction(self.accent).setName("accent") function =(Suppress(bslash) - + function).setParseAction(self.function).setName("function") + + function + ).setParseAction(self.function).setName("function") group = Group( start_group @@ -2063,11 +2077,9 @@ | placeable ) - ambiDelim = oneOf(r"""| \| / \backslash \uparrow \downarrow - \updownarrow \Uparrow \Downarrow - \Updownarrow .""") - leftDelim = oneOf(r"( [ { \lfloor \langle \lceil") - rightDelim = oneOf(r") ] } \rfloor \rangle \rceil") + ambiDelim = oneOf(self._ambiDelim) + leftDelim = oneOf(self._leftDelim) + rightDelim = oneOf(self._rightDelim) autoDelim <<(Suppress(Literal(r"\left")) + ((leftDelim | ambiDelim) | Error("Expected a delimiter")) + Group( @@ -2395,7 +2407,9 @@ super = next1 sub = next2 else: - raise ParseFatalException("Subscript/superscript sequence is too long. Use braces { } to remove ambiguity.") + raise ParseFatalException( + "Subscript/superscript sequence is too long. " + "Use braces { } to remove ambiguity.") state = self.get_state() rule_thickness = state.font_output.get_underline_thickness( @@ -2403,6 +2417,7 @@ xHeight = state.font_output.get_xheight( state.font, state.fontsize, state.dpi) + # Handle over/under symbols, such as sum or integral if self.is_overunder(nucleus): vlist = [] shift = 0. @@ -2431,6 +2446,7 @@ result = Hlist([vlist]) return [result] + # Handle regular sub/superscripts shift_up = nucleus.height - SUBDROP * xHeight if self.is_dropsub(nucleus): shift_down = nucleus.depth + SUBDROP * xHeight This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-20 22:00:54
|
Revision: 4399 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4399&view=rev Author: mdboom Date: 2007-11-20 14:00:51 -0800 (Tue, 20 Nov 2007) Log Message: ----------- Reduce file sizes for mixed-mode PDFs by only outputting the part of the image with non-transparent pixels. Minor speed improvement in MixedModeRenderer. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_agg.py branches/transforms/lib/matplotlib/backends/backend_mixed.py branches/transforms/src/_backend_agg.cpp branches/transforms/src/_backend_agg.h Modified: branches/transforms/lib/matplotlib/backends/backend_agg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-20 21:00:20 UTC (rev 4398) +++ branches/transforms/lib/matplotlib/backends/backend_agg.py 2007-11-20 22:00:51 UTC (rev 4399) @@ -68,6 +68,7 @@ self.draw_image = self._renderer.draw_image self.copy_from_bbox = self._renderer.copy_from_bbox self.restore_region = self._renderer.restore_region + self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized self.mathtext_parser = MathTextParser('Agg') self._fontd = {} Modified: branches/transforms/lib/matplotlib/backends/backend_mixed.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_mixed.py 2007-11-20 21:00:20 UTC (rev 4398) +++ branches/transforms/lib/matplotlib/backends/backend_mixed.py 2007-11-20 22:00:51 UTC (rev 4399) @@ -34,14 +34,28 @@ assert not vector_renderer.option_image_nocomposite() self._vector_renderer = vector_renderer - vector_renderer.start_rasterizing = self.start_rasterizing - vector_renderer.stop_rasterizing = self.stop_rasterizing self._raster_renderer = None self._rasterizing = False - self._renderer = self._vector_renderer + self._set_current_renderer(vector_renderer) + _methods = """ + open_group close_group draw_path draw_markers + draw_path_collection draw_quad_mesh get_image_magnification + draw_image draw_tex draw_text flipy option_image_nocomposite + get_texmanager get_text_width_height_descent new_gc + points_to_pixels strip_math finalize + """.split() + def _set_current_renderer(self, renderer): + self._renderer = renderer + + for method in self._methods: + if hasattr(renderer, method): + setattr(self, method, getattr(renderer, method)) + renderer.start_rasterizing = self.start_rasterizing + renderer.stop_rasterizing = self.stop_rasterizing + def start_rasterizing(self): """ Enter "raster" mode. All subsequent drawing commands (until @@ -54,9 +68,7 @@ if not self._rasterizing: self._raster_renderer = self._raster_renderer_class( self._width*self._dpi, self._height*self._dpi, self._dpi) - self._raster_renderer.start_rasterizing = self.start_rasterizing - self._raster_renderer.stop_rasterizing = self.stop_rasterizing - self._renderer = self._raster_renderer + self._set_current_renderer(self._raster_renderer) self._rasterizing = True def stop_rasterizing(self): @@ -69,74 +81,19 @@ start_rasterizing is called, this method has no effect. """ if self._rasterizing: + self._set_current_renderer(self._vector_renderer) + width, height = self._width * self._dpi, self._height * self._dpi - buffer = self._raster_renderer.buffer_rgba(0, 0) - image = frombuffer(buffer, width, height, True) - image.is_grayscale = False + buffer, bounds = self._raster_renderer.tostring_rgba_minimized() + l, b, w, h = bounds + if w > 0 and h > 0: + image = frombuffer(buffer, w, h, True) + image.is_grayscale = False - self._renderer = self._vector_renderer - self._renderer.draw_image(0, 0, image, None) + self._renderer.draw_image(l, height - b - h, image, None) self._raster_renderer = None self._rasterizing = False def get_canvas_width_height(self): 'return the canvas width and height in display coords' return self._width, self._height - - # The rest of this methods simply delegate to the currently active - # rendering backend. - - def open_group(self, *args, **kwargs): - return self._renderer.open_group(*args, **kwargs) - - def close_group(self, *args, **kwargs): - return self._renderer.close_group(*args, **kwargs) - - def draw_path(self, *args, **kwargs): - return self._renderer.draw_path(*args, **kwargs) - - def draw_markers(self, *args, **kwargs): - return self._renderer.draw_markers(*args, **kwargs) - - def draw_path_collection(self, *args, **kwargs): - return self._renderer.draw_path_collection(*args, **kwargs) - - def draw_quad_mesh(self, *args, **kwargs): - return self._renderer.draw_quad_mesh(*args, **kwargs) - - def get_image_magnification(self, *args, **kwargs): - return self._renderer.get_image_magnification(*args, **kwargs) - - def draw_image(self, *args, **kwargs): - return self._renderer.draw_image(*args, **kwargs) - - def draw_tex(self, *args, **kwargs): - return self._renderer.draw_tex(*args, **kwargs) - - def draw_text(self, *args, **kwargs): - return self._renderer.draw_text(*args, **kwargs) - - def flipy(self, *args, **kwargs): - return self._renderer.flipy(*args, **kwargs) - - def option_image_nocomposite(self, *args, **kwargs): - return self._vector_renderer.option_image_nocomposite(*args, **kwargs) - - def get_texmanager(self, *args, **kwargs): - return self._renderer.get_texmanager(*args, **kwargs) - - def get_text_width_height_descent(self, *args, **kwargs): - return self._renderer.get_text_width_height_descent(*args, **kwargs) - - def new_gc(self, *args, **kwargs): - return self._renderer.new_gc(*args, **kwargs) - - def points_to_pixels(self, *args, **kwargs): - return self._renderer.points_to_pixels(*args, **kwargs) - - def strip_math(self, *args, **kwargs): - return self._renderer(*args, **kwargs) - - def finalize(self, *args, **kwargs): - return self._renderer.finalize(*args, **kwargs) - Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-20 21:00:20 UTC (rev 4398) +++ branches/transforms/src/_backend_agg.cpp 2007-11-20 22:00:51 UTC (rev 4399) @@ -1474,8 +1474,66 @@ return Py::asObject(PyBuffer_FromMemory( pixBuffer+start, row_len*height-start)); } +Py::Object +RendererAgg::tostring_rgba_minimized(const Py::Tuple& args) { + args.verify_length(0); + int xmin = width; + int ymin = height; + int xmax = 0; + int ymax = 0; + + // Looks at the alpha channel to find the minimum extents of the image + unsigned char* pixel = pixBuffer + 3; + for (int y = 0; y < (int)height; ++y) { + for (int x = 0; x < (int)width; ++x) { + if (*pixel) { + if (x < xmin) xmin = x; + if (y < ymin) ymin = y; + if (x > xmax) xmax = x; + if (y > ymax) ymax = y; + } + pixel += 4; + } + } + int newwidth = 0; + int newheight = 0; + Py::String data; + if (xmin < xmax and ymin < ymax) { + // Expand the bounds by 1 pixel on all sides + xmin = std::max(0, xmin - 1); + ymin = std::max(0, ymin - 1); + xmax = std::min(xmax, (int)width); + ymax = std::min(ymax, (int)height); + + newwidth = xmax - xmin; + newheight = ymax - ymin; + int newsize = newwidth * newheight * 4; + + unsigned char* buf = new unsigned char[newsize]; + unsigned int* dst = (unsigned int*)buf; + unsigned int* src = (unsigned int*)pixBuffer; + for (int y = ymin; y < ymax; ++y) + for (int x = xmin; x < xmax; ++x, ++dst) + *dst = src[y * width + x]; + + data = Py::String((const char *)buf, (int)newsize); + } + + Py::Tuple bounds(4); + bounds[0] = Py::Int(xmin); + bounds[1] = Py::Int(ymin); + bounds[2] = Py::Int(newwidth); + bounds[3] = Py::Int(newheight); + + Py::Tuple result(2); + result[0] = data; + result[1] = bounds; + + return result; +} + Py::Object RendererAgg::clear(const Py::Tuple& args) { //"clear the rendered buffer"; @@ -1605,6 +1663,8 @@ "s = tostring_argb()"); add_varargs_method("tostring_bgra", &RendererAgg::tostring_bgra, "s = tostring_bgra()"); + add_varargs_method("tostring_rgba_minimized", &RendererAgg::tostring_rgba_minimized, + "s = tostring_rgba_minimized()"); add_varargs_method("buffer_rgba", &RendererAgg::buffer_rgba, "buffer = buffer_rgba()"); add_varargs_method("clear", &RendererAgg::clear, Modified: branches/transforms/src/_backend_agg.h =================================================================== --- branches/transforms/src/_backend_agg.h 2007-11-20 21:00:20 UTC (rev 4398) +++ branches/transforms/src/_backend_agg.h 2007-11-20 22:00:51 UTC (rev 4399) @@ -179,6 +179,7 @@ Py::Object tostring_rgb(const Py::Tuple & args); Py::Object tostring_argb(const Py::Tuple & args); Py::Object tostring_bgra(const Py::Tuple & args); + Py::Object tostring_rgba_minimized(const Py::Tuple & args); Py::Object buffer_rgba(const Py::Tuple & args); Py::Object clear(const Py::Tuple & args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-21 13:49:11
|
Revision: 4401 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4401&view=rev Author: mdboom Date: 2007-11-21 05:49:03 -0800 (Wed, 21 Nov 2007) Log Message: ----------- Merged revisions 4395-4400 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4396 | mdboom | 2007-11-20 13:25:33 -0500 (Tue, 20 Nov 2007) | 2 lines Slight speed improvement in draw_quad_mesh. ........ Modified Paths: -------------- branches/transforms/src/_backend_agg.cpp Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4394 + /trunk/matplotlib:1-4400 Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-21 13:23:54 UTC (rev 4400) +++ branches/transforms/src/_backend_agg.cpp 2007-11-21 13:49:03 UTC (rev 4401) @@ -469,7 +469,6 @@ typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; - args.verify_length(5, 6); Py::Object gc_obj = args[0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |