From 7a3219abaf03240321fa474b577f22e595a4cdb2 Mon Sep 17 00:00:00 2001 From: chaoming Date: Tue, 18 Oct 2022 21:25:50 +0800 Subject: [PATCH] fix delay update bug --- brainpy/math/delayvars.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainpy/math/delayvars.py b/brainpy/math/delayvars.py index 339e483d8..29db51461 100644 --- a/brainpy/math/delayvars.py +++ b/brainpy/math/delayvars.py @@ -445,8 +445,8 @@ def update(self, value: Union[float, int, bool, JaxArray, jnp.DeviceArray]): The value of the latest data, used to update this delay variable. """ if self.update_method == ROTATION_UPDATING: + self.idx.value = stop_gradient((self.idx - 1) % self.num_delay_step) self.data[self.idx[0]] = value - self.idx.value = stop_gradient((self.idx + 1) % self.num_delay_step) elif self.update_method == CONCAT_UPDATING: if self.num_delay_step >= 2: