Skip to content

Commit 1ea4d15

Browse files
committed
updates
1 parent 7bf2fc0 commit 1ea4d15

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

brainpy/_src/dyn/channels/hyperpolarization_activated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def derivative(self, p, t, V):
8989

9090
def reset_state(self, V, batch_size=None):
9191
self.p.value = self.f_p_inf(V)
92-
if batch_size is not None:
92+
if isinstance(batch_size, int):
9393
assert self.p.shape[0] == batch_size
9494

9595
def update(self, V):
@@ -237,7 +237,7 @@ def reset_state(self, V, C_Ca, E_Ca, batch_size=None):
237237
beta = (1 - inf) / tau
238238
self.O.value = alpha / (alpha + alpha * self.k3 * self.P1 / self.k4 + beta)
239239
self.OL.value = self.k3 * self.P1 * self.O / self.k4
240-
if batch_size is not None:
240+
if isinstance(batch_size, int):
241241
assert self.P1.shape[0] == batch_size
242242
assert self.O.shape[0] == batch_size
243243
assert self.OL.shape[0] == batch_size

brainpy/_src/math/object_transform/tests/test_controls.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ def test_for_loop_progress_bar(self):
117117
ys = bm.for_loop(lambda a: a, xs, progress_bar=True)
118118
self.assertTrue(bm.allclose(xs, ys))
119119

120+
def test_for_loop2(self):
121+
class MyClass(bp.DynamicalSystem):
122+
def __init__(self):
123+
super().__init__()
124+
self.a = bm.Variable(bm.zeros(1))
125+
126+
def update(self):
127+
self.a += 1
128+
129+
cls = MyClass()
130+
indices = bm.arange(10)
131+
bm.for_loop(cls.step_run, indices)
132+
self.assertTrue(bm.allclose(cls.a, 10.))
133+
120134

121135
class TestIfElse(unittest.TestCase):
122136
def test1(self):

0 commit comments

Comments
 (0)