|
From: <nn...@us...> - 2007-07-20 15:42:14
|
Revision: 3592
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3592&view=rev
Author: nnemec
Date: 2007-07-20 08:42:09 -0700 (Fri, 20 Jul 2007)
Log Message:
-----------
Numpification new try: dont touch numerix/, but make mpl code independent of it.
(Including conversion to "import numpy as npy")
Complete except for pylab.py and mlab.py
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/art3d.py
trunk/matplotlib/lib/matplotlib/axes.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/contour.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/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
Modified: trunk/matplotlib/lib/matplotlib/art3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/art3d.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -3682,7 +3682,7 @@
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,), numpy.float_) * widths
+ widths = npy.ones((col,), float) * widths
# loop through columns, adding each to plot
self.hold(True)
Modified: trunk/matplotlib/lib/matplotlib/axes3d.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes3d.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/axes3d.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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.matrixmultiply(viewM,worldM)
- M = nx.matrixmultiply(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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/axis.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -7,14 +7,9 @@
import re
import sys
-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
@@ -118,7 +113,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.
"""
@@ -492,7 +487,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))
@@ -657,7 +652,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
@@ -677,7 +672,7 @@
return silent_list('Line2D ticklines', lines)
def get_ticklocs(self):
- "Get the tick locations in data coordinates as a Numeric array"
+ "Get the tick locations in data coordinates as a numpy array"
return self.major.locator()
def _get_tick(self, major):
@@ -901,11 +896,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
@@ -967,12 +962,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))
@@ -1155,11 +1150,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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/axis3d.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -13,8 +13,7 @@
import art3d
import proj3d
-from numerix import sin, cos, pi, cumsum, dot, asarray, array, \
- where, nonzero, equal, sqrt
+import numpy as npy
def norm_angle(a):
"""Return angle between -180 and +180"""
@@ -47,13 +46,13 @@
angle = text.get_rotation(dashrotation)
- theta = pi*(angle/180.0+dashdirection-1)
- cos_theta, sin_theta = cos(theta), sin(theta)
+ theta = math.pi*(angle/180.0+dashdirection-1)
+ cos_theta, sin_theta = math.cos(theta), math.sin(theta)
# Compute the dash end points
# The 'c' prefix is for canvas coordinates
- cxy = array(transform.xy_tup((x, y)))
- cd = array([cos_theta, sin_theta])
+ cxy = npy.array(transform.xy_tup((x, y)))
+ cd = npy.array([cos_theta, sin_theta])
c1 = cxy+dashpush*cd
c2 = cxy+(dashpush+dashlength)*cd
(x1, y1) = transform.inverse_xy_tup(tuple(c1))
@@ -76,9 +75,9 @@
# well enough yet.
we = self._mytext.get_window_extent(renderer=renderer)
w, h = we.width(), we.height()
- off = array([cos_theta*(w/2+2)-1,sin_theta*(h+1)-1])
- off = array([cos_theta*(w/2),sin_theta*(h/2)])
- dir = array([cos_theta,sin_theta])*dashpad
+ 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
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 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -69,23 +69,22 @@
"""
from __future__ import division
-
import os, sys
+
+import numpy as npy
+
import matplotlib
from matplotlib import verbose, rcParams
-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,\
GraphicsContextBase, FigureManagerBase, FigureCanvasBase
-
from matplotlib.cbook import enumerate, is_string_like, exception_to_str
from matplotlib.figure import Figure
from matplotlib.font_manager import fontManager
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
@@ -154,8 +153,8 @@
point in x, y
"""
if __debug__: verbose.report('RendererAgg.draw_line', 'debug-annoying')
- x = array([x1,x2], typecode=Float)
- y = array([y1,y2], typecode=Float)
+ x = npy.array([x1,x2], float)
+ y = npy.array([y1,y2], float)
self._renderer.draw_lines(gc, x, y)
@@ -271,9 +270,9 @@
m,n,tmp = Z.shape
def func(x):
- return transpose(fliplr(x))
+ return npy.transpose(npy.fliplr(x))
- Z = zeros((n,m,4), typecode=Float)
+ Z = npy.zeros((n,m,4), 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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_agg2.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -8,7 +8,6 @@
import matplotlib.agg as agg
from matplotlib import verbose
-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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -19,9 +19,10 @@
"""
from __future__ import division
-import os
-import sys
-import warnings
+import os, sys, warnings
+
+import numpy as npy
+
def _fn_name(): return sys._getframe(1).f_code.co_name
import cairo
@@ -38,7 +39,6 @@
from matplotlib.cbook import enumerate, izip
from matplotlib.figure import Figure
from matplotlib.mathtext import math_parse_s_ft2font
-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, numx.pi * angle1 / 180.,
- numx.pi * angle2 / 180.)
+ ctx.arc(0.0, 0.0, 1.0, npy.pi * angle1 / 180.,
+ npy.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*numx.pi)
+ ctx.arc (x, self.height - y, 0.5, 0, 2*npy.pi)
self._fill_and_stroke (ctx, gc.get_rgb())
@@ -294,7 +294,7 @@
ctx.save()
if angle:
- ctx.rotate (-angle * numx.pi / 180)
+ ctx.rotate (-angle * npy.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 numx.which[0] == "numarray":
+ #if npy.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 = numx.zeros((N,len(fonts)), typecode=numx.UInt8)
+ Xall = npy.zeros((N,len(fonts)), npy.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] = numx.fromstring(s, numx.UInt8)
+ Xall[:,i] = npy.fromstring(s, npy.uint8)
# get the max alpha at each pixel
- Xs = numx.mlab.max (Xall,1)
+ Xs = npy.mlab.max (Xall,1)
# convert it to it's proper shape
Xs.shape = imh, imw
- pa = numx.zeros(shape=(imh,imw,4), typecode=numx.UInt8)
+ pa = npy.zeros((imh,imw,4), npy.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 (numx.asarray(dashes)), offset)
+ self.renderer.points_to_pixels (npy.asarray(dashes)), offset)
def set_foreground(self, fg, isRGB=None):
@@ -593,7 +593,7 @@
ctx = renderer.ctx
if orientation == 'landscape':
- ctx.rotate (numx.pi/2)
+ ctx.rotate (npy.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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_fltkagg.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -26,7 +26,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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gd.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -6,13 +6,14 @@
from __future__ import division
import sys, os, math, warnings
-try: import gd
+import numpy as npy
+
+try:
+ import gd
except ImportError:
print >>sys.stderr, 'You must first install the gd module http://newcenturycomputers.net/projects/gdmodule.html'
sys.exit()
-
-
from matplotlib.backend_bases import RendererBase, \
GraphicsContextBase, FigureManagerBase, FigureCanvasBase
from matplotlib import verbose
@@ -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')):
@@ -107,7 +107,7 @@
"""
Draw a single line from x1,y1 to x2,y2
"""
- self.draw_lines(gc, array([x1, x2]), array([y1, y2]))
+ self.draw_lines(gc, npy.array([x1, x2]), npy.array([y1, y2]))
def draw_lines(self, gc, x, y):
"""
@@ -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(npy.int16)
+ y = self.height*npy.ones(y.shape, npy.int16) - y.astype(npy.int16)
style = self._set_gd_style(gc)
self.im.lines( zip(x,y), style)
self.flush_clip()
@@ -269,7 +269,7 @@
convert point measures to pixes using dpi and the pixels per
inch of the display
"""
- return asarray(points)*(PIXELS_PER_INCH/72.0*self.dpi.get()/72.0)
+ return npy.asarray(points)*(PIXELS_PER_INCH/72.0*self.dpi.get()/72.0)
class GraphicsContextGD(GraphicsContextBase):
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gdk.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -16,6 +16,8 @@
% (gtk.pygtk_version + pygtk_version_required))
del pygtk_version_required
+import numpy as npy
+
import matplotlib
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \
@@ -23,11 +25,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
@@ -106,7 +104,7 @@
im.flipud_out()
rows, cols, image_str = im.as_rgba_str()
- image_array = fromstring(image_str, UInt8)
+ image_array = npy.fromstring(image_str, npy.uint8)
image_array.shape = rows, cols, 4
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
@@ -144,8 +142,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(npy.int16)
+ y = self.height - y.astype(npy.int16)
self.gdkDrawable.draw_lines(gc.gdkGC, zip(x,y))
@@ -213,16 +211,16 @@
N = imw*imh
# a numpixels by num fonts array
- Xall = zeros((N,len(fonts)), typecode=UInt8)
+ Xall = npy.zeros((N,len(fonts)), npy.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] = npy.fromstring(image_str, npy.uint8)
# get the max alpha at each pixel
- Xs = numerix.mlab.max(Xall,1)
+ Xs = npy.amax(Xall,axis=1)
# convert it to it's proper shape
Xs.shape = imh, imw
@@ -422,7 +420,7 @@
if dash_list == None:
self.gdkGC.line_style = gdk.LINE_SOLID
else:
- pixels = self.renderer.points_to_pixels(asarray(dash_list))
+ pixels = self.renderer.points_to_pixels(npy.asarray(dash_list))
dl = [max(1, int(round(val))) for val in pixels]
self.gdkGC.set_dashes(dash_offset, dl)
self.gdkGC.line_style = gdk.LINE_ON_OFF_DASH
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -22,9 +22,6 @@
from matplotlib.cbook import is_string_like, enumerate
from matplotlib.colors import colorConverter
from matplotlib.figure import Figure
-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
@@ -156,7 +153,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)
@@ -1087,7 +1084,7 @@
hbox.show_all()
self.set_extra_widget(hbox)
-
+
def get_filename_from_user (self):
while True:
filename = None
@@ -1137,7 +1134,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):
@@ -1279,7 +1276,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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_paint.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -16,8 +16,10 @@
import sys
import os
import paint
+
+import numpy as npy
+
from matplotlib import verbose
-from matplotlib.numerix import asarray
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import RendererBase,\
@@ -155,7 +157,7 @@
offset, dashes = gc.get_dashes()
if dashes is not None:
- dashes = tuple(self.points_to_pixels(asarray(dashes)))
+ dashes = tuple(self.points_to_pixels(npy.asarray(dashes)))
return path.dash(offset, dashes)
else:
return path
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -12,6 +12,8 @@
import time
import zlib
+import numpy as npy
+
from cStringIO import StringIO
from datetime import datetime
from math import ceil, cos, floor, pi, sin
@@ -28,7 +30,6 @@
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 matplotlib.numerix import Float32, UInt8, fromstring, arange, infinity, isnan, asarray
from matplotlib.transforms import Bbox
from matplotlib import ttconv
@@ -111,7 +112,7 @@
# need to use %f with some precision. Perhaps the precision
# should adapt to the magnitude of the number?
elif isinstance(obj, float):
- if isnan(obj) or obj in (-infinity, infinity):
+ if npy.isnan(obj) or obj in (-npy.infinity, npy.infinity):
raise ValueError, "Can only output finite numbers in PDF"
r = "%.10f" % obj
return r.rstrip('0').rstrip('.')
@@ -543,13 +544,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 +633,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)
@@ -712,21 +713,21 @@
0, 0, sidelen, sidelen, Op.rectangle,
Op.fill)
if lst[2]: # -
- for j in arange(0.0, sidelen, density/lst[2]):
+ for j in npy.arange(0.0, sidelen, density/lst[2]):
self.output(0, j, Op.moveto,
sidelen, j, Op.lineto)
if lst[3]: # /
- for j in arange(0.0, sidelen, density/lst[3]):
+ for j in npy.arange(0.0, sidelen, density/lst[3]):
self.output(0, j, Op.moveto,
sidelen-j, sidelen, Op.lineto,
sidelen-j, 0, Op.moveto,
sidelen, j, Op.lineto)
if lst[4]: # |
- for j in arange(0.0, sidelen, density/lst[4]):
+ for j in npy.arange(0.0, sidelen, density/lst[4]):
self.output(j, 0, Op.moveto,
j, sidelen, Op.lineto)
if lst[5]: # \
- for j in arange(sidelen, 0.0, -density/lst[5]):
+ for j in npy.arange(sidelen, 0.0, -density/lst[5]):
self.output(sidelen, j, Op.moveto,
j, sidelen, Op.lineto,
j, 0, Op.moveto,
@@ -755,20 +756,20 @@
def _rgb(self, im):
h,w,s = im.as_rgba_str()
- rgba = fromstring(s, UInt8)
+ rgba = npy.fromstring(s, npy.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 = npy.fromstring(rgbat[2], npy.uint8)
rgba.shape = (rgbat[0], rgbat[1], 4)
- rgba_f = rgba.astype(Float32)
+ rgba_f = rgba.astype(npy.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(npy.uint8)
return rgbat[0], rgbat[1], gray.tostring()
def writeImages(self):
@@ -999,7 +1000,7 @@
imob, Op.use_xobject, Op.grestore)
def draw_line(self, gc, x1, y1, x2, y2):
- if isnan(x1) or isnan(x2) or isnan(y1) or isnan(y2):
+ if npy.isnan(x1) or npy.isnan(x2) or npy.isnan(y1) or npy.isnan(y2):
return
self.check_gc(gc)
self.file.output(x1, y1, Op.moveto,
@@ -1009,7 +1010,7 @@
self.check_gc(gc)
if transform is not None:
x, y = transform.seq_x_y(x, y)
- nan_at = isnan(x) | isnan(y)
+ nan_at = npy.isnan(x) | npy.isnan(y)
next_op = Op.moveto
for i in range(len(x)):
if nan_at[i]:
@@ -1061,8 +1062,8 @@
self.check_gc(gc, rgbFace)
fillp = rgbFace is not None
marker = self.file.markerObject(path, fillp, self.gc._linewidth)
- x, y = trans.numerix_x_y(asarray(x), asarray(y))
- nan_at = isnan(x) | isnan(y)
+ x, y = trans.numerix_x_y(npy.asarray(x), npy.asarray(y))
+ nan_at = npy.isnan(x) | npy.isnan(y)
self.file.output(Op.gsave)
ox, oy = 0, 0
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -26,8 +26,7 @@
from matplotlib.transforms import get_vec6_scales
-from matplotlib.numerix import UInt8, Float32, alltrue, array, ceil, equal, \
- fromstring, nonzero, ones, put, take, where, isnan
+import numpy as npy
import binascii
import re
import sets
@@ -113,7 +112,7 @@
#ok, neither are None:, assuming iterable
if len(seq1) != len(seq2): return False
- return alltrue(equal(seq1, seq2))
+ return npy.alltrue(npy.equal(seq1, seq2))
class RendererPS(RendererBase):
@@ -336,20 +335,20 @@
def _rgb(self, im):
h,w,s = im.as_rgba_str()
- rgba = fromstring(s, UInt8)
+ rgba = npy.fromstring(s, npy.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 = npy.fromstring(rgbat[2], npy.uint8)
rgba.shape = (rgbat[0], rgbat[1], 4)
- rgba_f = rgba.astype(Float32)
+ rgba_f = rgba.astype(npy.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(npy.uint8)
return rgbat[0], rgbat[1], gray.tostring()
def _hex_lines(self, s, chars_per_line=128):
@@ -490,7 +489,7 @@
start = 0
end = step
- mask = where(isnan(x) + isnan(y), 0, 1)
+ mask = npy.where(npy.isnan(x) + npy.isnan(y), 0, 1)
cliprect = gc.get_clip_rectangle()
if cliprect:
@@ -512,7 +511,7 @@
def draw_lines(self, gc, x, y, transform):
"""
- x and y are equal length arrays, draw lines connecting each
+ x and y are npy.equal length arrays, draw lines connecting each
point in x, y
"""
if debugPS: self._pswriter.write('% draw_lines \n')
@@ -534,7 +533,7 @@
start = 0
end = step
- skip = where(isnan(x) + isnan(y), 1, 0)
+ skip = npy.where(npy.isnan(x) + npy.isnan(y), 1, 0)
points = zip(x,y,skip)
self.push_gc(gc, store=1)
@@ -556,14 +555,14 @@
def draw_lines_old(self, gc, x, y, transform=None):
"""
- x and y are equal length arrays, draw lines connecting each
+ x and y are npy.equal length arrays, draw lines connecting each
point in x, y
"""
if debugPS: self._pswriter.write('% draw_lines \n')
write = self._pswriter.write
- mask = where(isnan(x) + isnan(y), 0, 1)
+ mask = npy.where(npy.isnan(x) + npy.isnan(y), 0, 1)
if transform: # this won't be called if draw_markers is hidden
if transform.need_nonlinear():
x,y,mask = transform.nonlinear_only_numerix(x, y, returnMask=1)
@@ -589,16 +588,16 @@
points = zip(x,y)
while start < len(x):
- # put moveto on all the bad data and on the first good
+ # npy.put moveto on all the bad data and on the first good
# point after the bad data
codes = [('m','l')[int(i)] for i in mask]
- ind = nonzero(mask[start:end+1]==0)+1
+ ind = npy.nonzero(mask[start:end+1]==0)+1
if len(ind):
if ind[-1]>=len(codes):
ind = ind[:-1]
for i in ind:
codes[i] = 'm'
- # put a moveto on the first point, regardless
+ # npy.put a moveto on the first point, regardless
codes[0] = 'm'
thisx = x[start:end+1]
@@ -1384,7 +1383,7 @@
dy = (bbox[3]-bbox[1])/2
l,b,r,t = (x-dx, y-dy, x+dx, y+dy)
- bbox_info = '%%%%BoundingBox: %d %d %d %d' % (l, b, ceil(r), ceil(t))
+ bbox_info = '%%%%BoundingBox: %d %d %d %d' % (l, b, npy.ceil(r), npy.ceil(t))
hires_bbox_info = '%%%%HiResBoundingBox: %.6f %.6f %.6f %.6f' % (l, b, r, t)
return '\n'.join([bbox_info, hires_bbox_info])
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -5,9 +5,6 @@
import matplotlib
from matplotlib import verbose
-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, \
@@ -323,7 +320,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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -5,9 +5,6 @@
import matplotlib
from matplotlib import verbose
-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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -17,7 +17,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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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(npy.int)
+ 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)
Modified: trunk/matplotlib/lib/matplotlib/contour.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/contour.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/contour.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -216,8 +216,8 @@
yy=npy.asarray(slc)[:,1].copy()
#indices which are under the label
- inds=npy.nonzero(((xx < x+xlabel) & (xx > x-xlabel)) &
- ((yy < y+ylabel) & (yy > y-ylabel)))[0]
+ inds, = npy.nonzero(((xx < x+xlabel) & (xx > x-xlabel)) &
+ ((yy < y+ylabel) & (yy > y-ylabel)))
if len(inds) >0:
#if the label happens to be over the beginning of the
@@ -225,7 +225,7 @@
#indices to be removed are
#inds= [0,1,2,3,305,306,307]
#should rewrite this in a better way
- linds = npy.nonzero(inds[1:]- inds[:-1] != 1)[0]
+ linds, = npy.nonzero(inds[1:]- inds[:-1] != 1)
if inds[0] == 0 and len(linds) != 0:
ii = inds[linds[0]]
lc1 =linecontour[ii+1:inds[ii+1]]
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -2,6 +2,9 @@
Figure class -- add docstring here!
"""
import sys
+
+import numpy as npy
+
import artist
from artist import Artist
from axes import Axes, Subplot, PolarSubplot, PolarAxes
@@ -16,8 +19,6 @@
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 ticker import FormatStrFormatter
from cm import ScalarMappable
from contour import ContourSet
@@ -842,8 +843,8 @@
# min/max sizes to respect when autoscaling. If John likes the idea, they
# could become rc parameters, for now they're hardwired.
- figsize_min = array((4.0,2.0)) # min length for width/height
- figsize_max = array((16.0,16.0)) # max length for width/height
+ figsize_min = npy.array((4.0,2.0)) # min length for width/height
+ figsize_max = npy.array((16.0,16.0)) # max length for width/height
#figsize_min = rcParams['figure.figsize_min']
#figsize_max = rcParams['figure.figsize_max']
@@ -858,7 +859,7 @@
fig_height = rcParams['figure.figsize'][1]
# New size for the figure, keeping the aspect ratio of the caller
- newsize = array((fig_height/arr_ratio,fig_height))
+ newsize = npy.array((fig_height/arr_ratio,fig_height))
# Sanity checks, don't drop either dimension below figsize_min
newsize /= min(1.0,*(newsize/figsize_min))
@@ -868,7 +869,7 @@
# Finally, if we have a really funky aspect ratio, break it but respect
# the min/max dimensions (we don't want figures 10 feet tall!)
- newsize = clip(newsize,figsize_min,figsize_max)
+ newsize = npy.clip(newsize,figsize_min,figsize_max)
return newsize
artist.kwdocd['Figure'] = artist.kwdoc(Figure)
Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py 2007-07-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/finance.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/image.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -5,13 +5,14 @@
"""
from __future__ import division
import sys, os
+
+import numpy as npy
+import numerix.ma as ma
+
from matplotlib import rcParams
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, typecode
import _image
@@ -117,7 +118,7 @@
raise RuntimeError('You must first set the image array or the image attribute')
if self._imcache is None:
- if typecode(self._A) == UInt8 and len(self._A.shape) == 3:
+ if self._A.dtype == npy.uint8 and len(self._A.shape) == 3:
im = _image.frombyte(self._A, 0)
im.is_grayscale = False
else:
@@ -186,7 +187,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
@@ -197,7 +198,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):
@@ -333,9 +334,9 @@
return im
def set_data(self, x, y, A):
- x = asarray(x).astype(Float32)
- y = asarray(y).astype(Float32)
- A = asarray(A)
+ x = npy.asarray(x,npy.float32)
+ y = npy.asarray(y,npy.float32)
+ A = npy.asarray(A)
if len(x.shape) != 1 or len(y.shape) != 1\
or A.shape[0:2] != (y.shape[0], x.shape[0]):
raise TypeError("Axes don't match array shape")
@@ -346,16 +347,16 @@
if len(A.shape) == 3 and A.shape[2] == 1:
A.shape = A.shape[0:2]
if len(A.shape) == 2:
- if typecode(A) != UInt8:
- A = (self.cmap(self.norm(A))*255).astype(UInt8)
+ if A.dtype != npy.uint8:
+ A = (self.cmap(self.norm(A))*255).astype(npy.uint8)
else:
- A = repeat(A[:,:,NewAxis], 4, 2)
+ A = npy.repeat(A[:,:,npy.newaxis], 4, 2)
A[:,:,3] = 255
else:
- if typecode(A) != UInt8:
- A = (255*A).astype(UInt8)
+ if A.dtype != npy.uint8:
+ A = (255*A).astype(npy.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]), npy.uint8)
B[:,:,0:3] = A
B[:,:,3] = 255
A = B
@@ -428,7 +429,7 @@
inside = xdata>=xmin and xdata<=xmax and ydata>=ymin and ydata<=ymax
else:
inside = False
-
+
return inside,{}
def get_size(self):
@@ -441,7 +442,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):
@@ -477,7 +478,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 +505,6 @@
raise RuntimeError('Unknown image mode')
x_str = im.tostring('raw',im.mode,0,-1)
- x = numerix.fromstring(x_str,numerix.UInt8)
+ x = npy.fromstring(x_str,npy.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-20 15:17:37 UTC (rev 3591)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2007-07-20 15:42:09 UTC (rev 3592)
@@ -22,15 +22,15 @@
"""
from __future__ import division
import sys, warnings
-from numerix import array, ones, Float
+import numpy as npy
from matplotlib import verbose, rcParams
from artist import Artist
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
@@ -199,9 +199,9 @@
# based on it's bbox
left, top = 0.5, 0.5
if self.numpoints == 1:
- self._xdata = array([left + self.handlelen*0.5])
+ self._xdata = npy.array([left + self.handlelen*0.5])
else:
- self._xdata = linspace(left, left + self.han...
[truncated message content] |