Closed jnjnnjzch closed 1 year ago
The example code of function brain.math.ifelse() seems not work. The function is located at brainpy/_src/math/object_transform/controls.py The example of doc doesn't work either, which is located at https://brainpy.readthedocs.io/en/latest/apis/auto/generated/brainpy.math.ifelse.html
import brainpy.math as bm def f(a): return bm.ifelse(conditions=[a > 10, a > 5, a > 2, a > 0], branches=[lambda _: 1, lambda _: 2, lambda _: 3, lambda _: 4, lambda _: 5]) f(1)
To let it work, one way is to delete "_".
import brainpy.math as bm def f(a): return bm.ifelse(conditions=[a > 10, a > 5, a > 2, a > 0], branches=[lambda : 1, lambda : 2, lambda : 3, lambda : 4, lambda : 5]) f(1)
Another way is to directly not use lambda expression
import brainpy.math as bm def f(a): return bm.ifelse(conditions=[a > 10, a > 5, a > 2, a > 0], branches=[1, 2, 3, 4, 5]) f(1)
So many thanks for your report. That is indeed a bug. We should fix the bug in the doc.
The example code of function brain.math.ifelse() seems not work. The function is located at brainpy/_src/math/object_transform/controls.py The example of doc doesn't work either, which is located at https://brainpy.readthedocs.io/en/latest/apis/auto/generated/brainpy.math.ifelse.html
To let it work, one way is to delete "_".
Another way is to directly not use lambda expression