Skip to content
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

Much easier way to write control flows #184

Closed
2 tasks done
chaoming0625 opened this issue Apr 25, 2022 · 1 comment
Closed
2 tasks done

Much easier way to write control flows #184

chaoming0625 opened this issue Apr 25, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@chaoming0625
Copy link
Collaborator

chaoming0625 commented Apr 25, 2022

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=...)
@chaoming0625 chaoming0625 added the enhancement New feature or request label Apr 25, 2022
@chaoming0625 chaoming0625 changed the title More easy way to write control flows Much easier way to write control flows Apr 25, 2022
@chaoming0625
Copy link
Collaborator Author

#189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants