Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa2300e

Browse files
committed
completed numpification of most trivial cases
svn path=/trunk/matplotlib/; revision=3577
1 parent 06759b0 commit fa2300e

26 files changed

Lines changed: 148 additions & 185 deletions

CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
2007-07-19 converted non-numpy relicts troughout the code
1+
2007-07-19 completed numpification of most trivial cases - NN
2+
3+
2007-07-19 converted non-numpy relicts troughout the code - NN
24

35
2007-07-19 replaced the Python code in numerix/ by a minimal wrapper around
46
numpy that explicitly mentions all symbols that need to be

lib/matplotlib/art3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from colors import Normalize
1313
from cm import jet
1414

15-
import numerix as nx
15+
import numpy as npy
1616
import proj3d
1717

1818
class Wrap2D:
@@ -254,8 +254,8 @@ def get_vector(self):
254254
segis.append((si,ei))
255255
si = ei
256256
xs,ys,zs = zip(*points)
257-
ones = nx.ones(len(xs))
258-
self.vec = nx.array([xs,ys,zs,ones])
257+
ones = npy.ones(len(xs))
258+
self.vec = npy.array([xs,ys,zs,ones])
259259
self.segis = segis
260260

261261
def draw3d(self, renderer):

lib/matplotlib/axes3d.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from transforms import unit_bbox
1818

1919
import figure
20-
import numerix as nx
20+
import numpy as npy
2121
from colors import Normalize
2222

2323
import art3d
@@ -122,8 +122,8 @@ def create_axes(self):
122122
self.zz_dataLim.intervalx, self)
123123

