From c6507e7555ff4902f56788db6ad7baebe0bedf3b Mon Sep 17 00:00:00 2001 From: Hans Ekkehard Plesser Date: Tue, 27 Feb 2024 14:36:41 +0100 Subject: [PATCH] Fix code to pass R1730 test activated with pylint 3.1 --- pynest/examples/pong/pong.py | 5 +---- testsuite/pytests/test_jonke_synapse.py | 3 +-- testsuite/pytests/test_stdp_nn_synapses.py | 6 ++---- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/pynest/examples/pong/pong.py b/pynest/examples/pong/pong.py index 3f0590ce5d..72e4a37214 100644 --- a/pynest/examples/pong/pong.py +++ b/pynest/examples/pong/pong.py @@ -193,10 +193,7 @@ def propagate_ball_and_paddles(self): """Updates ball and paddle coordinates based on direction and velocity.""" for paddle in [self.r_paddle, self.l_paddle]: paddle.y_pos += paddle.direction * paddle.velocity - if paddle.y_pos < 0: - paddle.y_pos = 0 - if paddle.y_pos > self.y_length: - paddle.y_pos = self.y_length + paddle.y_pos = min(max(0, paddle.y_pos), self.y_length) paddle.update_cell() self.ball.y_pos += self.ball.velocity * self.ball.direction[1] self.ball.x_pos += self.ball.velocity * self.ball.direction[0] diff --git a/testsuite/pytests/test_jonke_synapse.py b/testsuite/pytests/test_jonke_synapse.py index 06a330d324..2b96fc7871 100644 --- a/testsuite/pytests/test_jonke_synapse.py +++ b/testsuite/pytests/test_jonke_synapse.py @@ -225,8 +225,7 @@ def facilitate(self, _delta_t, weight, Kplus): * Kplus * np.exp(_delta_t / self.synapse_constants["tau_plus"]) ) - if weight > self.synapse_constants["Wmax"]: - weight = self.synapse_constants["Wmax"] + weight = min(weight, self.synapse_constants["Wmax"]) return weight def depress(self, _delta_t, weight, Kminus): diff --git a/testsuite/pytests/test_stdp_nn_synapses.py b/testsuite/pytests/test_stdp_nn_synapses.py index 6beb1a55e4..8313bf6ac3 100644 --- a/testsuite/pytests/test_stdp_nn_synapses.py +++ b/testsuite/pytests/test_stdp_nn_synapses.py @@ -260,8 +260,7 @@ def facilitate(self, _delta_t, w): * ((1 - w / self.synapse_parameters["Wmax"]) ** self.synapse_parameters["mu_plus"]) * exp(-1 * _delta_t / self.synapse_parameters["tau_plus"]) ) - if w > self.synapse_parameters["Wmax"]: - w = self.synapse_parameters["Wmax"] + w = min(w, self.synapse_parameters["Wmax"]) return w def depress(self, _delta_t, w): @@ -273,8 +272,7 @@ def depress(self, _delta_t, w): * ((w / self.synapse_parameters["Wmax"]) ** self.synapse_parameters["mu_minus"]) * exp(_delta_t / self.neuron_parameters["tau_minus"]) ) - if w < 0: - w = 0 + w = max(0, w) return w def test_nn_symm_synapse(self):