Jackson Jin
Jackson Jin

Reputation: 1

Problem with sending argument using dblquad integrator

from scipy import integrate

def g(y,x,a):
    
    return x*y**2 + a

a= 13

integrate.dblquad(g, 0, 2, lambda x: 0, lambda x: x, args=(a))

TypeError Traceback (most recent call last) in 5 a= 13 6 ----> 7 integrate.dblquad(g, 0, 2, lambda x: 0, lambda x: x, args=(a))

~\anaconda3\lib\site-packages\scipy\integrate\quadpack.py in dblquad(func, a, b, gfun, hfun, args, epsabs, epsrel) 599 hfun(args[0]) if callable(hfun) else hfun] 600 --> 601 return nquad(func, [temp_ranges, [a, b]], args=args, 602 opts={"epsabs": epsabs, "epsrel": epsrel}) 603

~\anaconda3\lib\site-packages\scipy\integrate\quadpack.py in nquad(func, ranges, args, opts, full_output) 824 else: 825 opts = [opt if callable(opt) else _OptFunc(opt) for opt in opts] --> 826 return _NQuad(func, ranges, opts, full_output).integrate(*args) 827 828

TypeError: integrate() argument after * must be an iterable, not int

Upvotes: 0

Views: 177

Answers (1)

Nico Schlömer
Nico Schlömer

Reputation: 58861

You could just define a inside (or even outside) of g:

from scipy import integrate

a = 13

def g(y, x):
    return x * y ** 2 + a


integrate.dblquad(g, 0, 2, lambda x: 0, lambda x: x)

(I was never a big of the args argument.)

Upvotes: 0

Related Questions