Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 964
user133140 Avatar asked Feb 15 '26 11:02

user133140


1 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)
like image 75
falsetru Avatar answered Feb 18 '26 00:02

falsetru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!