AttributeError: 'function' object has no attribute 'quad' in Python

from scipy import linalg
from scipy.integrate import quad
import numpy as np


a = integrate.quad(lambda x: x**2, 0, 4.5)
print(a)

AttributeError                            Traceback (most recent call last)
<ipython-input-132-c7f6592004af> in <module>()
      2 from scipy.integrate import quad
      3 import numpy as np
----> 4 a = integrate.quad(lambda x: x**2, 0, 4.5)
      5 
      6 

AttributeError: 'function' object has no attribute 'quad'

I have no idea what happen, anyone could help me? Thanks!

Answers


The code imports quad; You don't need to qualify it:

from scipy.integrate import quad  # <----
....

a = quad(lambda x: x**2, 0, 4.5)

Need Your Help

Preventing a setter being called twice in a Spring bean?

java spring

I am being asked by a colleague to move our setters to constructors, in our Spring beans, since "the setter exposes a private variable that could be potentially changed after the construction phase...

Deleting entity with child relationships using .Net Entity Framework problem

.net asp.net asp.net-mvc entity-framework orm

My God, EF is so frustrating. I can't seem to be able to get my head around what I need to do so I can delete an object. I seem to be able to remove the object but not the related child objects. Can