Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lambdify returns TypeError: _lambdifygenerated() missing 1 required positional argument: 'k'

Tags:

I need to solve an equation numerically (solution must depend on k∈⟨0,1)). Every time I use a function that returns expression or use lambda to define function it returns similar error. Now I tried using lambdify to translate a SymPy expression into an equivalent numeric function, but same error is returned.

from scipy import *
import sympy as sym
init_printing()

x,k=symbols("x,k")
f=(sym.log(x)/sym.log(k))**k-x**(1/sym.atanh(k))

a=lambdify([x,k], f, "scipy")
(a([0,1]))
TypeError                                 Traceback (most recent call last)
<ipython-input-29-04519472dd5e> in <module>
      7 
      8 a=lambdify([x,k], f, "scipy")
----> 9 print(a([0,1]))

TypeError: _lambdifygenerated() missing 1 required positional argument: 'k'

like image 330
Quasar Avatar asked Jan 07 '20 17:01

Quasar


1 Answers

Call with a(0,1), not a([0,1]). If you want to use a list as the argument, you can use a nested variable list like this: a=lambdify([(x,k)], f, "scipy").

like image 123
Hurried-Helpful Avatar answered Oct 12 '22 11:10

Hurried-Helpful