Conditional branches of expressions #125
MilesCranmer
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here's how you can search for conditional branches of expressions (including if statements) using PySR:
The
::Twhere {T}is just Julia notation for templating a function for arbitrary type. It's not normally required, but I want to declare the type of the0there as the same type, so I used it.Using the
Piecewisefunction, SymPy should correctly convert the output of this to an executable function when calling lambdify.A simpler version which is also valid:
"cond(x, y) = x >= 0 ? y : 0*y". Though this might be slower due to the type conversions.Beta Was this translation helpful? Give feedback.
All reactions