124124
def unit_cube(self,vals=None):
125-
minx,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims()
126-
xs,ys,zs = ([minx,maxx,maxx,minx,minx,maxx,maxx,minx],
125+
minpy,maxx,miny,maxy,minz,maxz = vals or self.get_w_lims()
126+
xs,ys,zs = ([minpy,maxx,maxx,minpy,minpy,maxx,maxx,minpy],
127127
[miny,miny,maxy,maxy,miny,miny,maxy,maxy],
128128
[minz,minz,minz,minz,maxz,maxz,maxz,maxz])
129129
return zip(xs,ys,zs)
@@ -186,7 +186,7 @@ def update_datalim_numerix(self, x, y):
186186
pass
187187

188188
def auto_scale_xyz(self, X,Y,Z=None,had_data=None):
189-
x,y,z = map(nx.asarray, (X,Y,Z))
189+
x,y,z = map(npy.asarray, (X,Y,Z))
190190
try:
191191
x,y = X.flat,Y.flat
192192
if Z is not None:
@@ -216,10 +216,10 @@ def autoscale_view(self, scalex=True, scaley=True, scalez=True):
216216
self.set_w_zlim(locator.autoscale())
217217

218218
def get_w_lims(self):
219-
minx,maxx = self.get_w_xlim()
219+
minpy,maxx = self.get_w_xlim()
220220
miny,maxy = self.get_w_ylim()
221221
minz,maxz = self.get_w_zlim()
222-
return minx,maxx,miny,maxy,minz,maxz
222+
return minpy,maxx,miny,maxy,minz,maxz
223223

224224
def set_w_zlim(self, *args, **kwargs):
225225
gl,self.get_xlim = self.get_xlim,self.get_w_zlim
@@ -257,7 +257,7 @@ def get_w_ylim(self):
257257
def pany(self, numsteps):
258258
print 'numsteps', numsteps
259259

260-
def panx(self, numsteps):
260+
def panpy(self, numsteps):
261261
print 'numsteps', numsteps
262262

263263
def view_init(self, elev, azim):
@@ -276,7 +276,7 @@ def get_proj(self):
276276
point.
277277
278278
"""
279-
relev,razim = nx.pi * self.elev/180, nx.pi * self.azim/180
279+
relev,razim = npy.pi * self.elev/180, npy.pi * self.azim/180
280280

281281
xmin,xmax = self.get_w_xlim()
282282
ymin,ymax = self.get_w_ylim()
@@ -288,29 +288,29 @@ def get_proj(self):
288288
zmin,zmax)
289289

290290
# look into the middle of the new coordinates
291-
R = nx.array([0.5,0.5,0.5])
291+
R = npy.array([0.5,0.5,0.5])
292292
#
293-
xp = R[0] + nx.cos(razim)*nx.cos(relev)*self.dist
294-
yp = R[1] + nx.sin(razim)*nx.cos(relev)*self.dist
295-
zp = R[2] + nx.sin(relev)*self.dist
293+
xp = R[0] + npy.cos(razim)*npy.cos(relev)*self.dist
294+
yp = R[1] + npy.sin(razim)*npy.cos(relev)*self.dist
295+
zp = R[2] + npy.sin(relev)*self.dist
296296

297-
E = nx.array((xp, yp, zp))
297+
E = npy.array((xp, yp, zp))
298298
#
299299
self.eye = E
300300
self.vvec = R - E
301301
self.vvec = self.vvec / proj3d.mod(self.vvec)
302302

303-
if abs(relev) > nx.pi/2:
303+
if abs(relev) > npy.pi/2:
304304
# upside down
305-
V = nx.array((0,0,-1))
305+
V = npy.array((0,0,-1))
306306
else:
307-
V = nx.array((0,0,1))
307+
V = npy.array((0,0,1))
308308
zfront,zback = -self.dist,self.dist
309309

310310
viewM = proj3d.view_transformation(E,R,V)
311311
perspM = proj3d.persp_transformation(zfront,zback)
312-
M0 = nx.dot(viewM,worldM)
313-
M = nx.dot(perspM,M0)
312+
M0 = npy.dot(viewM,worldM)
313+
M = npy.dot(perspM,M0)
314314
return M
315315

316316
def mouse_init(self):
@@ -383,8 +383,8 @@ def format_coord(self, xd, yd):
383383
# scale the z value to match
384384
x0,y0,z0 = p0
385385
x1,y1,z1 = p1
386-
d0 = nx.hypot(x0-xd,y0-yd)
387-
d1 = nx.hypot(x1-xd,y1-yd)
386+
d0 = npy.hypot(x0-xd,y0-yd)
387+
d1 = npy.hypot(x1-xd,y1-yd)
388388
dt = d0+d1
389389
z = d1/dt * z0 + d0/dt * z1
390390
#print 'mid', edgei, d0, d1, z0, z1, z
@@ -435,12 +435,12 @@ def on_move(self, event):
435435
elif self.button_pressed == 3:
436436
# zoom view
437437
# hmmm..this needs some help from clipping....
438-
minx,maxx,miny,maxy,minz,maxz = self.get_w_lims()
438+
minpy,maxx,miny,maxy,minz,maxz = self.get_w_lims()
439439
df = 1-((h - dy)/h)
440-
dx = (maxx-minx)*df
440+
dx = (maxx-minpy)*df
441441
dy = (maxy-miny)*df
442442
dz = (maxz-minz)*df
443-
self.set_w_xlim(minx-dx,maxx+dx)
443+
self.set_w_xlim(minpy-dx,maxx+dx)
444444
self.set_w_ylim(miny-dy,maxy+dy)
445445
self.set_w_zlim(minz-dz,maxz+dz)
446446
self.get_proj()
@@ -504,14 +504,14 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
504504
had_data = self.has_data()
505505

506506
rows, cols = Z.shape
507-
tX,tY,tZ = nx.transpose(X), nx.transpose(Y), nx.transpose(Z)
507+
tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
508508
rstride = cbook.popd(kwargs, 'rstride', 10)
509509
cstride = cbook.popd(kwargs, 'cstride', 10)
510510
#
511511
polys = []
512512
boxes = []
513-
for rs in nx.arange(0,rows,rstride):
514-
for cs in nx.arange(0,cols,cstride):
513+
for rs in npy.arange(0,rows,rstride):
514+
for cs in npy.arange(0,cols,cstride):
515515
ps = []
516516
corners = []
517517
for a,ta in [(X,tX),(Y,tY),(Z,tZ)]:
@@ -522,9 +522,9 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
522522
zright = ta[cs][rs:min(rows-1,rs+rstride):]
523523
zright = zright[::-1]
524524
corners.append([ztop[0],ztop[-1],zbase[0],zbase[-1]])
525-
z = nx.concatenate((ztop,zleft,zbase,zright))
525+
z = npy.concatenate((ztop,zleft,zbase,zright))
526526
ps.append(z)
527-
boxes.append(map(nx.array,zip(*corners)))
527+
boxes.append(map(npy.array,zip(*corners)))
528528
polys.append(zip(*ps))
529529
#
530530
lines = []
@@ -533,10 +533,10 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
533533
n = proj3d.cross(box[0]-box[1],
534534
box[0]-box[2])
535535
n = n/proj3d.mod(n)*5
536-
shade.append(nx.dot(n,[-1,-1,0.5]))
536+
shade.append(npy.dot(n,[-1,-1,0.5]))
537537
lines.append((box[0],n+box[0]))
538538
#
539-
color = nx.array([0,0,1,1])
539+
color = npy.array([0,0,1,1])
540540
norm = Normalize(min(shade),max(shade))
541541
colors = [color * (0.5+norm(v)*0.5) for v in shade]
542542
for c in colors: c[3] = 1
@@ -554,7 +554,7 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
554554
had_data = self.has_data()
555555
rows,cols = Z.shape
556556

557-
tX,tY,tZ = nx.transpose(X), nx.transpose(Y), nx.transpose(Z)
557+
tX,tY,tZ = npy.transpose(X), npy.transpose(Y), npy.transpose(Z)
558558

559559
rii = [i for i in range(0,rows,rstride)]+[rows-1]
560560
cii = [i for i in range(0,cols,cstride)]+[cols-1]
@@ -718,7 +718,7 @@ def test_scatter():
718718

719719
def get_test_data(delta=0.05):
720720
from mlab import meshgrid, bivariate_normal
721-
x = y = nx.arange(-3.0, 3.0, delta)
721+
x = y = npy.arange(-3.0, 3.0, delta)
722722
X, Y = meshgrid(x,y)
723723

724724
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
@@ -764,8 +764,8 @@ def test_contour():
764764

765765
def test_plot():
766766
ax = Axes3D()
767-
xs = nx.arange(0,4*nx.pi+0.1,0.1)
768-
ys = nx.sin(xs)
767+
xs = npy.arange(0,4*npy.pi+0.1,0.1)
768+
ys = npy.sin(xs)
769769
ax.plot(xs,ys, label='zl')
770770
ax.plot(xs,ys+max(xs),label='zh')
771771
ax.plot(xs,ys,dir='x', label='xl')
@@ -785,7 +785,7 @@ def test_polys():
785785
cc = lambda arg: colorConverter.to_rgba(arg, alpha=0.6)
786786

787787
ax = Axes3D()
788-
xs = nx.arange(0,10,0.4)
788+
xs = npy.arange(0,10,0.4)
789789
verts = []
790790
zs = [0.0,1.0,2.0,3.0]
791791
for z in zs:
@@ -817,7 +817,7 @@ def test_bar2D():
817817
ax = Axes3D()
818818

819819
for c,z in zip(['r','g','b','y'],[30,20,10,0]):
820-
xs = nx.arange(20)
820+
xs = npy.arange(20)
821821
ys = [random.random() for x in xs]
822822
ax.bar(xs,ys,z=z,dir='y',color=c)
823823
#ax.plot(xs,ys)

lib/matplotlib/axis.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
import re
88
import sys
99

10-
from numerix import arange, array, asarray, ones, zeros, \
10+
from numpy import arange, array, asarray, ones, zeros, \
1111
nonzero, take, log10, logical_and, \
12-
dot, sin, cos, tan, pi, sqrt
12+
dot, sin, cos, tan, pi, sqrt, linspace
1313

1414
from artist import Artist, setp
1515
from cbook import enumerate, silent_list, popall, CallbackRegistry
1616
from lines import Line2D, TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN
17-
from mlab import linspace
1817
from matplotlib import rcParams
1918
from patches import bbox_artist
2019
from ticker import NullFormatter, FixedFormatter, ScalarFormatter, LogFormatter

lib/matplotlib/axis3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import art3d
1414
import proj3d
1515

16-
from numerix import sin, cos, pi, cumsum, dot, asarray, array, \
16+
from numpy import sin, cos, pi, cumsum, dot, asarray, array, \
1717
where, nonzero, equal, sqrt
1818

1919
def norm_angle(a):

lib/matplotlib/backend_bases.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def new_gc(self):
437437
def points_to_pixels(self, points):
438438
"""
439439
Convert points to display units
440-
points - a float or a numerix array of float
440+
points - a float or a numpy array of float
441441
return points converted to pixels
442442
443443
You need to override this function (unless your backend doesn't have a
@@ -891,24 +891,24 @@ def hilite(self, ev):
891891
#print "leaving:",[str(a) for a in leave]
892892
# On leave restore the captured colour
893893
for a in leave:
894-
if hasattr(a,'get_color'):
894+
if hasattr(a,'get_color'):
895895
a.set_color(self._active[a])
896-
elif hasattr(a,'get_edgecolor'):
896+
elif hasattr(a,'get_edgecolor'):
897897
a.set_edgecolor(self._active[a][0])
898898
a.set_facecolor(self._active[a][1])
899899
del self._active[a]
900900
# On enter, capture the color and repaint the artist
901-
# with the highlight colour. Capturing colour has to
902-
# be done first in case the parent recolouring affects
901+
# with the highlight colour. Capturing colour has to
902+
# be done first in case the parent recolouring affects
903903
# the child.
904904
for a in enter:
905-
if hasattr(a,'get_color'):
905+
if hasattr(a,'get_color'):
906906
self._active[a] = a.get_color()
907907
elif hasattr(a,'get_edgecolor'):
908908
self._active[a] = (a.get_edgecolor(),a.get_facecolor())
909909
else: self._active[a] = None
910910
for a in enter:
911-
if hasattr(a,'get_color'):
911+
if hasattr(a,'get_color'):
912912
a.set_color('red')
913913
elif hasattr(a,'get_edgecolor'):
914914
a.set_edgecolor('red')

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
import os, sys
7474
import matplotlib
7575
from matplotlib import verbose, rcParams
76-
from numpy import array, zeros, transpose
76+
from numpy import array, zeros, transpose, fliplr
7777
from matplotlib._image import fromarray
7878
from matplotlib._pylab_helpers import Gcf
7979
from matplotlib.backend_bases import RendererBase,\
@@ -85,7 +85,6 @@
8585
from matplotlib.ft2font import FT2Font
8686
from matplotlib.mathtext import math_parse_s_ft2font
8787
from matplotlib.transforms import lbwh_to_bbox
88-
from matplotlib.numerix.mlab import fliplr
8988

9089
from _backend_agg import RendererAgg as _RendererAgg
9190

lib/matplotlib/backends/backend_fltkagg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import os.path
1919

20+
from numpy import asarray
21+
2022
import matplotlib
2123

2224
from matplotlib import rcParams, verbose
@@ -26,7 +28,6 @@
2628
NavigationToolbar2, cursors
2729
from matplotlib.figure import Figure
2830
from matplotlib._pylab_helpers import Gcf
29-
from matplotlib.numerix import asarray
3031
import matplotlib.windowing as windowing
3132
from matplotlib.widgets import SubplotTool
3233

lib/matplotlib/backends/backend_gd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
sys.exit()
1313

1414

15+
from numpy import ones, array, int16, asarray
1516

1617
from matplotlib.backend_bases import RendererBase, \
1718
GraphicsContextBase, FigureManagerBase, FigureCanvasBase
@@ -22,7 +23,6 @@
2223
from matplotlib.figure import Figure
2324
from matplotlib.transforms import Bbox
2425
from matplotlib.font_manager import fontManager
25-
from matplotlib.numerix import ones, array, nx, asarray
2626
# support old font names
2727
if (os.environ.has_key('GDFONTPATH') and not
2828
os.environ.has_key('TTFPATH')):
@@ -115,8 +115,8 @@ def draw_lines(self, gc, x, y):
115115
point in x, y
116116
"""
117117

118-
x = x.astype(nx.int16)
119-
y = self.height*ones(y.shape, nx.int16) - y.astype(nx.int16)
118+
x = x.astype(int16)
119+
y = self.height*ones(y.shape, int16) - y.astype(int16)
120120
style = self._set_gd_style(gc)
121121
self.im.lines( zip(x,y), style)
122122
self.flush_clip()

0 commit comments

Comments
 (0)