From: <jd...@us...> - 2007-07-20 02:10:44
|
Revision: 3580 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3580&view=rev Author: jdh2358 Date: 2007-07-19 19:10:43 -0700 (Thu, 19 Jul 2007) Log Message: ----------- reverted numerix breakage, with apologies Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/art3d.py trunk/matplotlib/lib/matplotlib/axes3d.py trunk/matplotlib/lib/matplotlib/axis.py trunk/matplotlib/lib/matplotlib/axis3d.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py trunk/matplotlib/lib/matplotlib/backends/backend_gd.py trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_paint.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/backends/backend_qt.py trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/colors.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/lib/matplotlib/finance.py trunk/matplotlib/lib/matplotlib/image.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/lib/matplotlib/mlab.py trunk/matplotlib/lib/matplotlib/numerix/__init__.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/proj3d.py trunk/matplotlib/lib/matplotlib/table.py trunk/matplotlib/lib/matplotlib/texmanager.py trunk/matplotlib/lib/matplotlib/text.py trunk/matplotlib/lib/matplotlib/units.py trunk/matplotlib/lib/matplotlib/widgets.py trunk/matplotlib/mpl1/mpl1.py trunk/matplotlib/mpl1/mtraits.py trunk/matplotlib/setup.py Modified: trunk/matplotlib/lib/matplotlib/art3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -12,7 +12,7 @@ from colors import Normalize from cm import jet -import numpy as npy +import numerix as nx import proj3d class Wrap2D: @@ -254,8 +254,8 @@ segis.append((si,ei)) si = ei xs,ys,zs = zip(*points) - ones = npy.ones(len(xs)) - self.vec = npy.array([xs,ys,zs,ones]) + ones = nx.ones(len(xs)) + self.vec = nx.array([xs,ys,zs,ones]) self.segis = segis def draw3d(self, renderer): Modified: trunk/matplotlib/lib/matplotlib/axes3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes3d.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/axes3d.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -17,7 +17,7 @@ from transforms import unit_bbox import figure -import numpy as npy +import numerix as nx from colors import Normalize import art3d @@ -122,8 +122,8 @@ self.zz_dataLim.intervalx, self) def unit_cube(self,vals=None): - minpy,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims() - xs,ys,zs = ([minpy,maxx,maxx,minpy,minpy,maxx,maxx,minpy], + minx,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims() + xs,ys,zs = ([minx,maxx,maxx,minx,minx,maxx,maxx,minx], [miny,miny,maxy,maxy,miny,miny,maxy,maxy], [minz,minz,minz,minz,maxz,maxz,maxz,maxz]) return zip(xs,ys,zs) @@ -186,7 +186,7 @@ pass def auto_scale_xyz(self, X,Y,Z=None,had_data=None): - x,y,z = map(npy.asarray, (X,Y,Z)) + x,y,z = map(nx.asarray, (X,Y,Z)) try: x,y = X.flat,Y.flat if Z is not None: @@ -216,10 +216,10 @@ self.set_w_zlim(locator.autoscale()) def get_w_lims(self): - minpy,maxx = self.get_w_xlim() + minx,maxx = self.get_w_xlim() miny,maxy = self.get_w_ylim() minz,maxz = self.get_w_zlim() - return minpy,maxx,miny,maxy,minz,maxz + return minx,maxx,miny,maxy,minz,maxz def set_w_zlim(self, *args, **kwargs): gl,self.get_xlim = self.get_xlim,self.get_w_zlim @@ -257,7 +257,7 @@ def pany(self, numsteps): print 'numsteps', numsteps - def panpy(self, numsteps): + def panx(self, numsteps): print 'numsteps', numsteps def view_init(self, elev, azim): @@ -276,7 +276,7 @@ point. """ - relev,razim = npy.pi * self.elev/180, npy.pi * self.azim/180 + relev,razim = nx.pi * self.elev/180, nx.pi * self.azim/180 xmin,xmax = self.get_w_xlim() ymin,ymax = self.get_w_ylim() @@ -288,29 +288,29 @@ zmin,zmax) # look into the middle of the new coordinates - R = npy.array([0.5,0.5,0.5]) + R = nx.array([0.5,0.5,0.5]) # - xp = R[0] + npy.cos(razim)*npy.cos(relev)*self.dist - yp = R[1] + npy.sin(razim)*npy.cos(relev)*self.dist - zp = R[2] + npy.sin(relev)*self.dist + xp = R[0] + nx.cos(razim)*nx.cos(relev)*self.dist + yp = R[1] + nx.sin(razim)*nx.cos(relev)*self.dist + zp = R[2] + nx.sin(relev)*self.dist - E = npy.array((xp, yp, zp)) + E = nx.array((xp, yp, zp)) # self.eye = E self.vvec = R - E self.vvec = self.vvec / proj3d.mod(self.vvec) - if abs(relev) > npy.pi/2: + if abs(relev) > nx.pi/2: # upside down - V = npy.array((0,0,-1)) + V = nx.array((0,0,-1)) else: - V = npy.array((0,0,1)) + V = nx.array((0,0,1)) zfront,zback = -self.dist,self.dist viewM = proj3d.view_transformation(E,R,V) perspM = proj3d.persp_transformation(zfront,zback) - M0 = npy.dot(viewM,worldM) - M = npy.dot(perspM,M0) + M0 = nx.matrixmultiply(viewM,worldM) + M = nx.matrixmultiply(perspM,M0) return M def mouse_init(self): @@ -383,8 +383,8 @@ # scale the z value to match x0,y0,z0 = p0 x1,y1,z1 = p1 - d0 = npy.hypot(x0-xd,y0-yd) - d1 = npy.hypot(x1-xd,y1-yd) + d0 = nx.hypot(x0-xd,y0-yd) + d1 = nx.hypot(x1-xd,y1-yd) dt = d0+d1 z = d1/dt * z0 + d0/dt * z1 #print 'mid', edgei, d0, d1, z0, z1, z @@ -435,12 +435,12 @@ elif self.button_pressed == 3: # zoom view # hmmm..this needs some help from clipping.... - minpy,maxx,miny,maxy,minz,maxz = self.get_w_lims() + minx,maxx,miny,maxy,minz,maxz = self.get_w_lims() df = 1-((h - dy)/h) - dx = (maxx-minpy)*df + dx = (maxx-minx)*df dy = (maxy-miny)*df dz = (maxz-minz)*df - self.set_w_xlim(minpy-dx,maxx+dx) + self.set_w_xlim(minx-dx,maxx+dx) self.set_w_ylim(miny-dy,maxy+dy) self.set_w_zlim(minz-dz,maxz+dz) self.get_proj() @@ -504,14 +504,14 @@ had_data = self.has_data() rows, cols = Z.shape - tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z) + tX,tY,tZ = nx.transpose(X), nx.transpose(Y), nx.transpose(Z) rstride = cbook.popd(kwargs, 'rstride', 10) cstride = cbook.popd(kwargs, 'cstride', 10) # polys = [] boxes = [] - for rs in npy.arange(0,rows,rstride): - for cs in npy.arange(0,cols,cstride): + for rs in nx.arange(0,rows,rstride): + for cs in nx.arange(0,cols,cstride): ps = [] corners = [] for a,ta in [(X,tX),(Y,tY),(Z,tZ)]: @@ -522,9 +522,9 @@ zright = ta[cs][rs:min(rows-1,rs+rstride):] zright = zright[::-1] corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]]) - z = npy.concatenate((ztop,zleft,zbase,zright)) + z = nx.concatenate((ztop,zleft,zbase,zright)) ps.append(z) - boxes.append(map(npy.array,zip(*corners))) + boxes.append(map(nx.array,zip(*corners))) polys.append(zip(*ps)) # lines = [] @@ -533,10 +533,10 @@ n = proj3d.cross(box[0]-box[1], box[0]-box[2]) n = n/proj3d.mod(n)*5 - shade.append(npy.dot(n,[-1,-1,0.5])) + shade.append(nx.dot(n,[-1,-1,0.5])) lines.append((box[0],n+box[0])) # - color = npy.array([0,0,1,1]) + color = nx.array([0,0,1,1]) norm = Normalize(min(shade),max(shade)) colors = [color * (0.5+norm(v)*0.5) for v in shade] for c in colors: c[3] = 1 @@ -554,7 +554,7 @@ had_data = self.has_data() rows,cols = Z.shape - tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z) + tX,tY,tZ = nx.transpose(X), nx.transpose(Y), nx.transpose(Z) rii = [i for i in range(0,rows,rstride)]+[rows-1] cii = [i for i in range(0,cols,cstride)]+[cols-1] @@ -718,7 +718,7 @@ def get_test_data(delta=0.05): from mlab import meshgrid, bivariate_normal - x = y = npy.arange(-3.0, 3.0, delta) + x = y = nx.arange(-3.0, 3.0, delta) X, Y = meshgrid(x,y) Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) @@ -764,8 +764,8 @@ def test_plot(): ax = Axes3D() - xs = npy.arange(0,4*npy.pi+0.1,0.1) - ys = npy.sin(xs) + xs = nx.arange(0,4*nx.pi+0.1,0.1) + ys = nx.sin(xs) ax.plot(xs,ys, label='zl') ax.plot(xs,ys+max(xs),label='zh') ax.plot(xs,ys,dir='x', label='xl') @@ -785,7 +785,7 @@ cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6) ax = Axes3D() - xs = npy.arange(0,10,0.4) + xs = nx.arange(0,10,0.4) verts = [] zs = [0.0,1.0,2.0,3.0] for z in zs: @@ -817,7 +817,7 @@ ax = Axes3D() for c,z in zip(['r','g','b','y'],[30,20,10,0]): - xs = npy.arange(20) + xs = nx.arange(20) ys = [random.random() for x in xs] ax.bar(xs,ys,z=z,dir='y',color=c) #ax.plot(xs,ys) Modified: trunk/matplotlib/lib/matplotlib/axis.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/axis.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -7,13 +7,14 @@ import re import sys -from numpy import arange, array, asarray, ones, zeros, \ - nonzero, take, log10, logical_and, \ - dot, sin, cos, tan, pi, sqrt, linspace +from numerix import arange, array, asarray, ones, zeros, \ + nonzero, take, Float, log10, logical_and, \ + dot, sin, cos, tan, pi, sqrt from artist import Artist, setp from cbook import enumerate, silent_list, popall, CallbackRegistry from lines import Line2D, TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN +from mlab import linspace from matplotlib import rcParams from patches import bbox_artist from ticker import NullFormatter, FixedFormatter, ScalarFormatter, LogFormatter @@ -117,7 +118,7 @@ def contains(self, mouseevent): """Test whether the mouse event occured in the Tick marks. - + This function always returns false. It is more useful to test if the axis as a whole contains the mouse rather than the set of tick marks. """ @@ -491,7 +492,7 @@ LABELPAD = 5 OFFSETTEXTPAD = 3 - def __str__(self): + def __str__(self): return str(self.__class__).split('.')[-1] \ + "(%d,%d)"%self.axes.transAxes.xy_tup((0,0)) @@ -656,7 +657,7 @@ def get_offset_text(self): 'Return the axis offsetText as a Text instance' return self.offsetText - + def get_pickradius(self): 'Return the depth of the axis used by the picker' return self.pickradius @@ -900,11 +901,11 @@ self.minor.locator = locator self.minor.locator.set_view_interval( self.get_view_interval() ) self.minor.locator.set_data_interval( self.get_data_interval() ) - + def set_pickradius(self, pickradius): """ Set the depth of the axis used by the picker - + ACCEPTS: a distance in points """ self.pickradius = pickradius @@ -966,12 +967,12 @@ class XAxis(Axis): __name__ = 'xaxis' - + def contains(self,mouseevent): """Test whether the mouse event occured in the x axis. """ if callable(self._contains): return self._contains(self,mouseevent) - + xpixel,ypixel = mouseevent.x,mouseevent.y try: xaxes,yaxes = self.axes.transAxes.inverse_xy_tup((xpixel,ypixel)) @@ -1154,11 +1155,11 @@ def contains(self,mouseevent): """Test whether the mouse event occurred in the y axis. - + Returns T/F, {} """ if callable(self._contains): return self._contains(self,mouseevent) - + xpixel,ypixel = mouseevent.x,mouseevent.y try: xaxes,yaxes = self.axes.transAxes.inverse_xy_tup((xpixel,ypixel)) Modified: trunk/matplotlib/lib/matplotlib/axis3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis3d.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/axis3d.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -13,7 +13,7 @@ import art3d import proj3d -from numpy import sin, cos, pi, cumsum, dot, asarray, array, \ +from numerix import sin, cos, pi, cumsum, dot, asarray, array, \ where, nonzero, equal, sqrt def norm_angle(a): Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -437,7 +437,7 @@ def points_to_pixels(self, points): """ Convert points to display units - points - a float or a numpy array of float + points - a float or a numerix array of float return points converted to pixels You need to override this function (unless your backend doesn't have a @@ -891,24 +891,24 @@ #print "leaving:",[str(a) for a in leave] # On leave restore the captured colour for a in leave: - if hasattr(a,'get_color'): + if hasattr(a,'get_color'): a.set_color(self._active[a]) - elif hasattr(a,'get_edgecolor'): + elif hasattr(a,'get_edgecolor'): a.set_edgecolor(self._active[a][0]) a.set_facecolor(self._active[a][1]) del self._active[a] # On enter, capture the color and repaint the artist - # with the highlight colour. Capturing colour has to - # be done first in case the parent recolouring affects + # with the highlight colour. Capturing colour has to + # be done first in case the parent recolouring affects # the child. for a in enter: - if hasattr(a,'get_color'): + if hasattr(a,'get_color'): self._active[a] = a.get_color() elif hasattr(a,'get_edgecolor'): self._active[a] = (a.get_edgecolor(),a.get_facecolor()) else: self._active[a] = None for a in enter: - if hasattr(a,'get_color'): + if hasattr(a,'get_color'): a.set_color('red') elif hasattr(a,'get_edgecolor'): a.set_edgecolor('red') Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -73,7 +73,7 @@ import os, sys import matplotlib from matplotlib import verbose, rcParams -from numpy import array, zeros, transpose, fliplr +from matplotlib.numerix import array, Float, zeros, transpose from matplotlib._image import fromarray from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase,\ @@ -85,6 +85,7 @@ from matplotlib.ft2font import FT2Font from matplotlib.mathtext import math_parse_s_ft2font from matplotlib.transforms import lbwh_to_bbox +from matplotlib.numerix.mlab import fliplr from _backend_agg import RendererAgg as _RendererAgg @@ -153,8 +154,8 @@ point in x, y """ if __debug__: verbose.report('RendererAgg.draw_line', 'debug-annoying') - x = array([x1,x2], float) - y = array([y1,y2], float) + x = array([x1,x2], typecode=Float) + y = array([y1,y2], typecode=Float) self._renderer.draw_lines(gc, x, y) @@ -272,7 +273,7 @@ def func(x): return transpose(fliplr(x)) - Z = zeros((n,m,4), float) + Z = zeros((n,m,4), typecode=Float) Z[:,:,0] = func(r) Z[:,:,1] = func(g) Z[:,:,2] = func(b) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -8,7 +8,7 @@ import matplotlib.agg as agg from matplotlib import verbose -from numpy import array +from matplotlib.numerix import array, Float from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase,\ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -38,7 +38,7 @@ from matplotlib.cbook import enumerate, izip from matplotlib.figure import Figure from matplotlib.mathtext import math_parse_s_ft2font -import numpy as npy +import matplotlib.numerix as numx from matplotlib.transforms import Bbox from matplotlib import rcParams @@ -137,8 +137,8 @@ ctx.rotate(rotation) ctx.scale(width / 2.0, height / 2.0) ctx.new_sub_path() - ctx.arc(0.0, 0.0, 1.0, npy.pi * angle1 / 180., - npy.pi * angle2 / 180.) + ctx.arc(0.0, 0.0, 1.0, numx.pi * angle1 / 180., + numx.pi * angle2 / 180.) ctx.restore() self._fill_and_stroke (ctx, rgbFace) @@ -243,7 +243,7 @@ # render by drawing a 0.5 radius circle ctx = gc.ctx ctx.new_path() - ctx.arc (x, self.height - y, 0.5, 0, 2*npy.pi) + ctx.arc (x, self.height - y, 0.5, 0, 2*numx.pi) self._fill_and_stroke (ctx, gc.get_rgb()) @@ -294,7 +294,7 @@ ctx.save() if angle: - ctx.rotate (-angle * npy.pi / 180) + ctx.rotate (-angle * numx.pi / 180) ctx.set_font_size (size) ctx.show_text (s) ctx.restore() @@ -304,7 +304,7 @@ if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) # mathtext using the gtk/gdk method - #if npy.which[0] == "numarray": + #if numx.which[0] == "numarray": # warnings.warn("_draw_mathtext() currently works for numpy, but " # "not numarray") # return @@ -327,21 +327,21 @@ N = imw*imh # a numpixels by num fonts array - Xall = npy.zeros((N,len(fonts)), npy.uint8) + Xall = numx.zeros((N,len(fonts)), typecode=numx.UInt8) for i, font in enumerate(fonts): if angle == 90: font.horiz_image_to_vert_image() # <-- Rotate imw, imh, s = font.image_as_str() - Xall[:,i] = npy.fromstring(s, npy.uint8) + Xall[:,i] = numx.fromstring(s, numx.UInt8) # get the max alpha at each pixel - Xs = npy.mlab.max (Xall,1) + Xs = numx.mlab.max (Xall,1) # convert it to it's proper shape Xs.shape = imh, imw - pa = npy.zeros((imh,imw,4), npy.uint8) + pa = numx.zeros(shape=(imh,imw,4), typecode=numx.UInt8) rgb = gc.get_rgb() pa[:,:,0] = int(rgb[0]*255) pa[:,:,1] = int(rgb[1]*255) @@ -469,7 +469,7 @@ self.ctx.set_dash([], 0) # switch dashes off else: self.ctx.set_dash ( - self.renderer.points_to_pixels (npy.asarray(dashes)), offset) + self.renderer.points_to_pixels (numx.asarray(dashes)), offset) def set_foreground(self, fg, isRGB=None): @@ -593,7 +593,7 @@ ctx = renderer.ctx if orientation == 'landscape': - ctx.rotate (npy.pi/2) + ctx.rotate (numx.pi/2) ctx.translate (0, -height_in_points) # cairo/src/cairo_ps_surface.c # '%%Orientation: Portrait' is always written to the file header Modified: trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -17,8 +17,6 @@ import os.path -from numpy import asarray - import matplotlib from matplotlib import rcParams, verbose @@ -28,6 +26,7 @@ NavigationToolbar2, cursors from matplotlib.figure import Figure from matplotlib._pylab_helpers import Gcf +from matplotlib.numerix import asarray import matplotlib.windowing as windowing from matplotlib.widgets import SubplotTool Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gd.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gd.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gd.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -12,7 +12,6 @@ sys.exit() -from numpy import ones, array, int16, asarray from matplotlib.backend_bases import RendererBase, \ GraphicsContextBase, FigureManagerBase, FigureCanvasBase @@ -23,6 +22,7 @@ from matplotlib.figure import Figure from matplotlib.transforms import Bbox from matplotlib.font_manager import fontManager +from matplotlib.numerix import ones, array, nx, asarray # support old font names if (os.environ.has_key('GDFONTPATH') and not os.environ.has_key('TTFPATH')): @@ -115,8 +115,8 @@ point in x, y """ - x = x.astype(int16) - y = self.height*ones(y.shape, int16) - y.astype(int16) + x = x.astype(nx.Int16) + y = self.height*ones(y.shape, nx.Int16) - y.astype(nx.Int16) style = self._set_gd_style(gc) self.im.lines( zip(x,y), style) self.flush_clip() Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -16,9 +16,6 @@ % (gtk.pygtk_version + pygtk_version_required)) del pygtk_version_required -from numpy import amax, asarray, fromstring, int16, uint8, zeros, \ - where, transpose, nonzero, indices, ones - import matplotlib from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ @@ -26,7 +23,11 @@ from matplotlib.cbook import is_string_like, enumerate from matplotlib.figure import Figure from matplotlib.mathtext import math_parse_s_ft2font +import matplotlib.numerix as numerix +from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ + where, transpose, nonzero, indices, ones, nx + from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array @@ -105,7 +106,7 @@ im.flipud_out() rows, cols, image_str = im.as_rgba_str() - image_array = fromstring(image_str, uint8) + image_array = fromstring(image_str, UInt8) image_array.shape = rows, cols, 4 pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, @@ -143,8 +144,8 @@ def draw_lines(self, gc, x, y, transform=None): if gc.gdkGC.line_width > 0: - x = x.astype(int16) - y = self.height - y.astype(int16) + x = x.astype(nx.Int16) + y = self.height - y.astype(nx.Int16) self.gdkDrawable.draw_lines(gc.gdkGC, zip(x,y)) @@ -212,16 +213,16 @@ N = imw*imh # a numpixels by num fonts array - Xall = zeros((N,len(fonts)), uint8) + Xall = zeros((N,len(fonts)), typecode=UInt8) for i, font in enumerate(fonts): if angle == 90: font.horiz_image_to_vert_image() # <-- Rotate imw, imh, image_str = font.image_as_str() - Xall[:,i] = fromstring(image_str, uint8) + Xall[:,i] = fromstring(image_str, UInt8) # get the max alpha at each pixel - Xs = amax(Xall,axis=1) + Xs = numerix.mlab.max(Xall,1) # convert it to it's proper shape Xs.shape = imh, imw Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -22,8 +22,9 @@ from matplotlib.cbook import is_string_like, enumerate from matplotlib.colors import colorConverter from matplotlib.figure import Figure -from numpy import asarray, fromstring, zeros, \ - where, transpose, nonzero, indices, ones +import matplotlib.numerix as numerix +from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ + where, transpose, nonzero, indices, ones, nx from matplotlib.widgets import SubplotTool from matplotlib import lines @@ -155,7 +156,7 @@ gdk.LEAVE_NOTIFY_MASK | gdk.POINTER_MOTION_MASK | gdk.POINTER_MOTION_HINT_MASK) - + def __init__(self, figure): if _debug: print 'FigureCanvasGTK.%s' % fn_name() FigureCanvasBase.__init__(self, figure) @@ -1086,7 +1087,7 @@ hbox.show_all() self.set_extra_widget(hbox) - + def get_filename_from_user (self): while True: filename = None @@ -1136,7 +1137,7 @@ def __init__(self, lines): import gtk.glade - + datadir = matplotlib.get_data_path() gladefile = os.path.join(datadir, 'lineprops.glade') if not os.path.exists(gladefile): @@ -1278,7 +1279,7 @@ # Unfortunately, the SVG renderer (rsvg) leaks memory under earlier # versions of pygtk, so we have to use a PNG file instead. try: - + if gtk.pygtk_version < (2, 8, 0): icon_filename = 'matplotlib.png' else: Modified: trunk/matplotlib/lib/matplotlib/backends/backend_paint.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_paint.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_paint.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -16,10 +16,8 @@ import sys import os import paint - -from numpy import asarray - from matplotlib import verbose +from matplotlib.numerix import asarray from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase,\ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -28,7 +28,7 @@ from matplotlib.dviread import Dvi from matplotlib.ft2font import FT2Font, FIXED_WIDTH, ITALIC, LOAD_NO_SCALE from matplotlib.mathtext import math_parse_s_pdf -from numpy import float32, uint8, fromstring, arange, infinity, isnan, asarray +from matplotlib.numerix import Float32, UInt8, fromstring, arange, infinity, isnan, asarray from matplotlib.transforms import Bbox from matplotlib import ttconv @@ -543,13 +543,13 @@ fontdict['FontMatrix'] = [ .001, 0, 0, .001, 0, 0 ] fontdict['CharProcs'] = charprocsObject fontdict['Encoding'] = { - 'Type': Name('Encoding'), + 'Type': Name('Encoding'), 'Differences': differencesArray} elif fonttype == 42: fontdict['Subtype'] = Name('TrueType') fontdict['Encoding'] = Name('WinAnsiEncoding') - + flags = 0 symbolic = False #ps_name.name in ('Cmsy10', 'Cmmi10', 'Cmex10') if ff & FIXED_WIDTH: flags |= 1 << 0 @@ -632,7 +632,7 @@ self.beginStream(charprocObject.id, None, {'Length': len(stream)}) - self.currentstream.write(stream) + self.currentstream.write(stream) self.endStream() charprocs[charname] = charprocObject self.writeObject(charprocsObject, charprocs) @@ -755,20 +755,20 @@ def _rgb(self, im): h,w,s = im.as_rgba_str() - rgba = fromstring(s, uint8) + rgba = fromstring(s, UInt8) rgba.shape = (h, w, 4) rgb = rgba[:,:,:3] return h, w, rgb.tostring() def _gray(self, im, rc=0.3, gc=0.59, bc=0.11): rgbat = im.as_rgba_str() - rgba = fromstring(rgbat[2], uint8) + rgba = fromstring(rgbat[2], UInt8) rgba.shape = (rgbat[0], rgbat[1], 4) - rgba_f = rgba.astype(float32) + rgba_f = rgba.astype(Float32) r = rgba_f[:,:,0] g = rgba_f[:,:,1] b = rgba_f[:,:,2] - gray = (r*rc + g*gc + b*bc).astype(uint8) + gray = (r*rc + g*gc + b*bc).astype(UInt8) return rgbat[0], rgbat[1], gray.tostring() def writeImages(self): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -26,7 +26,7 @@ from matplotlib.transforms import get_vec6_scales -from numpy import uint8, float32, alltrue, array, ceil, equal, \ +from matplotlib.numerix import UInt8, Float32, alltrue, array, ceil, equal, \ fromstring, nonzero, ones, put, take, where, isnan import binascii import re @@ -336,20 +336,20 @@ def _rgb(self, im): h,w,s = im.as_rgba_str() - rgba = fromstring(s, uint8) + rgba = fromstring(s, UInt8) rgba.shape = (h, w, 4) rgb = rgba[:,:,:3] return h, w, rgb.tostring() def _gray(self, im, rc=0.3, gc=0.59, bc=0.11): rgbat = im.as_rgba_str() - rgba = fromstring(rgbat[2], uint8) + rgba = fromstring(rgbat[2], UInt8) rgba.shape = (rgbat[0], rgbat[1], 4) - rgba_f = rgba.astype(float32) + rgba_f = rgba.astype(Float32) r = rgba_f[:,:,0] g = rgba_f[:,:,1] b = rgba_f[:,:,2] - gray = (r*rc + g*gc + b*bc).astype(uint8) + gray = (r*rc + g*gc + b*bc).astype(UInt8) return rgbat[0], rgbat[1], gray.tostring() def _hex_lines(self, s, chars_per_line=128): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -5,8 +5,9 @@ import matplotlib from matplotlib import verbose -from numpy import asarray, fromstring, zeros, \ - where, transpose, nonzero, indices, ones +from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ + where, transpose, nonzero, indices, ones, nx +import matplotlib.numerix as numerix from matplotlib.cbook import is_string_like, enumerate, onetrue from matplotlib.font_manager import fontManager from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ @@ -322,7 +323,7 @@ for text, tooltip_text, image_file, callback in self.toolitems: if text is not None: qt.QObject.disconnect( self.buttons[ text ], - qt.SIGNAL( 'clicked()' ), + qt.SIGNAL( 'clicked()' ), getattr( self, callback ) ) def pan( self, *args ): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -5,8 +5,9 @@ import matplotlib from matplotlib import verbose -from numpy import asarray, fromstring, zeros, \ - where, transpose, nonzero, indices, ones +from matplotlib.numerix import asarray, fromstring, UInt8, zeros, \ + where, transpose, nonzero, indices, ones, nx +import matplotlib.numerix as numerix from matplotlib.cbook import is_string_like, enumerate, onetrue from matplotlib.font_manager import fontManager from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -10,8 +10,6 @@ import os.path -from numpy import asarray - import matplotlib from matplotlib.cbook import is_string_like, enumerate from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ @@ -19,6 +17,7 @@ from matplotlib.figure import Figure from matplotlib._pylab_helpers import Gcf +from matplotlib.numerix import asarray import matplotlib.windowing as windowing from matplotlib.widgets import SubplotTool Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/collections.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -145,14 +145,14 @@ def contains(self, mouseevent): """ Test whether the mouse event occurred in the collection. - + Returns T/F, dict(ind=itemlist), where every item in itemlist contains the event. """ if callable(self._contains): return self._contains(self,mouseevent) # TODO: Consider doing the test in data coordinates # Patch transforms the mouse into data coordinates and does the # test for membership there. This is more efficient though it - # may not match the visual appearance of the polygon on the + # may not match the visual appearance of the polygon on the # screen. Regardless, patch and patch collection should use # the same algorithm. Here's the code in patch: # @@ -338,7 +338,7 @@ """ verts is a sequence of ( verts0, verts1, ...) where verts_i is a sequence of xy tuples of vertices, or an equivalent - numpy array of shape (nv,2). + numerix array of shape (nv,2). %(PatchCollection)s """ @@ -461,7 +461,7 @@ def get_transformed_patches(self): # Shouldn't need all these calls to asarray; # the variables should be converted when stored. - # Similar speedups with numpy should be attainable + # Similar speedups with numerix should be attainable # in many other places. verts = npy.asarray(self._verts) offsets = npy.asarray(self._offsets) @@ -588,7 +588,7 @@ """ segments is a sequence of ( line0, line1, line2), where linen = (x0, y0), (x1, y1), ... (xm, ym), or the - equivalent numpy array with two columns. + equivalent numerix array with two columns. Each line can be a different length. colors must be a tuple of RGBA tuples (eg arbitrary color @@ -616,7 +616,7 @@ norm = None, # optional for ScalarMappable cmap = None, # ditto - + pickradius is the tolerance for mouse clicks picking a line. The default is 5 pt. @@ -659,7 +659,7 @@ def contains(self, mouseevent): """ Test whether the mouse event occurred in the collection. - + Returns T/F, dict(ind=itemlist), where every item in itemlist contains the event. """ import matplotlib.lines as ML @@ -679,7 +679,7 @@ this_ind = ML.segment_hits(mx,my,xy[:,0],xy[:,1],self.pickradius) ind.extend([(this,k) for k in this_ind]) return len(ind)>0,dict(ind=ind) - + def set_pickradius(self,pickradius): self.pickradius = 5 def get_pickradius(self): return self.pickradius Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/colors.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -432,7 +432,7 @@ mask_bad = ma.getmask(xma) if xa.dtype.char in npy.typecodes['Float']: npy.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1. - xa = (xa * self.N).astype(int) + xa = (xa * self.N).astype(npy.int) # Set the over-range indices before the under-range; # otherwise the under-range values get converted to over-range. npy.putmask(xa, xa>self.N-1, self._i_over) Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/figure.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -16,7 +16,8 @@ from legend import Legend from transforms import Bbox, Value, Point, get_bbox_transform, unit_bbox -from numpy import array, clip, transpose, minimum, maximum, linspace, meshgrid +from numerix import array, clip, transpose, minimum, maximum +from mlab import linspace, meshgrid from ticker import FormatStrFormatter from cm import ScalarMappable from contour import ContourSet Modified: trunk/matplotlib/lib/matplotlib/finance.py =================================================================== --- trunk/matplotlib/lib/matplotlib/finance.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/finance.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -12,8 +12,6 @@ except ImportError: raise SystemExit('The finance module requires datetime support (python2.3)') -import numpy as npy - from matplotlib import verbose, get_configdir from artist import Artist from dates import date2num, num2date @@ -22,6 +20,7 @@ from matplotlib.colors import colorConverter from lines import Line2D, TICKLEFT, TICKRIGHT from patches import Rectangle +import matplotlib.numerix as nx from matplotlib.transforms import scale_transform, Value, zero, one, \ scale_sep_transform, blend_xy_sep_transform @@ -77,7 +76,7 @@ if asobject: if len(results)==0: return None else: - date, open, close, high, low, volume = map(npy.asarray, zip(*results)) + date, open, close, high, low, volume = map(nx.asarray, zip(*results)) return Bunch(date=date, open=open, close=close, high=high, low=low, volume=volume) else: @@ -378,10 +377,10 @@ ) closeCollection.set_transform(tickTransform) - minpy, maxx = (0, len(rangeSegments)) + minx, maxx = (0, len(rangeSegments)) miny = min([low for low in lows if low !=-1]) maxy = max([high for high in highs if high != -1]) - corners = (minpy, miny), (maxx, maxy) + corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) ax.autoscale_view() @@ -467,11 +466,11 @@ - minpy, maxx = (0, len(rangeSegments)) + minx, maxx = (0, len(rangeSegments)) miny = min([low for low in lows if low !=-1]) maxy = max([high for high in highs if high != -1]) - corners = (minpy, miny), (maxx, maxy) + corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) ax.autoscale_view() @@ -534,10 +533,10 @@ - minpy, maxx = (0, len(offsetsBars)) + minx, maxx = (0, len(offsetsBars)) miny = 0 maxy = max([v for v in volumes if v!=-1]) - corners = (minpy, miny), (maxx, maxy) + corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) ax.autoscale_view() @@ -627,10 +626,10 @@ - minpy, maxx = (min(dates), max(dates)) + minx, maxx = (min(dates), max(dates)) miny = 0 maxy = max([volume for d, open, close, high, low, volume in quotes]) - corners = (minpy, miny), (maxx, maxy) + corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) #print 'datalim', ax.dataLim.get_bounds() #print 'viewlim', ax.viewLim.get_bounds() @@ -684,10 +683,10 @@ - minpy, maxx = (0, len(offsetsBars)) + minx, maxx = (0, len(offsetsBars)) miny = 0 maxy = max([v for v in vals if v!=-1]) - corners = (minpy, miny), (maxx, maxy) + corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) ax.autoscale_view() Modified: trunk/matplotlib/lib/matplotlib/image.py =================================================================== --- trunk/matplotlib/lib/matplotlib/image.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/image.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -9,8 +9,9 @@ from artist import Artist from colors import colorConverter import cm +import numerix import numerix.ma as ma -from numpy import arange, asarray, uint8, float32, repeat, newaxis, fromstring +from numerix import arange, asarray, UInt8, Float32, repeat, NewAxis, typecode import _image @@ -116,7 +117,7 @@ raise RuntimeError('You must first set the image array or the image attribute') if self._imcache is None: - if self._A.dtype == uint8 and len(self._A.shape) == 3: + if typecode(self._A) == UInt8 and len(self._A.shape) == 3: im = _image.frombyte(self._A, 0) im.is_grayscale = False else: @@ -185,7 +186,7 @@ """Test whether the mouse event occured within the image. """ if callable(self._contains): return self._contains(self,mouseevent) - # TODO: make sure this is consistent with patch and patch + # TODO: make sure this is consistent with patch and patch # collection on nonlinear transformed coordinates. # TODO: consider returning image coordinates (shouldn't # be too difficult given that the image is rectilinear @@ -196,7 +197,7 @@ inside = xdata>=xmin and xdata<=xmax and ydata>=ymin and ydata<=ymax else: inside = False - + return inside,{} def write_png(self, fname, noscale=False): @@ -332,8 +333,8 @@ return im def set_data(self, x, y, A): - x = asarray(x,float32) - y = asarray(y,float32) + x = asarray(x).astype(Float32) + y = asarray(y).astype(Float32) A = asarray(A) if len(x.shape) != 1 or len(y.shape) != 1\ or A.shape[0:2] != (y.shape[0], x.shape[0]): @@ -345,16 +346,16 @@ if len(A.shape) == 3 and A.shape[2] == 1: A.shape = A.shape[0:2] if len(A.shape) == 2: - if A.dtype != uint8: - A = (self.cmap(self.norm(A))*255).astype(uint8) + if typecode(A) != UInt8: + A = (self.cmap(self.norm(A))*255).astype(UInt8) else: - A = repeat(A[:,:,newaxis], 4, 2) + A = repeat(A[:,:,NewAxis], 4, 2) A[:,:,3] = 255 else: - if A.dtype != uint8: - A = (255*A).astype(uint8) + if typecode(A) != UInt8: + A = (255*A).astype(UInt8) if A.shape[2] == 3: - B = zeros(tuple(list(A.shape[0:2]) + [4]), uint8) + B = zeros(tuple(list(A.shape[0:2]) + [4]), UInt8) B[:,:,0:3] = A B[:,:,3] = 255 A = B @@ -427,7 +428,7 @@ inside = xdata>=xmin and xdata<=xmax and ydata>=ymin and ydata<=ymax else: inside = False - + return inside,{} def get_size(self): @@ -440,7 +441,7 @@ def get_extent(self): 'get the image extent: left, right, bottom, top' numrows, numcols = self.get_size() - return (-0.5+self.ox, numcols-0.5+self.ox, + return (-0.5+self.ox, numcols-0.5+self.ox, -0.5+self.oy, numrows-0.5+self.oy) def make_image(self, magnification=1.0): @@ -476,7 +477,7 @@ def imread(fname): """ - return image file in fname as numpy array + return image file in fname as numerix array Return value is a MxNx4 array of 0-1 normalized floats @@ -503,6 +504,6 @@ raise RuntimeError('Unknown image mode') x_str = im.tostring('raw',im.mode,0,-1) - x = fromstring(x_str,uint8) + x = numerix.fromstring(x_str,numerix.UInt8) x.shape = im.size[1], im.size[0], 4 return x Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/legend.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -22,7 +22,7 @@ """ from __future__ import division import sys, warnings -from numpy import array, ones, linspace +from numerix import array, ones, Float from matplotlib import verbose, rcParams @@ -30,7 +30,7 @@ from cbook import enumerate, is_string_like, iterable, silent_list from font_manager import FontProperties from lines import Line2D -from mlab import segments_intersect +from mlab import linspace, segments_intersect from patches import Patch, Rectangle, RegularPolygon, Shadow, bbox_artist, draw_bbox from collections import LineCollection, RegularPolyCollection, PatchCollection from text import Text @@ -280,7 +280,7 @@ x, y = label.get_position() x -= self.handlelen + self.handletextsep if isinstance(handle, Line2D): - ydata = (y-HEIGHT/2)*ones(self._xdata.shape, float) + ydata = (y-HEIGHT/2)*ones(self._xdata.shape, Float) legline = Line2D(self._xdata, ydata) legline.update_from(handle) self._set_artist_props(legline) # after update @@ -298,7 +298,7 @@ p.set_clip_box(None) ret.append(p) elif isinstance(handle, LineCollection): - ydata = (y-HEIGHT/2)*ones(self._xdata.shape, float) + ydata = (y-HEIGHT/2)*ones(self._xdata.shape, Float) legline = Line2D(self._xdata, ydata) self._set_artist_props(legline) legline.set_clip_box(None) @@ -555,7 +555,7 @@ for handle, tup in zip(self.legendHandles, hpos): y,h = tup if isinstance(handle, Line2D): - ydata = y*ones(self._xdata.shape, float) + ydata = y*ones(self._xdata.shape, Float) handle.set_ydata(ydata+h/2) elif isinstance(handle, Rectangle): handle.set_y(y+1/4*h) Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/lines.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -9,10 +9,10 @@ import sys, math, warnings import agg -from numpy import alltrue, arange, array, logical_and, \ +from numerix import Float, alltrue, arange, array, logical_and, \ nonzero, searchsorted, take, asarray, ones, where, less, ravel, \ greater, cos, sin, pi, sqrt, less_equal, \ - compress, zeros, concatenate, cumsum, newaxis + compress, zeros, concatenate, cumsum, typecode, NewAxis import numerix.ma as ma from matplotlib import verbose import artist @@ -64,12 +64,12 @@ if len(i1) == 0: return None if not compressed: - return concatenate((i0[:, newaxis], i1[:, newaxis]), axis=1) + return concatenate((i0[:, NewAxis], i1[:, NewAxis]), axis=1) seglengths = i1 - i0 breakpoints = cumsum(seglengths) ic0 = concatenate(((0,), breakpoints[:-1])) ic1 = breakpoints - return concatenate((ic0[:, newaxis], ic1[:, newaxis]), axis=1) + return concatenate((ic0[:, NewAxis], ic1[:, NewAxis]), axis=1) def segment_hits(cx,cy,x,y,radius): """Determine if any line segments are within radius of a point. Returns @@ -88,7 +88,7 @@ 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 @@ -96,7 +96,7 @@ 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 @@ -164,7 +164,7 @@ else: return "Line2D(%s)"\ %(",".join(["(%g,%g)"%(x,y) for x,y in zip(self._x,self._y)])) - + def __init__(self, xdata, ydata, linewidth = None, # all Nones default to rc linestyle = None, @@ -274,25 +274,25 @@ self.set_data(xdata, ydata) self._logcache = None - + # TODO: do we really need 'newstyle' self._newstyle = False def contains(self, mouseevent): """Test whether the mouse event occurred on the line. The pick radius determines the precision of the location test (usually within five points of the value). Use - get/set pickradius() to view or modify it. - - Returns True if any values are within the radius along with {'ind': pointlist}, + get/set pickradius() to view or modify it. + + Returns True if any values are within the radius along with {'ind': pointlist}, where pointlist is the set of points within the radius. - + TODO: sort returned indices by distance """ if callable(self._contains): return self._contains(self,mouseevent) - + if not is_numlike(self.pickradius): raise ValueError,"pick radius should be a distance" - + if self._newstyle: # transform in backend x = self._x @@ -308,7 +308,7 @@ pixels = self.pickradius else: pixels = self.figure.dpi.get()/72. * self.pickradius - + if self._linestyle == 'None': # If no line, return the nearby point(s) d = sqrt((xt-mouseevent.x)**2 + (yt-mouseevent.y)**2) @@ -322,21 +322,21 @@ print 'd', (xt-mouseevent.x)**2., (yt-mouseevent.y)**2. print d, pixels, ind return len(ind)>0,dict(ind=ind) - + def get_pickradius(self): 'return the pick radius used for containment tests' return self.pickradius - def set_pickradius(self,d): + def set_pickradius(self,d): """Sets the pick radius used for containment tests - + Accepts: float distance in points. """ self.pickradius = d - + def set_picker(self,p): """Sets the event picker details for the line. - + Accepts: float distance in points or callable pick function fn(artist,event) """ if callable(p): @@ -344,7 +344,7 @@ else: self.pickradius = p self._picker = p - + def get_window_extent(self, renderer): self._newstyle = hasattr(renderer, 'draw_markers') if self._newstyle: @@ -398,15 +398,15 @@ def recache(self): #if self.axes is None: print 'recache no axes' #else: print 'recache units', self.axes.xaxis.units, self.axes.yaxis.units - x = ma.asarray(self.convert_xunits(self._xorig), float) - y = ma.asarray(self.convert_yunits(self._yorig), float) + x = ma.asarray(self.convert_xunits(self._xorig), Float) + y = ma.asarray(self.convert_yunits(self._yorig), Float) x = ma.ravel(x) y = ma.ravel(y) if len(x)==1 and len(y)>1: - x = x * ones(y.shape, float) + x = x * ones(y.shape, Float) if len(y)==1 and len(x)>1: - y = y * ones(x.shape, float) + y = y * ones(x.shape, Float) if len(x) != len(y): raise RuntimeError('xdata and ydata must be the same length') @@ -421,8 +421,8 @@ else: self._segments = None - self._x = asarray(x, float) - self._y = asarray(y, float) + self._x = asarray(x, Float) + self._y = asarray(y, Float) self._logcache = None @@ -557,7 +557,7 @@ else: return self._markerfacecolor - + def get_markersize(self): return self._markersize def get_xdata(self, orig=True): @@ -708,9 +708,9 @@ def _draw_steps(self, renderer, gc, xt, yt): siz=len(xt) if siz<2: return - xt2=ones((2*siz,), xt.dtype) + xt2=ones((2*siz,), typecode(xt)) xt2[0:-1:2], xt2[1:-1:2], xt2[-1]=xt, xt[1:], xt[-1] - yt2=ones((2*siz,), yt.dtype) + yt2=ones((2*siz,), typecode(yt)) yt2[0:-1:2], yt2[1::2]=yt, yt gc.set_linestyle('solid') Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -143,6 +143,7 @@ from matplotlib.font_manager import fontManager, FontProperties from matplotlib._mathtext_data import latex_to_bakoma, cmkern, \ latex_to_standard, tex2uni, type12uni, tex2type1, uni2type1 +from matplotlib.numerix import absolute from matplotlib import get_data_path, rcParams # symbols that have the sub and superscripts over/under Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2007-07-19 20:24:30 UTC (rev 3579) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-07-20 02:10:43 UTC (rev 3580) @@ -71,8 +71,8 @@ multiply, transpose, ravel, repeat, resize, reshape, floor, ceil,\ absolute, matrixmultiply, power, take, where, Float, Int, asum,\ dot, convolve, pi, Complex, ones, zeros, diagonal, Matrix, nonzero, \ - log, searchsorted, concatenate, sort, ArrayType, ndarray, clip, size, indices,\ - conjugate, typecode, iscontiguous, linspace, meshgrid + log, searchsorted, concatenate, sort, ArrayType, clip, size, indices,\ + conjugate, typecode, iscontiguous from numerix.mlab import hanning, cov, diff, svd, rand, std @@ -93,6 +93,11 @@ else: return numerix.mlab.mean(x, dim) +def linspace(xmin, xmax, N): + if N==1: return array([xmax]) + dx = (xmax-xmin)/(N-1) + return xmin + dx*arange(N) + def logspace(xmin,xmax,N): return exp(linspace(log(xmin), log(xmax),Nh)) @@ -179,7 +184,7 @@ # for real x, ignore the negative frequencies - if npy.iscomplexobj(x): numFreqs = NFFT + if typecode(x)==Complex: numFreqs = NFFT else: numFreqs = NFFT//2+1 if iterable(window): @@ -190,7 +195,7 @@ step = NFFT-noverlap ind = range(0,len(x)-NFFT+1,step) n = len(ind) - Pxx = zeros((numFreqs,n), float) + Pxx = zeros((numFreqs,n), Float) # do the ffts of the slices for i in range(n): thisX = x[ind[i]:ind[i]+NFFT] @@ -238,7 +243,7 @@ if NFFT % 2: raise ValueError, 'NFFT must be a power of 2' - + x = asarray(x) # make sure we're dealing with a numpy array y = asarray(y) # make sure we're dealing with a numpy array @@ -253,7 +258,7 @@ y[n:] = 0 # for real x, ignore the negative frequencies - if npy.iscomplexobj(x): numFreqs = NFFT + if typecode(x)==Complex: numFreqs = NFFT else: numFreqs = NFFT//2+1 if iterable(window): @@ -264,7 +269,7 @@ step = NFFT-noverlap ind = range(0,len(x)-NFFT+1,step) n = len(ind) - Pxy = zeros((numFreqs,n), complex) + Pxy = zeros((numFreqs,n), Complex) # do the ffts of the slices for i in range(n): @@ -537,7 +542,7 @@ del seen # for real X, ignore the negative frequencies - if npy.iscomplexobj(X): numFreqs = NFFT + if typecode(X)==Complex: numFreqs = NFFT else: numFreqs = NFFT//2+1 # cache the FFT of every windowed, detrended NFFT length segement @@ -557,7 +562,7 @@ normVal = norm(windowVals)**2 for iCol in allColumns: progressCallback(i/Ncols, 'Cacheing FFTs') - Slices = zeros( (numSlices,numFreqs), complex) + Slices = zeros( (numSlices,numFreqs), Complex) for iSlice in slices: thisSlice = X[ind[iSlice]:ind[iSlice]+NFFT, iCol] thisSlice = windowVals*detrend(thisSlice) @@ -613,7 +618,7 @@ n,bins = hist(y, bins) - n = n.astype(float) + n = n.astype(Float) n = take(n, nonzero(n)) # get the positive @@ -686,14 +691,14 @@ dx = x[1]-x[0] - f = 1/(N*dx)*arange(-N/2, N/2, float) + f = 1/(N*dx)*arange(-N/2, N/2, Float) - ind = concatenate([arange(N/2, N, int), - arange(0, N/2, int)]) + ind = concatenate([arange(N/2, N, Int), + arange(N/2,Int)]) df = f[1]-f[0] cfl = exp(-gamma*absolute(2*pi*f)**alpha) - px = fft(take(cfl,ind)*df).astype(float) + px = fft(take(cfl,ind)*df).astype(Float) return take(px, ind) @@ -753,7 +758,7 @@ if len(ind)==0: return arange(len(x)) if len(ind)==len(x): return array([]) - y = zeros( (len(x)+2,), int) + y = zeros( (len(x)+2,), Int) y[1:-1] = x d = diff(y) #print 'd', d @@ -806,7 +811,7 @@ return x[int(p*Nx/100.0)] p = multiply(array(p), Nx/100.0) - ind = p.astype(int) + ind = p.astype(Int) ind = where(ind>=Nx, Nx-1, ind) return take(x, ind) @@ -841,7 +846,7 @@... [truncated message content] |