integrate does not work anymore

Discussion in 'Python' started by Doerte, Mar 25, 2009.

  1. Doerte

    Doerte Guest

    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
    Doerte, Mar 25, 2009
    #1
    1. Advertising

  2. Doerte wrote:
    > 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

    --
    Sator Laser GmbH
    Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
    Ulrich Eckhardt, Mar 25, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. claude
    Replies:
    3
    Views:
    2,271
    Andrew Thompson
    Jan 27, 2004
  2. Eric Lilja
    Replies:
    4
    Views:
    464
  3. Bobby Edward
    Replies:
    1
    Views:
    611
    Mike Lopilato
    Oct 10, 2009
  4. Junkone
    Replies:
    2
    Views:
    136
    Iñaki Baz Castillo
    Aug 14, 2008
  5. Forex Forex
    Replies:
    3
    Views:
    97
    Forex Forex
    Nov 7, 2008
Loading...

Share This Page