Skip to content

Commit

Permalink
Fix pylint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
heplesser committed May 23, 2024
1 parent 4b63447 commit 6aad9d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pynest/nest/raster_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ def extract_events(data, time=None, sel=None):
"""
val = []

t_min, t_max = 0, float("inf")
if time:
t_max = time[-1]
if len(time) > 1:
t_min = time[0]
else:
t_min = 0

for v in data:
t = v[1]
node_id = v[0]
if time and (t < t_min or t >= t_max):
if not (t_min <= t < t_max):
continue
if not sel or node_id in sel:
val.append(v)
Expand Down Expand Up @@ -131,6 +130,7 @@ def from_file_pandas(fname, **kwargs):
"""Use pandas."""
data = None
for f in fname:
# pylint: disable=possibly-used-before-assignment
dataFrame = pandas.read_table(f, header=2, skipinitialspace=True)
newdata = dataFrame.values

Expand Down
3 changes: 3 additions & 0 deletions testsuite/pytests/connect_test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,9 @@ def get_degrees(fan, pop1, pop2):
degrees = np.sum(M, axis=1)
elif fan == "out":
degrees = np.sum(M, axis=0)
else:
raise ValueError(f"fan must be 'in' or 'out', got '{fan}'.")

return degrees


Expand Down
7 changes: 7 additions & 0 deletions testsuite/pytests/test_clopath_synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def test_SynapseDepressionFacilitation(self):
"tau_u_bar_plus": 114.0,
"delay_u_bars": 5.0,
}
else:
raise ValueError(f"Unsupported neuron model '{nrn_model}'")

syn_weights = []
# Loop over pairs of spike trains
for s_t_pre, s_t_post in zip(spike_times_pre, spike_times_post):
Expand All @@ -146,6 +149,8 @@ def test_SynapseDepressionFacilitation(self):
conn_weight = 80.0
elif nrn_model == "hh_psc_alpha_clopath":
conn_weight = 2000.0
else:
raise ValueError(f"Unsupported neuron model '{nrn_model}'")

spike_gen_post = nest.Create("spike_generator", 1, {"spike_times": s_t_post})

Expand Down Expand Up @@ -176,6 +181,8 @@ def test_SynapseDepressionFacilitation(self):
correct_weights = [57.82638722, 72.16730112, 149.43359357, 103.30408341, 124.03640668, 157.02882555]
elif nrn_model == "hh_psc_alpha_clopath":
correct_weights = [70.14343863, 99.49206222, 178.1028757, 119.63314118, 167.37750688, 178.83111685]
else:
raise ValueError(f"Unsupported neuron model '{nrn_model}'")

self.assertTrue(np.allclose(syn_weights, correct_weights, rtol=1e-7))

Expand Down
3 changes: 3 additions & 0 deletions testsuite/pytests/test_connect_tripartite_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def get_degrees(fan, pop1, pop2):
degrees = np.sum(M, axis=1)
elif fan == "out":
degrees = np.sum(M, axis=0)
else:
raise ValueError(f"fan must be 'in' or 'out', got '{fan}'.")

return degrees


Expand Down
22 changes: 10 additions & 12 deletions testsuite/pytests/test_stdp_nn_synapses.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,16 @@ def reproduce_weight_drift(self, _pre_spikes, _post_spikes, _initial_weight):
t = _pre_spikes[pre_spikes_forced_to_grid.index(time_in_simulation_steps)]

# Evaluating the depression rule.
if self.synapse_parameters["synapse_model"] == "stdp_nn_restr_synapse":
current_nearest_neighbour_pair_is_suitable = t_previous_post > t_previous_pre
# If '<', t_previous_post has already been paired
# with t_previous_pre, thus due to the restricted
# pairing scheme we do not account it.
if (
self.synapse_parameters["synapse_model"] == "stdp_nn_symm_synapse"
or self.synapse_parameters["synapse_model"] == "stdp_nn_pre_centered_synapse"
):
# The current pre-spike is simply paired with the
# nearest post-spike.
current_nearest_neighbour_pair_is_suitable = True
# For the first two rules below, simply pair current pre-spike with nearest post-spike.
# For "nn_restr" and `post < pre`, the previous post has already been paired, thus due
# to the restricted pairing scheme, we do not account it.
current_nearest_neighbour_pair_is_suitable = self.synapse_parameters["synapse_model"] in [
"stdp_nn_symm_synapse",
"stdp_nn_pre_centered_synapse",
] or (
self.synapse_parameters["synapse_model"] == "stdp_nn_restr_synapse"
and t_previous_post > t_previous_pre
)

if current_nearest_neighbour_pair_is_suitable and t_previous_post != -1:
# Otherwise, if == -1, there have been
Expand Down

0 comments on commit 6aad9d4

Please sign in to comment.