-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create a BasicMathNode that can evaluate expressions given as a string #185
Conversation
Click here to view all benchmarks. |
Co-authored-by: Melissa DeLucchi <[email protected]>
from tdastro.base_models import FunctionNode | ||
|
||
|
||
class BasicMathNode(FunctionNode): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally irrelevant to this PR, but as a grad student I've definitely wished for this sort of conversion as a callable library, especially if C stdlib was one of the "basic math" languages that could be converted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general usability issues, most of them are not related to this PR and can be discussed separately:
BasicMathNode
doesn't have a string representationGraphState
doesn't have a string representation and iteration over it fails, e.g.list(BasicMathNode("a", a=1, node_label="node").sample_parameters())
BasicMathNode("a", a=1).sample_parameters()
cannot be used with[]
syntax becausenode_label is None
. However I still could useextract_parameters
- Math exceptions like
1/0
orlog(-1)
are hard to track - It is not clear how I can a) jit-compile with
jax
and b) use a random number node.
Thanks @hombit, I filed some issues for some of those:
|
Creates a new
BasicMathNode
that will evaluate basic math functions given as a string. Performs a bunch of checks to prevent arbitrary code execution. Also translates math functions into the correct backend (math
,numpy
, orjax
).This will allow us to write functions nodes (for basic math) as: