You seem to be quite a bit confused here.
First off, you are right that you aren't using nargs correctly. nargs
lists the number of arguments a function can take, not its signature.
However, you don't need to define a Function subclass at all. Function
subclasses let you define functions that are unevaluated, which
happens when eval() returns None. But if you never return None from
eval(), there's no point to having a Function subclass. That's the
same as just a normal Python function. Or, more simply, you can just
define an expression, like
mu, m_t, g, r, p_phi, p_r = sp.symbols('mu, m_t, g, r, p_phi, p_r')
h_Kepler_two_body_polar = p_r**2/(2*mu) + p_phi**2/(2*mu*r**2) - g*mu*m_t/r
H_Ktb_polar_lf = sp.lambdify(
[r, p_r, p_phi, (mu, m_t, g)],
h_Kepler_two_body_polar, 'numpy')
It's not necessary to make h_Kepler_two_body_polar into a function
unless you need this level of indirection. But note that you can
always replace symbols with numbers in an expression using subs(), so
strictly speaking this level of indirection should never be needed.
I'm not sure what you had r, p_phi, and p_r defined as, but they need
to be defined as symbols to use them as arguments to lambdify.
lambdify takes a symbolic expression as input and turns it into a
function based on the symbols in the expression (which are specified
by the first argument to lambdify()).
Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sympy+un...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/98a6147c-a081-4432-8168-d0d6b5139247n%40googlegroups.com.