|
From: <nn...@us...> - 2007-07-19 17:23:44
|
Revision: 3577
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3577&view=rev
Author: nnemec
Date: 2007-07-19 10:23:41 -0700 (Thu, 19 Jul 2007)
Log Message:
-----------
completed numpification of most trivial cases
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
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_fltkagg.py
trunk/matplotlib/lib/matplotlib/backends/backend_gd.py
trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
trunk/matplotlib/lib/matplotlib/backends/backend_paint.py
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
trunk/matplotlib/lib/matplotlib/collections.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/proj3d.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
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/CHANGELOG 2007-07-19 17:23:41 UTC (rev 3577)
@@ -1,5 +1,7 @@
-2007-07-19 converted non-numpy relicts troughout the code
+2007-07-19 completed numpification of most trivial cases - NN
+2007-07-19 converted non-numpy relicts troughout the code - NN
+
2007-07-19 replaced the Python code in numerix/ by a minimal wrapper around
numpy that explicitly mentions all symbols that need to be
addressed for further numpification - NN
Modified: trunk/matplotlib/lib/matplotlib/art3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -12,7 +12,7 @@
from colors import Normalize
from cm import jet
-import numerix as nx
+import numpy as npy
import proj3d
class Wrap2D:
@@ -254,8 +254,8 @@
segis.append((si,ei))
si = ei
xs,ys,zs = zip(*points)
- ones = nx.ones(len(xs))
- self.vec = nx.array([xs,ys,zs,ones])
+ ones = npy.ones(len(xs))
+ self.vec = npy.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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/axes3d.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -17,7 +17,7 @@
from transforms import unit_bbox
import figure
-import numerix as nx
+import numpy as npy
from colors import Normalize
import art3d
@@ -122,8 +122,8 @@
self.zz_dataLim.intervalx, self)
def unit_cube(self,vals=None):
- minx,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims()
- xs,ys,zs = ([minx,maxx,maxx,minx,minx,maxx,maxx,minx],
+ minpy,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims()
+ xs,ys,zs = ([minpy,maxx,maxx,minpy,minpy,maxx,maxx,minpy],
[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(nx.asarray, (X,Y,Z))
+ x,y,z = map(npy.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):
- minx,maxx = self.get_w_xlim()
+ minpy,maxx = self.get_w_xlim()
miny,maxy = self.get_w_ylim()
minz,maxz = self.get_w_zlim()
- return minx,maxx,miny,maxy,minz,maxz
+ return minpy,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 panx(self, numsteps):
+ def panpy(self, numsteps):
print 'numsteps', numsteps
def view_init(self, elev, azim):
@@ -276,7 +276,7 @@
point.
"""
- relev,razim = nx.pi * self.elev/180, nx.pi * self.azim/180
+ relev,razim = npy.pi * self.elev/180, npy.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 = nx.array([0.5,0.5,0.5])
+ R = npy.array([0.5,0.5,0.5])
#
- 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
+ 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
- E = nx.array((xp, yp, zp))
+ E = npy.array((xp, yp, zp))
#
self.eye = E
self.vvec = R - E
self.vvec = self.vvec / proj3d.mod(self.vvec)
- if abs(relev) > nx.pi/2:
+ if abs(relev) > npy.pi/2:
# upside down
- V = nx.array((0,0,-1))
+ V = npy.array((0,0,-1))
else:
- V = nx.array((0,0,1))
+ V = npy.array((0,0,1))
zfront,zback = -self.dist,self.dist
viewM = proj3d.view_transformation(E,R,V)
perspM = proj3d.persp_transformation(zfront,zback)
- M0 = nx.dot(viewM,worldM)
- M = nx.dot(perspM,M0)
+ M0 = npy.dot(viewM,worldM)
+ M = npy.dot(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 = nx.hypot(x0-xd,y0-yd)
- d1 = nx.hypot(x1-xd,y1-yd)
+ d0 = npy.hypot(x0-xd,y0-yd)
+ d1 = npy.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....
- minx,maxx,miny,maxy,minz,maxz = self.get_w_lims()
+ minpy,maxx,miny,maxy,minz,maxz = self.get_w_lims()
df = 1-((h - dy)/h)
- dx = (maxx-minx)*df
+ dx = (maxx-minpy)*df
dy = (maxy-miny)*df
dz = (maxz-minz)*df
- self.set_w_xlim(minx-dx,maxx+dx)
+ self.set_w_xlim(minpy-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 = nx.transpose(X), nx.transpose(Y), nx.transpose(Z)
+ tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
rstride = cbook.popd(kwargs, 'rstride', 10)
cstride = cbook.popd(kwargs, 'cstride', 10)
#
polys = []
boxes = []
- for rs in nx.arange(0,rows,rstride):
- for cs in nx.arange(0,cols,cstride):
+ for rs in npy.arange(0,rows,rstride):
+ for cs in npy.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 = nx.concatenate((ztop,zleft,zbase,zright))
+ z = npy.concatenate((ztop,zleft,zbase,zright))
ps.append(z)
- boxes.append(map(nx.array,zip(*corners)))
+ boxes.append(map(npy.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(nx.dot(n,[-1,-1,0.5]))
+ shade.append(npy.dot(n,[-1,-1,0.5]))
lines.append((box[0],n+box[0]))
#
- color = nx.array([0,0,1,1])
+ color = npy.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 = nx.transpose(X), nx.transpose(Y), nx.transpose(Z)
+ tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.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 = nx.arange(-3.0, 3.0, delta)
+ x = y = npy.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 = nx.arange(0,4*nx.pi+0.1,0.1)
- ys = nx.sin(xs)
+ xs = npy.arange(0,4*npy.pi+0.1,0.1)
+ ys = npy.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 = nx.arange(0,10,0.4)
+ xs = npy.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 = nx.arange(20)
+ xs = npy.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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -7,14 +7,13 @@
import re
import sys
-from numerix import arange, array, asarray, ones, zeros, \
+from numpy import arange, array, asarray, ones, zeros, \
nonzero, take, log10, logical_and, \
- dot, sin, cos, tan, pi, sqrt
+ dot, sin, cos, tan, pi, sqrt, linspace
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
Modified: trunk/matplotlib/lib/matplotlib/axis3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis3d.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/axis3d.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -13,7 +13,7 @@
import art3d
import proj3d
-from numerix import sin, cos, pi, cumsum, dot, asarray, array, \
+from numpy 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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -437,7 +437,7 @@
def points_to_pixels(self, points):
"""
Convert points to display units
- points - a float or a numerix array of float
+ points - a float or a numpy 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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -73,7 +73,7 @@
import os, sys
import matplotlib
from matplotlib import verbose, rcParams
-from numpy import array, zeros, transpose
+from numpy import array, zeros, transpose, fliplr
from matplotlib._image import fromarray
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase,\
@@ -85,7 +85,6 @@
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
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -17,6 +17,8 @@
import os.path
+from numpy import asarray
+
import matplotlib
from matplotlib import rcParams, verbose
@@ -26,7 +28,6 @@
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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gd.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -12,6 +12,7 @@
sys.exit()
+from numpy import ones, array, int16, asarray
from matplotlib.backend_bases import RendererBase, \
GraphicsContextBase, FigureManagerBase, FigureCanvasBase
@@ -22,7 +23,6 @@
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(nx.int16)
- y = self.height*ones(y.shape, nx.int16) - y.astype(nx.int16)
+ x = x.astype(int16)
+ y = self.height*ones(y.shape, int16) - y.astype(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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -16,6 +16,9 @@
% (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, \
@@ -23,11 +26,7 @@
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
@@ -144,8 +143,8 @@
def draw_lines(self, gc, x, y, transform=None):
if gc.gdkGC.line_width > 0:
- x = x.astype(nx.int16)
- y = self.height - y.astype(nx.int16)
+ x = x.astype(int16)
+ y = self.height - y.astype(int16)
self.gdkDrawable.draw_lines(gc.gdkGC, zip(x,y))
@@ -222,7 +221,7 @@
Xall[:,i] = fromstring(image_str, uint8)
# get the max alpha at each pixel
- Xs = numerix.mlab.max(Xall,1)
+ Xs = amax(Xall,axis=1)
# convert it to it's proper shape
Xs.shape = imh, imw
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_paint.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_paint.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_paint.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -16,8 +16,10 @@
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_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -26,7 +26,7 @@
from matplotlib.transforms import get_vec6_scales
-from matplotlib.numerix import uint8, float32, alltrue, array, ceil, equal, \
+from numpy import uint8, float32, alltrue, array, ceil, equal, \
fromstring, nonzero, ones, put, take, where, isnan
import binascii
import re
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -10,6 +10,8 @@
import os.path
+from numpy import asarray
+
import matplotlib
from matplotlib.cbook import is_string_like, enumerate
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
@@ -17,7 +19,6 @@
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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -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
- numerix array of shape (nv,2).
+ numpy 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 numerix should be attainable
+ # Similar speedups with numpy 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 numerix array with two columns.
+ equivalent numpy 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/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -16,8 +16,7 @@
from legend import Legend
from transforms import Bbox, Value, Point, get_bbox_transform, unit_bbox
-from numerix import array, clip, transpose, minimum, maximum
-from mlab import linspace, meshgrid
+from numpy import array, clip, transpose, minimum, maximum, 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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/finance.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -12,6 +12,8 @@
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
@@ -20,7 +22,6 @@
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
@@ -76,7 +77,7 @@
if asobject:
if len(results)==0: return None
else:
- date, open, close, high, low, volume = map(nx.asarray, zip(*results))
+ date, open, close, high, low, volume = map(npy.asarray, zip(*results))
return Bunch(date=date, open=open, close=close, high=high, low=low, volume=volume)
else:
@@ -377,10 +378,10 @@
)
closeCollection.set_transform(tickTransform)
- minx, maxx = (0, len(rangeSegments))
+ minpy, 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 = (minx, miny), (maxx, maxy)
+ corners = (minpy, miny), (maxx, maxy)
ax.update_datalim(corners)
ax.autoscale_view()
@@ -466,11 +467,11 @@
- minx, maxx = (0, len(rangeSegments))
+ minpy, 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 = (minx, miny), (maxx, maxy)
+ corners = (minpy, miny), (maxx, maxy)
ax.update_datalim(corners)
ax.autoscale_view()
@@ -533,10 +534,10 @@
- minx, maxx = (0, len(offsetsBars))
+ minpy, maxx = (0, len(offsetsBars))
miny = 0
maxy = max([v for v in volumes if v!=-1])
- corners = (minx, miny), (maxx, maxy)
+ corners = (minpy, miny), (maxx, maxy)
ax.update_datalim(corners)
ax.autoscale_view()
@@ -626,10 +627,10 @@
- minx, maxx = (min(dates), max(dates))
+ minpy, maxx = (min(dates), max(dates))
miny = 0
maxy = max([volume for d, open, close, high, low, volume in quotes])
- corners = (minx, miny), (maxx, maxy)
+ corners = (minpy, miny), (maxx, maxy)
ax.update_datalim(corners)
#print 'datalim', ax.dataLim.get_bounds()
#print 'viewlim', ax.viewLim.get_bounds()
@@ -683,10 +684,10 @@
- minx, maxx = (0, len(offsetsBars))
+ minpy, maxx = (0, len(offsetsBars))
miny = 0
maxy = max([v for v in vals if v!=-1])
- corners = (minx, miny), (maxx, maxy)
+ corners = (minpy, 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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/image.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -9,9 +9,8 @@
from artist import Artist
from colors import colorConverter
import cm
-import numerix
import numerix.ma as ma
-from numerix import arange, asarray, uint8, float32, repeat, newaxis
+from numpy import arange, asarray, uint8, float32, repeat, newaxis, fromstring
import _image
@@ -477,7 +476,7 @@
def imread(fname):
"""
- return image file in fname as numerix array
+ return image file in fname as numpy array
Return value is a MxNx4 array of 0-1 normalized floats
@@ -504,6 +503,6 @@
raise RuntimeError('Unknown image mode')
x_str = im.tostring('raw',im.mode,0,-1)
- x = numerix.fromstring(x_str,numerix.uint8)
+ x = fromstring(x_str,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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -22,7 +22,7 @@
"""
from __future__ import division
import sys, warnings
-from numerix import array, ones
+from numpy import array, ones, linspace
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 linspace, segments_intersect
+from mlab import segments_intersect
from patches import Patch, Rectangle, RegularPolygon, Shadow, bbox_artist, draw_bbox
from collections import LineCollection, RegularPolyCollection, PatchCollection
from text import Text
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -9,7 +9,7 @@
import sys, math, warnings
import agg
-from numerix import alltrue, arange, array, logical_and, \
+from numpy import 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
Modified: trunk/matplotlib/lib/matplotlib/mathtext.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mathtext.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/mathtext.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -143,7 +143,6 @@
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 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -72,7 +72,7 @@
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
+ conjugate, typecode, iscontiguous, linspace, meshgrid
from numerix.mlab import hanning, cov, diff, svd, rand, std
@@ -93,11 +93,6 @@
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))
@@ -863,42 +858,8 @@
if dim==1: M=transpose(M)
return M
-def meshgrid(x,y):
- """
- For vectors x, y with lengths Nx=len(x) and Ny=len(y), return X, Y
- where X and Y are (Ny, Nx) shaped arrays with the elements of x
- and y repeated to fill the matrix
- EG,
- [X, Y] = meshgrid([1,2,3], [4,5,6,7])
-
- X =
- 1 2 3
- 1 2 3
- 1 2 3
- 1 2 3
-
-
- Y =
- 4 4 4
- 5 5 5
- 6 6 6
- 7 7 7
- """
-
- x = array(x)
- y = array(y)
- numRows, numCols = len(y), len(x) # yes, reversed
- x.shape = 1, numCols
- X = repeat(x, numRows)
-
- y.shape = numRows,1
- Y = repeat(y, numCols, 1)
- return X, Y
-
-
-
def rk4(derivs, y0, t):
"""
Integrate 1D or ND system of ODEs from initial state y0 at sample
Modified: trunk/matplotlib/lib/matplotlib/proj3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/proj3d.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/proj3d.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -7,8 +7,8 @@
from collections import LineCollection
from patches import Circle
-import numerix as nx
-from numerix import linear_algebra
+import numpy as npy
+import numpy.linalg as linalg
from math import sqrt
def _hide_cross(a,b):
@@ -17,7 +17,7 @@
A x B = <Ay*Bz - Az*By, Az*Bx - Ax*Bz, Ax*By - Ay*Bx>
a x b = [a2b3 - a3b2, a3b1 - a1b3, a1b2 - a2b1]
"""
- return nx.array([a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1] - a[1]*b[0]])
+ return npy.array([a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1] - a[1]*b[0]])
cross = _hide_cross
def line2d(p0,p1):
@@ -49,7 +49,7 @@
"""
a,b,c = l
x0,y0 = p
- return abs((a*x0 + b*y0 + c)/nx.sqrt(a**2+b**2))
+ return abs((a*x0 + b*y0 + c)/npy.sqrt(a**2+b**2))
def line2d_seg_dist(p1,p2, p0):
@@ -64,12 +64,12 @@
x21 = p2[0] - p1[0]
y21 = p2[1] - p1[1]
- x01 = nx.asarray(p0[0]) - p1[0]
- y01 = nx.asarray(p0[1]) - p1[1]
+ x01 = npy.asarray(p0[0]) - p1[0]
+ y01 = npy.asarray(p0[1]) - p1[1]
u = (x01*x21 + y01*y21)/float(abs(x21**2 + y21**2))
- u = nx.clip(u, 0, 1)
- d = nx.sqrt((x01 - u*x21)**2 + (y01 - u*y21)**2)
+ u = npy.clip(u, 0, 1)
+ d = npy.sqrt((x01 - u*x21)**2 + (y01 - u*y21)**2)
return d
@@ -86,7 +86,7 @@
pylab.scatter(xs,ys)
#
dist = line2d_seg_dist(p0,p1,(xs[0],ys[0]))
- dist = line2d_seg_dist(p0,p1,nx.array((xs,ys)))
+ dist = line2d_seg_dist(p0,p1,npy.array((xs,ys)))
for x,y,d in zip(xs,ys,dist):
c = Circle((x,y),d,fill=0)
ax.add_patch(c)
@@ -97,13 +97,13 @@
def mod(v):
"""3d vector length"""
- return nx.sqrt(v[0]**2+v[1]**2+v[2]**2)
+ return npy.sqrt(v[0]**2+v[1]**2+v[2]**2)
def world_transformation(xmin,xmax,
ymin,ymax,
zmin,zmax):
dx,dy,dz = (xmax-xmin),(ymax-ymin),(zmax-zmin)
- return nx.array([
+ return npy.array([
[1.0/dx,0,0,-xmin/dx],
[0,1.0/dy,0,-ymin/dy],
[0,0,1.0/dz,-zmin/dz],
@@ -120,11 +120,11 @@
n = (E - R)
## new
# n /= mod(n)
-# u = nx.cross(V,n)
+# u = npy.cross(V,n)
# u /= mod(u)
-# v = nx.cross(n,u)
-# Mr = nx.diag([1.]*4)
-# Mt = nx.diag([1.]*4)
+# v = npy.cross(n,u)
+# Mr = npy.diag([1.]*4)
+# Mt = npy.diag([1.]*4)
# Mr[:3,:3] = u,v,n
# Mt[:3,-1] = -E
## end new
@@ -146,38 +146,38 @@
[0, 0, 0, 1]]
## end old
- return nx.dot(Mr,Mt)
+ return npy.dot(Mr,Mt)
def persp_transformation(zfront,zback):
a = (zfront+zback)/(zfront-zback)
b = -2*(zfront*zback)/(zfront-zback)
- return nx.array([[1,0,0,0],
+ return npy.array([[1,0,0,0],
[0,1,0,0],
[0,0,a,b],
[0,0,-1,0]
])
def proj_transform_vec(vec, M):
- vecw = nx.dot(M,vec)
+ vecw = npy.dot(M,vec)
w = vecw[3]
# clip here..
txs,tys,tzs = vecw[0]/w,vecw[1]/w,vecw[2]/w
return txs,tys,tzs
def proj_transform_vec_clip(vec, M):
- vecw = nx.dot(M,vec)
+ vecw = npy.dot(M,vec)
w = vecw[3]
# clip here..
txs,tys,tzs = vecw[0]/w,vecw[1]/w,vecw[2]/w
tis = (vecw[0] >= 0) * (vecw[0] <= 1) * (vecw[1] >= 0) * (vecw[1] <= 1)
- if nx.sometrue( tis ):
+ if npy.sometrue( tis ):
tis = vecw[1]<1
return txs,tys,tzs,tis
def inv_transform(xs,ys,zs,M):
- iM = linear_algebra.inverse(M)
+ iM = linalg.inv(M)
vec = vec_pad_ones(xs,ys,zs)
- vecr = nx.dot(iM,vec)
+ vecr = npy.dot(iM,vec)
try:
vecr = vecr/vecr[3]
except OverflowError:
@@ -187,11 +187,11 @@
def vec_pad_ones(xs,ys,zs):
try:
try:
- vec = nx.array([xs,ys,zs,nx.ones(xs.shape)])
+ vec = npy.array([xs,ys,zs,npy.ones(xs.shape)])
except (AttributeError,TypeError):
- vec = nx.array([xs,ys,zs,nx.ones((len(xs)))])
+ vec = npy.array([xs,ys,zs,npy.ones((len(xs)))])
except TypeError:
- vec = nx.array([xs,ys,zs,1])
+ vec = npy.array([xs,ys,zs,1])
return vec
def proj_transform(xs,ys,zs, M):
@@ -236,13 +236,13 @@
def test_proj_make_M(E=None):
# eye point
- E = E or nx.array([1,-1,2])*1000
- #E = nx.array([20,10,20])
- R = nx.array([1,1,1])*100
- V = nx.array([0,0,1])
+ E = E or npy.array([1,-1,2])*1000
+ #E = npy.array([20,10,20])
+ R = npy.array([1,1,1])*100
+ V = npy.array([0,0,1])
viewM = view_transformation(E,R,V)
perspM = persp_transformation(100,-100)
- M = nx.dot(perspM,viewM)
+ M = npy.dot(perspM,viewM)
return M
def test_proj():
@@ -251,7 +251,7 @@
ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]]
#xs,ys,zs = [0,1,1,0,0,1,1,0],[0,0,1,1,0,0,1,1],[0,0,0,0,1,1,1,1]
xs,ys,zs = [0,1,1,0,0, 0,1,1,0,0],[0,0,1,1,0, 0,0,1,1,0],[0,0,0,0,0, 1,1,1,1,1]
- xs,ys,zs = [nx.array(v)*300 for v in (xs,ys,zs)]
+ xs,ys,zs = [npy.array(v)*300 for v in (xs,ys,zs)]
#
test_proj_draw_axes(M,s=400)
txs,tys,tzs = proj_transform(xs,ys,zs,M)
@@ -268,19 +268,19 @@
pylab.show()
def rot_x(V,alpha):
- cosa,sina = nx.cos(alpha),nx.sin(alpha)
- M1 = nx.array([[1,0,0,0],
+ cosa,sina = npy.cos(alpha),npy.sin(alpha)
+ M1 = npy.array([[1,0,0,0],
[0,cosa,-sina,0],
[0,sina,cosa,0],
[0,0,0,0]])
#
- return nx.dot(M1,V)
+ return npy.dot(M1,V)
def test_rot():
V = [1,0,0,1]
- print rot_x(V, nx.pi/6)
+ print rot_x(V, npy.pi/6)
V = [0,1,0,1]
- print rot_x(V, nx.pi/6)
+ print rot_x(V, npy.pi/6)
if __name__ == "__main__":
Modified: trunk/matplotlib/lib/matplotlib/texmanager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/texmanager.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/texmanager.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -18,7 +18,7 @@
Only supported on *Agg and PS backends currently
-For raster output, you can get RGBA numerix arrays from TeX expressions
+For raster output, you can get RGBA numpy arrays from TeX expressions
as follows
texmanager = TexManager()
@@ -78,7 +78,7 @@
dvipngVersion = get_dvipng_version()
- # mappable cache of
+ # mappable cache of
arrayd = {}
postscriptd = {}
pscnt = 0
@@ -90,7 +90,7 @@
font_family = 'serif'
font_families = ('serif', 'sans-serif', 'cursive', 'monospace')
- font_info = {'new century schoolbook': ('pnc',
+ font_info = {'new century schoolbook': ('pnc',
r'\renewcommand{\rmdefault}{pnc}'),
'bookman': ('pbk', r'\renewcommand{\rmdefault}{pbk}'),
'times': ('ptm', r'\usepackage{mathptmx}'),
@@ -107,7 +107,7 @@
'computer modern roman': ('cmr', ''),
'computer modern sans serif': ('cmss', ''),
'computer modern typewriter': ('cmtt', '')}
-
+
_rc_cache = None
_rc_cache_keys = ('text.latex.preamble', )\
+ tuple('font.'+n for n in ('family', ) + font_families)
@@ -122,15 +122,15 @@
else:
warnings.warn('The %s font family is not compatible with LaTeX. serif will be used by default.' % ff)
self.font_family = 'serif'
-
+
fontconfig = [self.font_family]
for font_family, font_family_attr in \
((ff, ff.replace('-', '_')) for ff in self.font_families):
for font in rcParams['font.'+font_family]:
- if DEBUG: print 'family: %s, font: %s, info: %s'%(font_family,
+ if DEBUG: print 'family: %s, font: %s, info: %s'%(font_family,
font, self.font_info[font.lower()])
if font.lower() in self.font_info:
- setattr(self, font_family_attr,
+ setattr(self, font_family_attr,
self.font_info[font.lower()])
break
else:
@@ -165,7 +165,7 @@
if changed:
if DEBUG: print 'DEBUG following keys changed:', changed
for k in changed:
- if DEBUG:
+ if DEBUG:
print 'DEBUG %-20s: %-10s -> %-10s' % \
(k, self._rc_cache[k], rcParams[k])
# deepcopy may not be necessary, but feels more future-proof
Modified: trunk/matplotlib/lib/matplotlib/text.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/text.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/text.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -12,7 +12,7 @@
from font_manager import FontProperties
from matplotlib import rcParams
from patches import bbox_artist, YAArrow
-from numerix import sin, cos, pi, cumsum, dot, asarray, array, \
+from numpy import sin, cos, pi, cumsum, dot, asarray, array, \
where, nonzero, equal, sqrt
from transforms import lbwh_to_bbox, bbox_all, identity_transform
from lines import Line2D
Modified: trunk/matplotlib/lib/matplotlib/units.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/units.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/units.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -83,7 +83,7 @@
"""
convert obj using unit. If obj is a sequence, return the
converted sequence. The ouput must be a sequence of scalars
- that can be used by the numerix array layer
+ that can be used by the numpy array layer
"""
return obj
convert = staticmethod(convert)
Modified: trunk/matplotlib/lib/matplotlib/widgets.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/widgets.py 2007-07-19 17:04:19 UTC (rev 3576)
+++ trunk/matplotlib/lib/matplotlib/widgets.py 2007-07-19 17:23:41 UTC (rev 3577)
@@ -7,10 +7,11 @@
to be to accommodate your widget.
"""
-from mlab import linspace, dist
+from numpy import array, linspace
+
+from mlab import dist
from patches import Circle, Rectangle
from lines import Line2D
-from numerix import array
from transforms import blend_xy_sep_transform
class LockDraw:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|