Skip to content

Commit

Permalink
Fix issue 334 (lava-nc#364)
Browse files Browse the repository at this point in the history
* Update models.py

Changed calculation of wrapped_current.

* Update models.py

fixed linting

* Remove unused  sign_of_curr from models.py

Co-authored-by: Marcus G K Williams <[email protected]>
  • Loading branch information
PhilippPlank and mgkwill committed Sep 23, 2022
1 parent bdd0ccd commit f7e9f25
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lava/proc/lif/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def subthr_dynamics(self, activation_in: np.ndarray):
# Check if value of current is within bounds of 24-bit. Overflows are
# handled by wrapping around modulo 2 ** 23. E.g., (2 ** 23) + k
# becomes k and -(2**23 + k) becomes -k
sign_of_curr = np.sign(decayed_curr)
# when decayed_curr is 0, we don't care about its sign. But np.mod
# needs something non-zero to avoid the divide-by-zero warning
sign_of_curr[sign_of_curr == 0] = 1
wrapped_curr = np.mod(decayed_curr,
sign_of_curr * self.max_uv_val)
wrapped_curr = np.where(decayed_curr > self.max_uv_val,
decayed_curr - 2 * self.max_uv_val,
decayed_curr)
wrapped_curr = np.where(wrapped_curr <= -self.max_uv_val,
decayed_curr + 2 * self.max_uv_val,
wrapped_curr)
self.u[:] = wrapped_curr
# Update voltage
# --------------
Expand Down

0 comments on commit f7e9f25

Please sign in to comment.