Closed
Description
Please:
- Check for duplicate requests.
- Describe your goal, and if possible provide a code snippet with a motivating example.
Control flow is not easy in BrainPy because it relies on JAX. I think maybe there is a more conveninet way to write control flows. Like,
import brainpy as bp
import brainpy.math as bm
def f(a)
return bm.ifelse(a > 10., lambda x: 10.,
a > 5 and a <= 10, lambda x: x*2,
lambda x: x+2, x)
Or,
def f(b)
return bm.ifelse(conditions=[a > 10., a > 5 and a <= 10],
functions=[lambda x: 10., lambda x: x*2, lambda x: x+2],
operands=x,
dyn_vars=...)