integrate does not work anymore

D

Doerte

Hello,

some time ago I implemented a Python script, which uses integrate.quad
(...). This was done with Python 2.4 / Win2000.

I'm working with Python 2.5 now, and installed Numpy, Scipy and
Matplotlib. My script and also the test described below do not work
anymore:

from pylab import *
from numpy import *
from scipy import *
from math import *

m = 5
n = 3
f = lambda x:m*x+n
x0 = 2.0
x1 = 6.5
res = integrate.quad(func=f, a=x0, b=x1)
Traceback (most recent call last):
File "<pyshell#15>", line 1, in <module>
res = integrate.quad(func=f, a=x0, b=x1)
NameError: name 'integrate' is not defined


What's wrong here?

Regards,

Doerte
 
U

Ulrich Eckhardt

Doerte said:
from pylab import *
from numpy import *
from scipy import *
from math import *

Don't do this, read the style guide on writing Python code.
res = integrate.quad(func=f, a=x0, b=x1) [...]
NameError: name 'integrate' is not defined

# try this instead
from scipy import integrate


Note that this is also mentioned on the scipy homepage in their script,
though they also commit the sin of namespace pollution by importing with
wildcards.

Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top