[Scipy-svn] r5252 - trunk/doc/source/tutorial
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Dec 14 06:51:27 EST 2008
Author: jarrod.millman
Date: 2008-12-14 05:51:25 -0600 (Sun, 14 Dec 2008)
New Revision: 5252
Modified:
trunk/doc/source/tutorial/interpolate.rst
Log:
remove * import
Modified: trunk/doc/source/tutorial/interpolate.rst
===================================================================
--- trunk/doc/source/tutorial/interpolate.rst 2008-12-14 11:21:11 UTC (rev 5251)
+++ trunk/doc/source/tutorial/interpolate.rst 2008-12-14 11:51:25 UTC (rev 5252)
@@ -28,14 +28,14 @@
.. plot::
- >>> from numpy import *
+ >>> import numpy as np
>>> from scipy import interpolate
- >>> x = arange(0,10)
- >>> y = exp(-x/3.0)
+ >>> x = np.arange(0,10)
+ >>> y = np.exp(-x/3.0)
>>> f = interpolate.interp1d(x, y)
- >>> xnew = arange(0,9,0.1)
+ >>> xnew = np.arange(0,9,0.1)
>>> import matplotlib.pyplot as plt
>>> plt.plot(x,y,'o',xnew,f(xnew),'-')
@@ -91,20 +91,20 @@
.. plot::
- >>> from numpy import *
+ >>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import interpolate
Cubic-spline
- >>> x = arange(0,2*pi+pi/4,2*pi/8)
- >>> y = sin(x)
+ >>> x = np.arange(0,2*np.pi+np.pi/4,2*np.pi/8)
+ >>> y = np.sin(x)
>>> tck = interpolate.splrep(x,y,s=0)
- >>> xnew = arange(0,2*pi,pi/50)
+ >>> xnew = np.arange(0,2*np.pi,np.pi/50)
>>> ynew = interpolate.splev(xnew,tck,der=0)
>>> plt.figure()
- >>> plt.plot(x,y,'x',xnew,ynew,xnew,sin(xnew),x,y,'b')
+ >>> plt.plot(x,y,'x',xnew,ynew,xnew,np.sin(xnew),x,y,'b')
>>> plt.legend(['Linear','Cubic Spline', 'True'])
>>> plt.axis([-0.05,6.33,-1.05,1.05])
>>> plt.title('Cubic-spline interpolation')
@@ -114,7 +114,7 @@
>>> yder = interpolate.splev(xnew,tck,der=1)
>>> plt.figure()
- >>> plt.plot(xnew,yder,xnew,cos(xnew),'--')
+ >>> plt.plot(xnew,yder,xnew,np.cos(xnew),'--')
>>> plt.legend(['Cubic Spline', 'True'])
>>> plt.axis([-0.05,6.33,-1.05,1.05])
>>> plt.title('Derivative estimation from spline')
@@ -123,8 +123,8 @@
Integral of spline
>>> def integ(x,tck,constant=-1):
- >>> x = atleast_1d(x)
- >>> out = zeros(x.shape, dtype=x.dtype)
+ >>> x = np.atleast_1d(x)
+ >>> out = np.zeros(x.shape, dtype=x.dtype)
>>> for n in xrange(len(out)):
>>> out[n] = interpolate.splint(0,x[n],tck)
>>> out += constant
@@ -132,7 +132,7 @@
>>>
>>> yint = integ(xnew,tck)
>>> plt.figure()
- >>> plt.plot(xnew,yint,xnew,-cos(xnew),'--')
+ >>> plt.plot(xnew,yint,xnew,-np.cos(xnew),'--')
>>> plt.legend(['Cubic Spline', 'True'])
>>> plt.axis([-0.05,6.33,-1.05,1.05])
>>> plt.title('Integral estimation from spline')
@@ -145,14 +145,14 @@
Parametric spline
- >>> t = arange(0,1.1,.1)
- >>> x = sin(2*pi*t)
- >>> y = cos(2*pi*t)
+ >>> t = np.arange(0,1.1,.1)
+ >>> x = np.sin(2*np.pi*t)
+ >>> y = np.cos(2*np.pi*t)
>>> tck,u = interpolate.splprep([x,y],s=0)
- >>> unew = arange(0,1.01,0.01)
+ >>> unew = np.arange(0,1.01,0.01)
>>> out = interpolate.splev(unew,tck)
>>> plt.figure()
- >>> plt.plot(x,y,'x',out[0],out[1],sin(2*pi*unew),cos(2*pi*unew),x,y,'b')
+ >>> plt.plot(x,y,'x',out[0],out[1],np.sin(2*np.pi*unew),np.cos(2*np.pi*unew),x,y,'b')
>>> plt.legend(['Linear','Cubic Spline', 'True'])
>>> plt.axis([-1.05,1.05,-1.05,1.05])
>>> plt.title('Spline of parametrically-defined curve')
@@ -203,14 +203,14 @@
.. plot::
- >>> from numpy import *
+ >>> import numpy as np
>>> from scipy import interpolate
>>> import matplotlib.pyplot as plt
Define function over sparse 20x20 grid
- >>> x,y = mgrid[-1:1:20j,-1:1:20j]
- >>> z = (x+y)*exp(-6.0*(x*x+y*y))
+ >>> x,y = np.mgrid[-1:1:20j,-1:1:20j]
+ >>> z = (x+y)*np.exp(-6.0*(x*x+y*y))
>>> plt.figure()
>>> plt.pcolor(x,y,z)
@@ -220,7 +220,7 @@
Interpolate function over new 70x70 grid
- >>> xnew,ynew = mgrid[-1:1:70j,-1:1:70j]
+ >>> xnew,ynew = np.mgrid[-1:1:70j,-1:1:70j]
>>> tck = interpolate.bisplrep(x,y,z,s=0)
>>> znew = interpolate.bisplev(xnew[:,0],ynew[0,:],tck)
More information about the Scipy-svn
mailing list