Skip to content

Commit

Permalink
bugfix for set_params() of synapses
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldeistler committed Dec 7, 2023
1 parent 27bcdeb commit 042afb9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jaxley/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def channel_inds(self, ind_of_comps_to_be_set, channel_name: str):

def set_params(self, key, val):
"""Set parameter."""
self._set_params(key, val, self.nodes)
# Alternatively, we could do `assert key not in self.syn_params`.
nodes = self.syn_edges if key in self.syn_params else self.nodes
self._set_params(key, val, nodes)

def _set_params(self, key, val, view):
if key in self.params:
Expand All @@ -252,7 +254,9 @@ def _set_params(self, key, val, view):

def set_states(self, key, val):
"""Set parameters."""
self._set_states(key, val, self.nodes)
# Alternatively, we could do `assert key not in self.syn_states`.
nodes = self.syn_edges if key in self.syn_states else self.nodes
self._set_states(key, val, nodes)

def _set_states(self, key: str, val: float, view):
if key in self.states:
Expand All @@ -270,7 +274,9 @@ def _set_states(self, key: str, val: float, view):

def get_params(self, key: str):
"""Return parameters."""
return self._get_params(key, self.nodes)
# Alternatively, we could do `assert key not in self.syn_params`.
nodes = self.syn_edges if key in self.syn_params else self.nodes
return self._get_params(key, nodes)

def _get_params(self, key: str, view):
if key in self.params:
Expand All @@ -286,7 +292,9 @@ def _get_params(self, key: str, view):

def get_states(self, key: str):
"""Return states."""
return self._get_states(key, self.nodes)
# Alternatively, we could do `assert key not in self.syn_states`.
nodes = self.syn_edges if key in self.syn_states else self.nodes
return self._get_states(key, nodes)

def _get_states(self, key: str, view):
if key in self.states:
Expand Down

0 comments on commit 042afb9

Please sign in to comment.