From: <jd...@us...> - 2008-04-29 15:15:02
|
Revision: 5098 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5098&view=rev Author: jdh2358 Date: 2008-04-29 08:14:36 -0700 (Tue, 29 Apr 2008) Log Message: ----------- changed numpy abbrev from npy to np Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/art3d.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/axes3d.py trunk/matplotlib/lib/matplotlib/axis3d.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/cm.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/lib/matplotlib/colorbar.py trunk/matplotlib/lib/matplotlib/colors.py trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/lib/matplotlib/dviread.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/mlab.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/path.py trunk/matplotlib/lib/matplotlib/proj3d.py trunk/matplotlib/lib/matplotlib/pylab.py trunk/matplotlib/lib/matplotlib/quiver.py trunk/matplotlib/lib/matplotlib/scale.py trunk/matplotlib/lib/matplotlib/texmanager.py trunk/matplotlib/lib/matplotlib/ticker.py trunk/matplotlib/lib/matplotlib/transforms.py trunk/matplotlib/lib/matplotlib/widgets.py trunk/matplotlib/setupext.py trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/lib/matplotlib/art3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/art3d.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/art3d.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -11,7 +11,7 @@ from colors import Normalize -import numpy as npy +import numpy as np import proj3d class Wrap2D: @@ -253,8 +253,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 = np.ones(len(xs)) + self.vec = np.array([xs,ys,zs,ones]) self.segis = segis def draw3d(self, renderer): @@ -326,7 +326,7 @@ source = image._A w,h,p = source.shape X,Y = meshgrid(arange(w),arange(h)) - Z = npy.zeros((w,h)) + Z = np.zeros((w,h)) tX,tY,tZ = proj3d.transform(X.flat,Y.flat,Z.flat,M) tX = reshape(tX,(w,h)) tY = reshape(tY,(w,h)) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -1,7 +1,7 @@ from __future__ import division, generators import math, warnings, new -import numpy as npy +import numpy as np from numpy import ma import matplotlib @@ -212,16 +212,16 @@ def _xy_from_y(self, y): if self.axes.yaxis is not None: b = self.axes.yaxis.update_units(y) - if b: return npy.arange(len(y)), y, False + if b: return np.arange(len(y)), y, False if not ma.isMaskedArray(y): - y = npy.asarray(y) + y = np.asarray(y) if len(y.shape) == 1: - y = y[:,npy.newaxis] + y = y[:,np.newaxis] nr, nc = y.shape - x = npy.arange(nr) + x = np.arange(nr) if len(x.shape) == 1: - x = x[:,npy.newaxis] + x = x[:,np.newaxis] return x,y, True def _xy_from_xy(self, x, y): @@ -235,18 +235,18 @@ x = ma.asarray(x) y = ma.asarray(y) if len(x.shape) == 1: - x = x[:,npy.newaxis] + x = x[:,np.newaxis] if len(y.shape) == 1: - y = y[:,npy.newaxis] + y = y[:,np.newaxis] nrx, ncx = x.shape nry, ncy = y.shape assert nrx == nry, 'Dimensions of x and y are incompatible' if ncx == ncy: return x, y, True if ncx == 1: - x = npy.repeat(x, ncy, axis=1) + x = np.repeat(x, ncy, axis=1) if ncy == 1: - y = npy.repeat(y, ncx, axis=1) + y = np.repeat(y, ncx, axis=1) assert x.shape == y.shape, 'Dimensions of x and y are incompatible' return x, y, True @@ -1231,7 +1231,7 @@ # Otherwise, it will compute the bounds of it's current data # and the data in xydata if not ma.isMaskedArray(xys): - xys = npy.asarray(xys) + xys = np.asarray(xys) self.dataLim.update_from_data_xy(xys, self.ignore_existing_data_limits) self.ignore_existing_data_limits = False @@ -2071,7 +2071,7 @@ dx = 0.5 * (dx + dy) dy = dx - alpha = npy.power(10.0, (dx, dy)) + alpha = np.power(10.0, (dx, dy)) start = p.trans_inverse.transform_point((p.x, p.y)) lim_points = p.lim.get_points() result = start + alpha * (lim_points - start) @@ -2200,7 +2200,7 @@ def dist_x_y(p1, x, y): 'x and y are arrays; return the distance to the closest point' x1, y1 = p1 - return min(npy.sqrt((x-x1)**2+(y-y1)**2)) + return min(np.sqrt((x-x1)**2+(y-y1)**2)) def dist(a): if isinstance(a, Text): @@ -2217,7 +2217,7 @@ ydata = a.get_ydata(orig=False) xt, yt = a.get_transform().numerix_x_y(xdata, ydata) - return dist_x_y(xywin, npy.asarray(xt), npy.asarray(yt)) + return dist_x_y(xywin, np.asarray(xt), np.asarray(yt)) artists = self.lines + self.patches + self.texts if callable(among): @@ -2601,14 +2601,14 @@ if not iterable(y): y = [y] if not iterable(xmin): xmin = [xmin] if not iterable(xmax): xmax = [xmax] - y = npy.asarray(y) - xmin = npy.asarray(xmin) - xmax = npy.asarray(xmax) + y = np.asarray(y) + xmin = np.asarray(xmin) + xmax = np.asarray(xmax) if len(xmin)==1: - xmin = npy.resize( xmin, y.shape ) + xmin = np.resize( xmin, y.shape ) if len(xmax)==1: - xmax = npy.resize( xmax, y.shape ) + xmax = np.resize( xmax, y.shape ) if len(xmin)!=len(y): raise ValueError, 'xmin and y are unequal sized sequences' @@ -2669,26 +2669,26 @@ if not iterable(x): x = [x] if not iterable(ymin): ymin = [ymin] if not iterable(ymax): ymax = [ymax] - x = npy.asarray(x) - ymin = npy.asarray(ymin) - ymax = npy.asarray(ymax) + x = np.asarray(x) + ymin = np.asarray(ymin) + ymax = np.asarray(ymax) if len(ymin)==1: - ymin = npy.resize( ymin, x.shape ) + ymin = np.resize( ymin, x.shape ) if len(ymax)==1: - ymax = npy.resize( ymax, x.shape ) + ymax = np.resize( ymax, x.shape ) if len(ymin)!=len(x): raise ValueError, 'ymin and x are unequal sized sequences' if len(ymax)!=len(x): raise ValueError, 'ymax and x are unequal sized sequences' - Y = npy.array([ymin, ymax]).T + Y = np.array([ymin, ymax]).T verts = [ ((thisx, thisymin), (thisx, thisymax)) for thisx, (thisymin, thisymax) in zip(x,Y)] #print 'creating line collection' coll = mcoll.LineCollection(verts, colors=colors, - linestyles=linestyles, label=label) + linestyles=linestyles, label=label) self.add_collection(coll) coll.update(kwargs) @@ -3063,19 +3063,19 @@ if Nx!=len(y): raise ValueError('x and y must be equal length') - x = detrend(npy.asarray(x)) - y = detrend(npy.asarray(y)) + x = detrend(np.asarray(x)) + y = detrend(np.asarray(y)) - c = npy.correlate(x, y, mode=2) + c = np.correlate(x, y, mode=2) - if normed: c/= npy.sqrt(npy.dot(x,x) * npy.dot(y,y)) + if normed: c/= np.sqrt(np.dot(x,x) * np.dot(y,y)) if maxlags is None: maxlags = Nx - 1 if maxlags >= Nx or maxlags < 1: raise ValueError('maglags must be None or strictly positive < %d'%Nx) - lags = npy.arange(-maxlags,maxlags+1) + lags = np.arange(-maxlags,maxlags+1) c = c[Nx-1-maxlags:Nx+maxlags] @@ -3358,10 +3358,10 @@ # do not convert to array here as unit info is lost - #left = npy.asarray(left) - #height = npy.asarray(height) - #width = npy.asarray(width) - #bottom = npy.asarray(bottom) + #left = np.asarray(left) + #height = np.asarray(height) + #width = np.asarray(width) + #bottom = np.asarray(bottom) if len(linewidth) == 1: linewidth = linewidth * nbars @@ -3469,16 +3469,16 @@ if adjust_xlim: xmin, xmax = self.dataLim.intervalx - xmin = npy.amin(width) + xmin = np.amin(width) if xerr is not None: - xmin = xmin - npy.amax(xerr) + xmin = xmin - np.amax(xerr) xmin = max(xmin*0.9, 1e-100) self.dataLim.intervalx = (xmin, xmax) if adjust_ylim: ymin, ymax = self.dataLim.intervaly - ymin = npy.amin(height) + ymin = np.amin(height) if yerr is not None: - ymin = ymin - npy.amax(yerr) + ymin = ymin - np.amax(yerr) ymin = max(ymin*0.9, 1e-100) self.dataLim.intervaly = (ymin, ymax) self.autoscale_view() @@ -3596,7 +3596,7 @@ l, = self.plot([thisx,thisx], [0, thisy], linefmt) stemlines.append(l) - baseline, = self.plot([npy.amin(x), npy.amax(x)], [0,0], basefmt) + baseline, = self.plot([np.amin(x), np.amax(x)], [0,0], basefmt) self.hold(remember_hold) @@ -3658,10 +3658,10 @@ """ self.set_frame_on(False) - x = npy.asarray(x).astype(npy.float32) + x = np.asarray(x).astype(np.float32) sx = float(x.sum()) - if sx>1: x = npy.divide(x,sx) + if sx>1: x = np.divide(x,sx) if labels is None: labels = ['']*len(x) if explode is None: explode = [0]*len(x) @@ -3841,17 +3841,17 @@ # 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) + lolims = np.asarray([lolims]*len(x), bool) + else: lolims = np.asarray(lolims, bool) - if not iterable(uplims): uplims = npy.array([uplims]*len(x), bool) - else: uplims = npy.asarray(uplims, bool) + if not iterable(uplims): uplims = np.array([uplims]*len(x), bool) + else: uplims = np.asarray(uplims, bool) - if not iterable(xlolims): xlolims = npy.array([xlolims]*len(x), bool) - else: xlolims = npy.asarray(xlolims, bool) + if not iterable(xlolims): xlolims = np.array([xlolims]*len(x), bool) + else: xlolims = np.asarray(xlolims, bool) - if not iterable(xuplims): xuplims = npy.array([xuplims]*len(x), bool) - else: xuplims = npy.asarray(xuplims, bool) + if not iterable(xuplims): xuplims = np.array([xuplims]*len(x), bool) + else: xuplims = np.asarray(xuplims, bool) def xywhere(xs, ys, mask): """ @@ -4032,26 +4032,26 @@ distance = max(positions) - min(positions) widths = min(0.15*max(distance,1.0), 0.5) if isinstance(widths, float) or isinstance(widths, int): - widths = npy.ones((col,), float) * widths + widths = np.ones((col,), float) * widths # loop through columns, adding each to plot self.hold(True) for i,pos in enumerate(positions): - d = npy.ravel(x[i]) + d = np.ravel(x[i]) row = len(d) # get median and quartiles q1, med, q3 = mlab.prctile(d,[25,50,75]) # get high extreme iq = q3 - q1 hi_val = q3 + whis*iq - wisk_hi = npy.compress( d <= hi_val , d ) + wisk_hi = np.compress( d <= hi_val , d ) if len(wisk_hi) == 0: wisk_hi = q3 else: wisk_hi = max(wisk_hi) # get low extreme lo_val = q1 - whis*iq - wisk_lo = npy.compress( d >= lo_val, d ) + wisk_lo = np.compress( d >= lo_val, d ) if len(wisk_lo) == 0: wisk_lo = q1 else: @@ -4062,16 +4062,16 @@ flier_hi_x = [] flier_lo_x = [] if len(sym) != 0: - flier_hi = npy.compress( d > wisk_hi, d ) - flier_lo = npy.compress( d < wisk_lo, d ) - flier_hi_x = npy.ones(flier_hi.shape[0]) * pos - flier_lo_x = npy.ones(flier_lo.shape[0]) * pos + flier_hi = np.compress( d > wisk_hi, d ) + flier_lo = np.compress( d < wisk_lo, d ) + flier_hi_x = np.ones(flier_hi.shape[0]) * pos + flier_lo_x = np.ones(flier_lo.shape[0]) * pos # get x locations for fliers, whisker, whisker cap and box sides box_x_min = pos - widths[i] * 0.5 box_x_max = pos + widths[i] * 0.5 - wisk_x = npy.ones(2) * pos + wisk_x = np.ones(2) * pos cap_x_min = pos - widths[i] * 0.25 cap_x_max = pos + widths[i] * 0.25 @@ -4089,8 +4089,8 @@ med_x = [box_x_min, box_x_max] # calculate 'notch' plot else: - notch_max = med + 1.57*iq/npy.sqrt(row) - notch_min = med - 1.57*iq/npy.sqrt(row) + notch_max = med + 1.57*iq/np.sqrt(row) + notch_min = med - 1.57*iq/np.sqrt(row) if notch_max > q3: notch_max = q3 if notch_min < q1: @@ -4267,7 +4267,7 @@ # mapping, not interpretation as rgb or rgba. if not is_string_like(c): - sh = npy.shape(c) + sh = np.shape(c) if len(sh) == 1 and sh[0] == len(x): colors = None # use cmap, norm after collection is created else: @@ -4324,7 +4324,7 @@ symstyle = marker[1] else: - verts = npy.asarray(marker[0]) + verts = np.asarray(marker[0]) if sym is not None: if symstyle==0: @@ -4357,11 +4357,11 @@ else: # MGDTODO: This has dpi problems # rescale verts - rescale = npy.sqrt(max(verts[:,0]**2+verts[:,1]**2)) + rescale = np.sqrt(max(verts[:,0]**2+verts[:,1]**2)) verts /= rescale - scales = npy.asarray(scales) - scales = npy.sqrt(scales * self.figure.dpi / 72.) + scales = np.asarray(scales) + scales = np.sqrt(scales * self.figure.dpi / 72.) if len(scales)==1: verts = [scales[0]*verts] else: @@ -4382,7 +4382,7 @@ if colors is None: if norm is not None: assert(isinstance(norm, mcolors.Normalize)) if cmap is not None: assert(isinstance(cmap, mcolors.Colormap)) - collection.set_array(npy.asarray(c)) + collection.set_array(np.asarray(c)) collection.set_cmap(cmap) collection.set_norm(norm) @@ -4394,10 +4394,10 @@ temp_x = x temp_y = y - minx = npy.amin(temp_x) - maxx = npy.amax(temp_x) - miny = npy.amin(temp_y) - maxy = npy.amax(temp_y) + minx = np.amin(temp_x) + maxx = np.amax(temp_x) + miny = np.amin(temp_y) + maxy = np.amax(temp_y) w = maxx-minx h = maxy-miny @@ -4513,16 +4513,16 @@ nx = gridsize ny = int(nx/math.sqrt(3)) # Count the number of data in each hexagon - x = npy.array(x, float) - y = npy.array(y, float) + x = np.array(x, float) + y = np.array(y, float) if xscale=='log': - x = npy.log10(x) + x = np.log10(x) if yscale=='log': - y = npy.log10(y) - xmin = npy.amin(x) - xmax = npy.amax(x) - ymin = npy.amin(y) - ymax = npy.amax(y) + y = np.log10(y) + xmin = np.amin(x) + xmax = np.amax(x) + ymin = np.amin(y) + ymax = np.amax(y) # In the x-direction, the hexagons exactly cover the region from # xmin to xmax. Need some padding to avoid roundoff errors. padding = 1.e-9 * (xmax - xmin) @@ -4532,17 +4532,17 @@ sy = (ymax-ymin) / ny x = (x-xmin)/sx y = (y-ymin)/sy - ix1 = npy.round(x).astype(int) - iy1 = npy.round(y).astype(int) - ix2 = npy.floor(x).astype(int) - iy2 = npy.floor(y).astype(int) + ix1 = np.round(x).astype(int) + iy1 = np.round(y).astype(int) + ix2 = np.floor(x).astype(int) + iy2 = np.floor(y).astype(int) nx1 = nx + 1 ny1 = ny + 1 nx2 = nx ny2 = ny n = nx1*ny1+nx2*ny2 - counts = npy.zeros(n) + counts = np.zeros(n) lattice1 = counts[:nx1*ny1] lattice2 = counts[nx1*ny1:] lattice1.shape = (nx1,ny1) @@ -4558,16 +4558,16 @@ else: lattice2[ix2[i], iy2[i]]+=1 - px = xmin + sx * npy.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0]) - py = ymin + sy * npy.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0 + px = xmin + sx * np.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0]) + py = ymin + sy * np.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0 - polygons = npy.zeros((6, n, 2), float) - polygons[:,:nx1*ny1,0] = npy.repeat(npy.arange(nx1), ny1) - polygons[:,:nx1*ny1,1] = npy.tile(npy.arange(ny1), nx1) - polygons[:,nx1*ny1:,0] = npy.repeat(npy.arange(nx2) + 0.5, ny2) - polygons[:,nx1*ny1:,1] = npy.tile(npy.arange(ny2), nx2) + 0.5 + polygons = np.zeros((6, n, 2), float) + polygons[:,:nx1*ny1,0] = np.repeat(np.arange(nx1), ny1) + polygons[:,:nx1*ny1,1] = np.tile(np.arange(ny1), nx1) + polygons[:,nx1*ny1:,0] = np.repeat(np.arange(nx2) + 0.5, ny2) + polygons[:,nx1*ny1:,1] = np.tile(np.arange(ny2), nx2) + 0.5 - polygons = npy.transpose(polygons, axes=[1,0,2]) + polygons = np.transpose(polygons, axes=[1,0,2]) polygons[:,:,0] *= sx polygons[:,:,1] *= sy polygons[:,:,0] += px @@ -4607,13 +4607,13 @@ # Transform the counts if needed if bins=='log': - counts = npy.log10(counts+1) + counts = np.log10(counts+1) elif bins!=None: if not iterable(bins): minimum, maximum = min(counts), max(counts) bins-=1 # one less edge than bins - bins = minimum + (maximum-minimum)*npy.arange(bins)/bins - bins = npy.sort(bins) + bins = minimum + (maximum-minimum)*np.arange(bins)/bins + bins = np.sort(bins) counts = bins.searchsorted(counts) if norm is not None: assert(isinstance(norm, mcolors.Normalize)) @@ -4847,7 +4847,7 @@ if len(args)==1: C = args[0] numRows, numCols = C.shape - X, Y = npy.meshgrid(npy.arange(numCols+1), npy.arange(numRows+1) ) + X, Y = np.meshgrid(np.arange(numCols+1), np.arange(numRows+1) ) elif len(args)==3: X, Y, C = args else: @@ -4936,8 +4936,8 @@ Similarly for meshgrid: - x = npy.arange(5) - y = npy.arange(3) + x = np.arange(5) + y = np.arange(3) X, Y = meshgrid(x,y) is equivalent to @@ -4990,8 +4990,8 @@ # don't plot if C or any of the surrounding vertices are masked. mask = ma.getmaskarray(C)[0:Ny-1,0:Nx-1]+xymask - newaxis = npy.newaxis - compress = npy.compress + newaxis = np.newaxis + compress = np.compress ravelmask = (mask==0).ravel() X1 = compress(ravelmask, ma.filled(X[0:-1,0:-1]).ravel()) @@ -5004,7 +5004,7 @@ Y4 = compress(ravelmask, ma.filled(Y[0:-1,1:]).ravel()) npoly = len(X1) - xy = npy.concatenate((X1[:,newaxis], Y1[:,newaxis], + xy = np.concatenate((X1[:,newaxis], Y1[:,newaxis], X2[:,newaxis], Y2[:,newaxis], X3[:,newaxis], Y3[:,newaxis], X4[:,newaxis], Y4[:,newaxis], @@ -5043,10 +5043,10 @@ x = X.compressed() y = Y.compressed() - minx = npy.amin(x) - maxx = npy.amax(x) - miny = npy.amin(y) - maxy = npy.amax(y) + minx = np.amin(x) + maxx = np.amax(x) + miny = np.amin(y) + maxy = np.amax(y) corners = (minx, miny), (maxx, maxy) self.update_datalim( corners) @@ -5127,7 +5127,7 @@ X = X.ravel() Y = Y.ravel() - coords = npy.zeros(((Nx * Ny), 2), dtype=float) + coords = np.zeros(((Nx * Ny), 2), dtype=float) coords[:, 0] = X coords[:, 1] = Y @@ -5151,10 +5151,10 @@ self.grid(False) - minx = npy.amin(X) - maxx = npy.amax(X) - miny = npy.amin(Y) - maxy = npy.amax(Y) + minx = np.amin(X) + maxx = np.amax(X) + miny = np.amin(Y) + maxy = np.amax(Y) corners = (minx, miny), (maxx, maxy) self.update_datalim( corners) @@ -5250,16 +5250,16 @@ y = [0, nr] elif len(args) == 3: x, y = args[:2] - x = npy.asarray(x) - y = npy.asarray(y) + x = np.asarray(x) + y = np.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())): + dx = np.diff(x) + dy = np.diff(y) + if (np.ptp(dx) < 0.01*np.abs(dx.mean()) and + np.ptp(dy) < 0.01*np.abs(dy.mean())): style = "image" else: style = "pcolorimage" @@ -5283,7 +5283,7 @@ # 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 = np.empty(((Nx * Ny), 2), np.float64) coords[:, 0] = X coords[:, 1] = Y @@ -5328,7 +5328,7 @@ ret.set_clim(vmin, vmax) else: ret.autoscale_None() - self.update_datalim(npy.array([[xl, yb], [xr, yt]])) + self.update_datalim(np.array([[xl, yb], [xr, yt]])) self.autoscale_view(tight=True) return ret @@ -5427,7 +5427,7 @@ # trapezoidal integration of the probability density function pdf, bins, patches = ax.hist(...) - print npy.trapz(pdf, bins) + print np.trapz(pdf, bins) align = 'edge' | 'center'. Interprets bins either as edge or center values @@ -5445,7 +5445,7 @@ %(Rectangle)s """ if not self._hold: self.cla() - n, bins = npy.histogram(x, bins, range=None, normed=normed) + n, bins = np.histogram(x, bins, range=None, normed=normed) if width is None: width = 0.9*(bins[1]-bins[0]) if orientation == 'horizontal': patches = self.barh(bins, n, height=width, left=bottom, @@ -5498,7 +5498,7 @@ Returns the tuple Pxx, freqs - For plotting, the power is plotted as 10*npy.log10(pxx) for decibels, + For plotting, the power is plotted as 10*np.log10(pxx) for decibels, though pxx itself is returned Refs: @@ -5514,17 +5514,17 @@ pxx.shape = len(freqs), freqs += Fc - self.plot(freqs, 10*npy.log10(pxx), **kwargs) + self.plot(freqs, 10*np.log10(pxx), **kwargs) self.set_xlabel('Frequency') self.set_ylabel('Power Spectrum (dB)') self.grid(True) vmin, vmax = self.viewLim.intervaly intv = vmax-vmin - logi = int(npy.log10(intv)) + logi = int(np.log10(intv)) if logi==0: logi=.1 step = 10*logi #print vmin, vmax, step, intv, math.floor(vmin), math.ceil(vmax)+1 - ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step) + ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step) self.set_yticks(ticks) return pxx, freqs @@ -5546,7 +5546,7 @@ See the PSD help for a description of the optional parameters. Returns the tuple Pxy, freqs. Pxy is the cross spectrum (complex - valued), and 10*npy.log10(|Pxy|) is plotted + valued), and 10*np.log10(|Pxy|) is plotted Refs: Bendat & Piersol -- Random Data: Analysis and Measurement @@ -5561,16 +5561,16 @@ # pxy is complex freqs += Fc - self.plot(freqs, 10*npy.log10(npy.absolute(pxy)), **kwargs) + self.plot(freqs, 10*np.log10(np.absolute(pxy)), **kwargs) self.set_xlabel('Frequency') self.set_ylabel('Cross Spectrum Magnitude (dB)') self.grid(True) vmin, vmax = self.viewLim.intervaly intv = vmax-vmin - step = 10*int(npy.log10(intv)) + step = 10*int(np.log10(intv)) - ticks = npy.arange(math.floor(vmin), math.ceil(vmax)+1, step) + ticks = np.arange(math.floor(vmin), math.ceil(vmax)+1, step) self.set_yticks(ticks) return pxy, freqs @@ -5655,10 +5655,10 @@ window, noverlap) - Z = 10*npy.log10(Pxx) - Z = npy.flipud(Z) + Z = 10*np.log10(Pxx) + Z = np.flipud(Z) - if xextent is None: xextent = 0, npy.amax(bins) + if xextent is None: xextent = 0, np.amax(bins) xmin, xmax = xextent freqs += Fc extent = xmin, xmax, freqs[0], freqs[-1] @@ -5718,9 +5718,9 @@ if marker is None and markersize is None: if hasattr(Z, 'tocoo'): raise TypeError, "Image mode does not support scipy.sparse arrays" - Z = npy.asarray(Z) + Z = np.asarray(Z) if precision is None: mask = Z!=0. - else: mask = npy.absolute(Z)>precision + else: mask = np.absolute(Z)>precision if 'cmap' not in kwargs: kwargs['cmap'] = mcolors.ListedColormap(['w', 'k'], name='binary') @@ -5735,9 +5735,9 @@ x = c.col z = c.data else: - Z = npy.asarray(Z) + Z = np.asarray(Z) if precision is None: mask = Z!=0. - else: mask = npy.absolute(Z)>precision + else: mask = np.absolute(Z)>precision y,x,z = mlab.get_xyz_where(mask, mask) if marker is None: marker = 's' if markersize is None: markersize = 10 @@ -5780,7 +5780,7 @@ Returns: an image.AxesImage instance ''' - Z = npy.asarray(Z) + Z = np.asarray(Z) nr, nc = Z.shape extent = [-0.5, nc-0.5, nr-0.5, -0.5] kw = {'extent': extent, Modified: trunk/matplotlib/lib/matplotlib/axes3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes3d.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/axes3d.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -15,7 +15,7 @@ import cbook from transforms import unit_bbox -import numpy as npy +import numpy as np from colors import Normalize import art3d @@ -184,7 +184,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(np.asarray, (X,Y,Z)) try: x,y = X.flat,Y.flat if Z is not None: @@ -274,7 +274,7 @@ point. """ - relev,razim = npy.pi * self.elev/180, npy.pi * self.azim/180 + relev,razim = np.pi * self.elev/180, np.pi * self.azim/180 xmin,xmax = self.get_w_xlim() ymin,ymax = self.get_w_ylim() @@ -286,29 +286,29 @@ zmin,zmax) # look into the middle of the new coordinates - R = npy.array([0.5,0.5,0.5]) + R = np.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] + np.cos(razim)*np.cos(relev)*self.dist + yp = R[1] + np.sin(razim)*np.cos(relev)*self.dist + zp = R[2] + np.sin(relev)*self.dist - E = npy.array((xp, yp, zp)) + E = np.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) > np.pi/2: # upside down - V = npy.array((0,0,-1)) + V = np.array((0,0,-1)) else: - V = npy.array((0,0,1)) + V = np.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 = np.dot(viewM,worldM) + M = np.dot(perspM,M0) return M def mouse_init(self): @@ -382,8 +382,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 = np.hypot(x0-xd,y0-yd) + d1 = np.hypot(x1-xd,y1-yd) dt = d0+d1 z = d1/dt * z0 + d0/dt * z1 #print 'mid', edgei, d0, d1, z0, z1, z @@ -503,14 +503,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 = np.transpose(X), np.transpose(Y), np.transpose(Z) rstride = cbook.popd(kwargs, 'rstride', 10) cstride = cbook.popd(kwargs, 'cstride', 10) # polys = [] boxes = [] - for rs in npy.arange(0,rows-1,rstride): - for cs in npy.arange(0,cols-1,cstride): + for rs in np.arange(0,rows-1,rstride): + for cs in np.arange(0,cols-1,cstride): ps = [] corners = [] for a,ta in [(X,tX),(Y,tY),(Z,tZ)]: @@ -521,9 +521,9 @@ zright = ta[cs][rs:min(rows,rs+rstride+1):] zright = zright[::-1] corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]]) - z = npy.concatenate((ztop,zleft,zbase,zright)) + z = np.concatenate((ztop,zleft,zbase,zright)) ps.append(z) - boxes.append(map(npy.array,zip(*corners))) + boxes.append(map(np.array,zip(*corners))) polys.append(zip(*ps)) # lines = [] @@ -532,10 +532,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(np.dot(n,[-1,-1,0.5])) lines.append((box[0],n+box[0])) # - color = npy.array([0,0,1,1]) + color = np.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 @@ -553,7 +553,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 = np.transpose(X), np.transpose(Y), np.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,8 +718,8 @@ def get_test_data(delta=0.05): from mlab import bivariate_normal - x = y = npy.arange(-3.0, 3.0, delta) - X, Y = npy.meshgrid(x,y) + x = y = np.arange(-3.0, 3.0, delta) + X, Y = np.meshgrid(x,y) Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0) Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1) @@ -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 = np.arange(0,4*np.pi+0.1,0.1) + ys = np.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 = np.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 = np.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/axis3d.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axis3d.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/axis3d.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -13,7 +13,7 @@ import art3d import proj3d -import numpy as npy +import numpy as np def norm_angle(a): """Return angle between -180 and +180""" @@ -51,8 +51,8 @@ # Compute the dash end points # The 'c' prefix is for canvas coordinates - cxy = npy.array(transform.xy_tup((x, y))) - cd = npy.array([cos_theta, sin_theta]) + cxy = np.array(transform.xy_tup((x, y))) + cd = np.array([cos_theta, sin_theta]) c1 = cxy+dashpush*cd c2 = cxy+(dashpush+dashlength)*cd (x1, y1) = transform.inverse_xy_tup(tuple(c1)) @@ -75,9 +75,9 @@ # well enough yet. we = self._mytext.get_window_extent(renderer=renderer) w, h = we.width(), we.height() - off = npy.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1]) - off = npy.array([cos_theta*(w/2),sin_theta*(h/2)]) - dir = npy.array([cos_theta,sin_theta])*dashpad + off = np.array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1]) + off = np.array([cos_theta*(w/2),sin_theta*(h/2)]) + dir = np.array([cos_theta,sin_theta])*dashpad cw = c2 + off +dir self._mytext.set_position(transform.inverse_xy_tup(tuple(cw))) Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -6,7 +6,7 @@ from __future__ import division import os -import numpy as npy +import numpy as np import matplotlib.cbook as cbook import matplotlib.colors as colors import matplotlib._image as _image @@ -122,10 +122,10 @@ meshWidth, meshHeight, coordinates) if showedges: - edgecolors = npy.array([[0.0, 0.0, 0.0, 1.0]], npy.float_) + edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_) else: edgecolors = facecolors - linewidths = npy.array([1.0], npy.float_) + linewidths = np.array([1.0], np.float_) return self.draw_path_collection( master_transform, cliprect, clippath, clippath_trans, @@ -1569,7 +1569,7 @@ a.set_ylim((y0, y1)) elif self._button_pressed == 3: if a.get_xscale()=='log': - alpha=npy.log(Xmax/Xmin)/npy.log(x1/x0) + alpha=np.log(Xmax/Xmin)/np.log(x1/x0) rx1=pow(Xmin/x0,alpha)*Xmin rx2=pow(Xmax/x0,alpha)*Xmin else: @@ -1577,7 +1577,7 @@ rx1=alpha*(Xmin-x0)+Xmin rx2=alpha*(Xmax-x0)+Xmin if a.get_yscale()=='log': - alpha=npy.log(Ymax/Ymin)/npy.log(y1/y0) + alpha=np.log(Ymax/Ymin)/np.log(y1/y0) ry1=pow(Ymin/y0,alpha)*Ymin ry2=pow(Ymax/y0,alpha)*Ymin else: Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -5,7 +5,7 @@ from __future__ import generators import re, os, errno, sys, StringIO, traceback, locale import time, datetime -import numpy as npy +import numpy as np try: set = set @@ -856,7 +856,7 @@ class MemoryMonitor: def __init__(self, nmax=20000): self._nmax = nmax - self._mem = npy.zeros((self._nmax,), npy.int32) + self._mem = np.zeros((self._nmax,), np.int32) self.clear() def clear(self): @@ -892,7 +892,7 @@ print "Warning: array size was too small for the number of calls." def xy(self, i0=0, isub=1): - x = npy.arange(i0, self._n, isub) + x = np.arange(i0, self._n, isub) return x, self._mem[i0:self._n:isub] def plot(self, i0=0, isub=1, fig=None): @@ -1051,11 +1051,11 @@ def simple_linear_interpolation(a, steps): - steps = npy.floor(steps) + steps = np.floor(steps) new_length = ((len(a) - 1) * steps) + 1 new_shape = list(a.shape) new_shape[0] = new_length - result = npy.zeros(new_shape, a.dtype) + result = np.zeros(new_shape, a.dtype) result[0] = a[0] a0 = a[0:-1] Modified: trunk/matplotlib/lib/matplotlib/cm.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cm.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/cm.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -2,7 +2,7 @@ This module contains the instantiations of color mapping classes """ -import numpy as npy +import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors @@ -56,18 +56,18 @@ try: if x.ndim == 3: if x.shape[2] == 3: - if x.dtype == npy.uint8: - alpha = npy.array(alpha*255, npy.uint8) + if x.dtype == np.uint8: + alpha = np.array(alpha*255, np.uint8) m, n = x.shape[:2] - xx = npy.empty(shape=(m,n,4), dtype = x.dtype) + xx = np.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) + if bytes and xx.dtype != np.uint8: + xx = (xx * 255).astype(np.uint8) return xx except AttributeError: pass Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/collections.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -8,7 +8,7 @@ line segemnts) """ import math, warnings -import numpy as npy +import numpy as np import matplotlib as mpl import matplotlib.cbook as cbook import matplotlib.colors as _colors # avoid conflict with kwarg @@ -51,7 +51,7 @@ draw time a call to scalar mappable will be made to set the face colors. """ - _offsets = npy.array([], npy.float_) + _offsets = np.array([], np.float_) _transOffset = transforms.IdentityTransform() _transforms = [] @@ -84,11 +84,11 @@ self.set_antialiased(antialiaseds) self._uniform_offsets = None - self._offsets = npy.array([], npy.float_) + self._offsets = np.array([], np.float_) if offsets is not None: - offsets = npy.asarray(offsets, npy.float_) + offsets = np.asarray(offsets, np.float_) if len(offsets.shape) == 1: - offsets = offsets[npy.newaxis,:] # Make it Nx2. + offsets = offsets[np.newaxis,:] # Make it Nx2. if transOffset is not None: Affine2D = transforms.Affine2D self._offsets = offsets @@ -137,7 +137,7 @@ if not transOffset.is_affine: offsets = transOffset.transform_non_affine(offsets) transOffset = transOffset.get_affine() - offsets = npy.asarray(offsets, npy.float_) + offsets = np.asarray(offsets, np.float_) result = mpath.get_path_collection_extents( transform.frozen(), paths, self.get_transforms(), @@ -166,7 +166,7 @@ ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - offsets = npy.asarray(offsets, npy.float_) + offsets = np.asarray(offsets, np.float_) self.update_scalarmappable() @@ -206,7 +206,7 @@ ind = mpath.point_in_path_collection( mouseevent.x, mouseevent.y, self._pickradius, transform.frozen(), paths, self.get_transforms(), - npy.asarray(self._offsets, npy.float_), + np.asarray(self._offsets, np.float_), self._transOffset.frozen(), len(self._facecolors)) return len(ind)>0,dict(ind=ind) @@ -424,7 +424,7 @@ # By converting to floats now, we can avoid that on every draw. self._coordinates = self._coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) - self._coordinates = npy.array(self._coordinates, npy.float_) + self._coordinates = np.array(self._coordinates, np.float_) def get_paths(self, dataTrans=None): if self._paths is None: @@ -439,11 +439,11 @@ c = coordinates # 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( + codes = np.array( [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY], Path.code_type) - points = npy.concatenate(( + points = np.concatenate(( c[0:-1, 0:-1], c[0:-1, 1: ], c[1: , 1: ], @@ -470,7 +470,7 @@ ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - offsets = npy.asarray(offsets, npy.float_) + offsets = np.asarray(offsets, np.float_) if self.check_update('array'): self.update_scalarmappable() @@ -556,8 +556,8 @@ Example: see examples/dynamic_collection.py for complete example - offsets = npy.random.rand(20,2) - facecolors = [cm.jet(x) for x in npy.random.rand(20)] + offsets = np.random.rand(20,2) + facecolors = [cm.jet(x) for x in np.random.rand(20)] black = (0,0,0,1) collection = RegularPolyCollection( @@ -584,7 +584,7 @@ # in points^2 self._transforms = [ transforms.Affine2D().rotate(-self._rotation).scale( - (npy.sqrt(x) * renderer.dpi / 72.0) / npy.sqrt(npy.pi)) + (np.sqrt(x) * renderer.dpi / 72.0) / np.sqrt(np.pi)) for x in self._sizes] return Collection.draw(self, renderer) @@ -679,7 +679,7 @@ pickradius=pickradius, **kwargs) - self._facecolors = npy.array([]) + self._facecolors = np.array([]) self.set_segments(segments) def get_paths(self): @@ -687,7 +687,7 @@ def set_segments(self, segments): if segments is None: return - segments = [npy.asarray(seg, npy.float_) for seg in segments] + segments = [np.asarray(seg, np.float_) for seg in segments] if self._uniform_offsets is not None: segments = self._add_offsets(segments) self._paths = [mpath.Path(seg) for seg in segments] Modified: trunk/matplotlib/lib/matplotlib/colorbar.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/colorbar.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -15,7 +15,7 @@ ''' -import numpy as npy +import numpy as np import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cm as cm @@ -185,7 +185,7 @@ self._process_values() self._find_range() X, Y = self._mesh() - C = self._values[:,npy.newaxis] + C = self._values[:,np.newaxis] self._config_axes(X, Y) if self.filled: self._add_solids(X, Y, C) @@ -248,13 +248,13 @@ ''' N = X.shape[0] ii = [0, 1, N-2, N-1, 2*N-1, 2*N-2, N+1, N, 0] - x = npy.take(npy.ravel(npy.transpose(X)), ii) - y = npy.take(npy.ravel(npy.transpose(Y)), ii) + x = np.take(np.ravel(np.transpose(X)), ii) + y = np.take(np.ravel(np.transpose(Y)), ii) x = x.reshape((len(x), 1)) y = y.reshape((len(y), 1)) if self.orientation == 'horizontal': - return npy.hstack((y, x)) - return npy.hstack((x, y)) + return np.hstack((y, x)) + return np.hstack((x, y)) def _edges(self, X, Y): ''' @@ -276,7 +276,7 @@ if self.orientation == 'vertical': args = (X, Y, C) else: - args = (npy.transpose(Y), npy.transpose(X), npy.transpose(C)) + args = (np.transpose(Y), np.transpose(X), np.transpose(C)) kw = {'cmap':self.cmap, 'norm':self.norm, 'shading':'flat', 'alpha':self.alpha} # Save, set, and restore hold state to keep pcolor from @@ -303,8 +303,8 @@ dummy, y = self._locate(levels) if len(y) <> N: raise ValueError("levels are outside colorbar range") - x = npy.array([0.0, 1.0]) - X, Y = npy.meshgrid(x,y) + x = np.array([0.0, 1.0]) + X, Y = np.meshgrid(x,y) if self.orientation == 'vertical': xy = [zip(X[i], Y[i]) for i in range(N)] else: @@ -348,7 +348,7 @@ locator.set_data_interval(*intv) formatter.set_view_interval(*intv) formatter.set_data_interval(*intv) - b = npy.array(locator()) + b = np.array(locator()) b, ticks = self._locate(b) formatter.set_locs(b) ticklabels = [formatter(t, i) for i, t in enumerate(b)] @@ -364,32 +364,32 @@ if b is None: b = self.boundaries if b is not None: - self._boundaries = npy.asarray(b, dtype=float) + self._boundaries = np.asarray(b, dtype=float) if self.values is None: self._values = 0.5*(self._boundaries[:-1] + self._boundaries[1:]) if isinstance(self.norm, colors.NoNorm): - self._values = (self._values + 0.00001).astype(npy.int16) + self._values = (self._values + 0.00001).astype(np.int16) return - self._values = npy.array(self.values) + self._values = np.array(self.values) return if self.values is not None: - self._values = npy.array(self.values) + self._values = np.array(self.values) if self.boundaries is None: - b = npy.zeros(len(self.values)+1, 'd') + b = np.zeros(len(self.values)+1, 'd') b[1:-1] = 0.5*(self._values[:-1] - self._values[1:]) b[0] = 2.0*b[1] - b[2] b[-1] = 2.0*b[-2] - b[-3] self._boundaries = b return - self._boundaries = npy.array(self.boundaries) + self._boundaries = np.array(self.boundaries) return # Neither boundaries nor values are specified; # make reasonable ones based on cmap and norm. if isinstance(self.norm, colors.NoNorm): b = self._uniform_y(self.cmap.N+1) * self.cmap.N - 0.5 - v = npy.zeros((len(b)-1,), dtype=npy.int16) - v[self._inside] = npy.arange(self.cmap.N, dtype=npy.int16) + v = np.zeros((len(b)-1,), dtype=np.int16) + v[self._inside] = np.arange(self.cmap.N, dtype=np.int16) if self.extend in ('both', 'min'): v[0] = -1 if self.extend in ('both', 'max'): @@ -403,8 +403,8 @@ b = [b[0]-1] + b if self.extend in ('both', 'max'): b = b + [b[-1] + 1] - b = npy.array(b) - v = npy.zeros((len(b)-1,), dtype=float) + b = np.array(b) + v = np.zeros((len(b)-1,), dtype=float) bi = self.norm.boundaries v[self._inside] = 0.5*(bi[:-1] + bi[1:]) if self.extend in ('both', 'min'): @@ -461,19 +461,19 @@ spaced boundaries, plus ends if required. ''' if self.extend == 'neither': - y = npy.linspace(0, 1, N) + y = np.linspace(0, 1, N) else: if self.extend == 'both': - y = npy.zeros(N + 2, 'd') + y = np.zeros(N + 2, 'd') y[0] = -0.05 y[-1] = 1.05 elif self.extend == 'min': - y = npy.zeros(N + 1, 'd') + y = np.zeros(N + 1, 'd') y[0] = -0.05 else: - y = npy.zeros(N + 1, 'd') + y = np.zeros(N + 1, 'd') y[-1] = 1.05 - y[self._inside] = npy.linspace(0, 1, N) + y[self._inside] = np.linspace(0, 1, N) return y def _proportional_y(self): @@ -503,13 +503,13 @@ transposition for a horizontal colorbar are done outside this function. ''' - x = npy.array([0.0, 1.0]) + x = np.array([0.0, 1.0]) if self.spacing == 'uniform': y = self._uniform_y(self._central_N()) else: y = self._proportional_y() self._y = y - X, Y = npy.meshgrid(x,y) + X, Y = np.meshgrid(x,y) if self.extend in ('min', 'both'): X[0,:] = 0.5 if self.extend in ('max', 'both'): @@ -535,19 +535,19 @@ # floating point errors. xn = self.norm(x, clip=False).filled() in_cond = (xn > -0.001) & (xn < 1.001) - xn = npy.compress(in_cond, xn) - xout = npy.compress(in_cond, x) + xn = np.compress(in_cond, xn) + xout = np.compress(in_cond, x) # The rest is linear interpolation with clipping. y = self._y N = len(b) - ii = npy.minimum(npy.searchsorted(b, xn), N-1) - i0 = npy.maximum(ii - 1, 0) + ii = np.minimum(np.searchsorted(b, xn), N-1) + i0 = np.maximum(ii - 1, 0) #db = b[ii] - b[i0] - db = npy.take(b, ii) - npy.take(b, i0) - db = npy.where(i0==ii, 1.0, db) + db = np.take(b, ii) - np.take(b, i0) + db = np.where(i0==ii, 1.0, db) #dy = y[ii] - y[i0] - dy = npy.take(y, ii) - npy.take(y, i0) - z = npy.take(y, i0) + (xn-npy.take(b,i0))*dy/db + dy = np.take(y, ii) - np.take(y, i0) + z = np.take(y, i0) + (xn-np.take(b,i0))*dy/db return xout, z def set_alpha(self, alpha): Modified: trunk/matplotlib/lib/matplotlib/colors.py =================================================================== --- trunk/matplotlib/lib/matplotlib/colors.py 2008-04-29 14:22:48 UTC (rev 5097) +++ trunk/matplotlib/lib/matplotlib/colors.py 2008-04-29 15:14:36 UTC (rev 5098) @@ -34,7 +34,7 @@ 'chartreuse' are supported. """ import re -import numpy as npy +import numpy as np from numpy import ma import matplotlib.cbook as cbook @@ -320,23 +320,23 @@ """ try: if c.lower() == 'none': - return npy.zeros((0,4), dtype=npy.float_) + return np.zeros((0,4), dtype=np.float_) except AttributeError: pass if len(c) == 0: - return npy.zeros((0,4), dtype=npy.float_) + return np.zeros((0,4), dtype=np.float_) try: result = [self.to_rgba(c, alpha)] except ValueError: # 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, npy.ndarray)): # specific; don't need duck-typing + if not isinstance(c, (list, np.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 result = c - return npy.asarray(result, npy.float_) + return np.asarray(result, np.float_) colorConverter = ColorConverter() @@ -358,7 +358,7 @@ gives the closest value for values of x between 0 and 1. """ try: - adata = npy.array(data) + adata = np.array(data) except: raise TypeError("data must be convertable to an array") shape = adata.shape @@ -372,21 +372,21 @@ if x[0] != 0. or x[-1] != 1.0: raise ValueError( "data mapping points must start with x=0. and end with x=1") - if npy.sometrue(npy.sort(x)-x): + if np.sometrue(np.sort(x)-x): raise ValueError( "data mapping points must have x in increasing order") # begin generation of lookup table x = x * (N-1) - lut = npy.zeros((N,), npy.float) - xind = npy.arange(float(N)) - ind = npy.searchsorted(x, xind)[1:-1] + lut = np.zeros((N,), np.float) + xind = np.arange(float(N)) + ind = np.searchsorted(x, xind)[1:-1] lut[1:-1] = ( ((xind[1:-1] - x[ind-1]) / (x[ind] - x[ind-1])) * (y0[ind] - y1[ind-1]) + y1[ind-1]) lut[0] = y1[0] lut[-1] = y0[-1] # ensure that the lut is confined to values between 0 and 1 by clipping it - npy.clip(lut, 0.0, 1.0) + np.clip(lut, 0.0, 1.0) #lut = where(lut > 1., 1., lut) #lut = where(lut < 0., 0., lut) return lut @@ -437,26 +437,26 @@ mask_bad = None if not cbook.iterable(X): vtype = 'scalar' - xa = npy.array([X]) + xa = np.array([X]) else: vtype = 'array' xma = ma.asarray(X) xa = xma.filled(0) 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. + if xa.dtype.char in np.typecodes['Float']: + np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1. xa = (xa * self.N).astype(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) - npy.putmask(xa, xa<0, self._i_under) + np.putmask(xa, xa>self.N-1, self._i_over) + np.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) + np.putmask(xa, mask_bad, self._i_bad) if bytes: - lut = (self._lut * 255).astype(npy.uint8) + lut = (self._lut * 255).astype(np.uint8) else: lut = self._lut - rgba = npy.empty(shape=xa.shape+(4,), dtype=lut.dtype) + rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype) lut.take(xa, axis=0, mode='clip', out=rgba) # twice as fast as lut[xa]; # using the clip or wrap mode and providing an @@ -501,8 +501,8 @@ raise NotImplementedError("Abstract class only") def is_gray(self): - return (npy.alltrue(self._lut[:,0] == self._lut[:,1]) - and npy.alltrue(self._lut[:,0] == self._lut[:,2])) + return (np.alltrue(self._lut[:,0] == self._lut[:,1]) + and np.alltrue(self._lut[:,0] == self._lut[:,2])) class LinearSegmentedColormap(Colormap): @@ -527,7 +527,7 @@ self._segmentdata = segmentdata def _init(self): - self._lut = npy.ones((self.N + 3, 4), npy.float) + self._lut = np.ones((self.N + 3, 4), np.float) self._lut[:-3, 0] = makeMappingArray(self.N, self._segmentdata['red']) self._lut[:-3, 1] = makeMappingArray(self.N, self._segmentdata['green']) self._lut[:-3, 2] = makeMappingArray(self.N, self._segmentdata['blue']) @@ -579,9 +579,9 @@ def _init(self): - rgb = npy.array([colorConverter.to_rgb(c) - for c in self.colors], npy.float) - self._lut = npy.zeros((self.N + 3, 4), npy.float) + rgb = np.array([colorConverter.to_rgb(c) + for c in self.colors], np.float) + self._lut = np.zeros((self.N + 3, 4), np.float) self._lut[:-3, :-1] = rgb self._lut[:-3, -1] = 1 self._isinit = True @@ -615,10 +615,10 @@ if cbook.iterable(value): vtype = 'array' - val = ma.asarray(value).astype(npy.float) + val = ma.asarray(value).astype(np.float) else: vtype = 'scalar' - val = ma.array([value]).astype(npy.float) + val = ma.array([value]).astype(np.float) self.autoscale_None(val) vmin, vmax = self.vmin, self.vmax @@ -629,7 +629,7 @@ else: if clip: mask = ma.getmask(val) - val = ma.array(npy.clip(val.filled(vmax), vmin, vmax), + val = ma.array(np.clip(val.filled(vmax), vmin, vmax), mask=mask) result = (val-vmin) * (1.0/(vmax-vmin)) if vtype == 'scalar': @@ -674,10 +674,10 @@ if cbook.iterable(value): vtype = 'array' - val = ma.asarray(value).astype(npy.float) + val = ma.asarray(value).astype(np.float) else: vtype = 'scalar' - val = ma.array([value]).astype(npy.float) + val = ma.array([value]).astype(np.float) self.autoscale_None(val) vmin, vmax = self.vmin, self.vmax @@ -690,9 +690,9 @@ else: if clip: mask = ma.getmask(val) - val = ma.array(npy.clip(val.filled(vmax), vmin, vmax), + val = ma.array(np.clip(val.filled(vmax), vmin, vmax), mask=mask) - result = (ma.log(val)-npy.log(vmin))/(npy.log(vmax)-npy.log(vmin)) + result = (ma.log(val)-np.log(vmin))/(np.log(vmax)-np.log(vmin)) if vtype == 'scalar': result = result[0] return result @@ -737,7 +737,7 @@ self.clip = clip self.vmin = boundari... [truncated message content] |