-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Parametric printer #23661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parametric printer #23661
Conversation
✅ Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.11. Click here to see the pull request description that was parsed.
|
In your example, I'm trying to understand what the point of doing this is vs. just passing additional arguments to lambdify explicitly. We could have a function that automatically converts numbers in an expression into symbols which you could use before passing it to lambdify (something like that might even already exist). |
I've just checked, and you are correct, the example doesn't work unless The specific use case I had envisioned for the current implementation was as follows: I have dynamically created an expression with some intial values e.g However, I think your suggestion to replace the constants with symbols before inputing to lambdify may be better. As you pointed out, parameter order cannot be enforced in the currently proposed method. Would it be possible to have default values for those symbols that replace the constants using this method though? |
@tttc3 perhaps we could have |
It has been a long time since I last considered the functionality here. I no longer have an immediate use for this functionality, and as no other users have indicated a desire to have such a feature, I think it is same to close this pull. For future readers, the beautifully simple https://github.com/google/sympy2jax effectively provides the functionality described above specifically for JAX expressions. |
References to other Issues or PRs
Provides parametric priting support as originally introduced in #23627
Brief description of what is fixed or changed
Provides parametric support for all children of
AbstractPythonCodePrinter
.Other comments
Responses to the concerns raised in #23627 will be edited in here shortly.
Release Notes
f, params = lambdify([x,y], 1.0*cos(x) + 3.2*y, parametric=True)
would generate a function of the form:PythonCodePrinter(settings={"parametric": True}).doprint(1.0*cos(x) + 3.2*y)
would return"params_0*cos(x)+params_1*y"
.