diff --git a/src/neat/trees/phystree.py b/src/neat/trees/phystree.py index 37b23ca5..135ec870 100755 --- a/src/neat/trees/phystree.py +++ b/src/neat/trees/phystree.py @@ -557,6 +557,7 @@ def set_physiology(self, c_m_distr, r_a_distr, g_s_distr=None, node_arg=None): if g_s_distr is not None else 0.0 ) + assert int(np.sign(g_s)) != -1 node.set_physiology(c_m, r_a, g_s) @comptree_removal_decorator @@ -588,6 +589,7 @@ def set_leak_current(self, g_l_distr, e_l_distr, node_arg=None): for node in self.convert_node_arg_to_nodes(node_arg): g_l = self._distr2Float(g_l_distr, node, argname="`g_l_distr`") e_l = self._distr2Float(e_l_distr, node, argname="`e_l_distr`") + assert int(np.sign(g_l)) != -1 node._add_current("L", g_l, e_l) @comptree_removal_decorator @@ -631,6 +633,7 @@ def add_channel_current(self, channel, g_max_distr, e_rev_distr, node_arg=None): for node in self.convert_node_arg_to_nodes(node_arg): g_max = self._distr2Float(g_max_distr, node, argname="`g_max_distr`") e_rev = self._distr2Float(e_rev_distr, node, argname="`e_rev_distr`") + assert int(np.sign(g_max)) != -1 node._add_current(channel_name, g_max, e_rev) def get_channels_in_tree(self): diff --git a/tests/test_phystree.py b/tests/test_phystree.py index 7bc48e50..deb3f6ba 100755 --- a/tests/test_phystree.py +++ b/tests/test_phystree.py @@ -204,6 +204,9 @@ def test_physiology_setting(self): # as wrong type with pytest.raises(TypeError): self.tree.set_leak_current([]) + # wrong sign + with pytest.raises(AssertionError): + self.tree.set_leak_current(e_l, g_l) # gmax as potential as float e_rev = 100.0 @@ -233,6 +236,9 @@ def test_physiology_setting(self): # check if error is thrown if an ionchannel is not give with pytest.raises(IOError): self.tree.add_channel_current("test_channel2", g_max, e_rev) + # check if error is thrown if an ionchannel is not give + with pytest.raises(AssertionError): + self.tree.add_channel_current(channel, -10.0, e_rev) def test_membrane_functions(self): self.load_tree()