From 06ab8a681764afca353eb5ad9301568bd8c2e08d Mon Sep 17 00:00:00 2001 From: Mushkan Rana Date: Sat, 28 Mar 2026 10:08:49 +0000 Subject: [PATCH 1/3] test:add cython synapses regression coverage for #1769 --- brian2/tests/test_synapses.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/brian2/tests/test_synapses.py b/brian2/tests/test_synapses.py index cabfaf94d..41d146db4 100644 --- a/brian2/tests/test_synapses.py +++ b/brian2/tests/test_synapses.py @@ -3730,6 +3730,34 @@ def test_setting_from_weight_matrix(): assert all(syn.w[i, j] == weights[i, j]) +def test_synapses_cython_codegen_target_runs(): + from brian2 import prefs, start_scope, run, ms, NeuronGroup, Synapses + + old_target = prefs.codegen.target + prefs.codegen.target = "cython" + + try: + start_scope() + + G = NeuronGroup( + 2, + "v : 1", + threshold="v > 1", + reset="v = 0", + ) + + S = Synapses(G, G, on_pre="v_post += 1") + S.connect(i=0, j=1) + + G.v = [2, 0] + run(1 * ms) + + assert G.v[0] == pytest.approx(0) + assert G.v[1] == pytest.approx(1) + finally: + prefs.codegen.target = old_target + + if __name__ == "__main__": SANITY_CHECK_PERMUTATION_ANALYSIS_EXAMPLE = True # prefs.codegen.target = 'numpy' @@ -3832,5 +3860,6 @@ def test_setting_from_weight_matrix(): test_synaptic_subgroups() test_incorrect_connect_N_incoming_outgoing() test_setting_from_weight_matrix() + test_synapses_cython_codegen_target_runs() print("Tests took", time.time() - start) From 9d3cc382a1e9d024512f4fc8805ab2605bd3c5f3 Mon Sep 17 00:00:00 2001 From: Mushkan Rana Date: Sun, 29 Mar 2026 10:05:53 +0530 Subject: [PATCH 2/3] test: remove direct test call from synapses regression test --- brian2/tests/test_synapses.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/brian2/tests/test_synapses.py b/brian2/tests/test_synapses.py index 41d146db4..397fa1806 100644 --- a/brian2/tests/test_synapses.py +++ b/brian2/tests/test_synapses.py @@ -3731,7 +3731,6 @@ def test_setting_from_weight_matrix(): def test_synapses_cython_codegen_target_runs(): - from brian2 import prefs, start_scope, run, ms, NeuronGroup, Synapses old_target = prefs.codegen.target prefs.codegen.target = "cython" @@ -3752,8 +3751,7 @@ def test_synapses_cython_codegen_target_runs(): G.v = [2, 0] run(1 * ms) - assert G.v[0] == pytest.approx(0) - assert G.v[1] == pytest.approx(1) + assert_allclose(G.v[:], [0, 1]) finally: prefs.codegen.target = old_target @@ -3860,6 +3858,6 @@ def test_synapses_cython_codegen_target_runs(): test_synaptic_subgroups() test_incorrect_connect_N_incoming_outgoing() test_setting_from_weight_matrix() - test_synapses_cython_codegen_target_runs() + print("Tests took", time.time() - start) From 196928e5908211807f5e9f56ba83e83111626e61 Mon Sep 17 00:00:00 2001 From: Mushkan Rana Date: Wed, 1 Apr 2026 11:06:40 +0530 Subject: [PATCH 3/3] Fix:improved serialization test/minor fix --- 0.5 | 0 1 | 0 1.5 | 0 2 | 0 brian2/tests/test_synapses.py | 2 -- findstr | 0 q | 0 7 files changed, 2 deletions(-) create mode 100644 0.5 create mode 100644 1 create mode 100644 1.5 create mode 100644 2 create mode 100644 findstr create mode 100644 q diff --git a/0.5 b/0.5 new file mode 100644 index 000000000..e69de29bb diff --git a/1 b/1 new file mode 100644 index 000000000..e69de29bb diff --git a/1.5 b/1.5 new file mode 100644 index 000000000..e69de29bb diff --git a/2 b/2 new file mode 100644 index 000000000..e69de29bb diff --git a/brian2/tests/test_synapses.py b/brian2/tests/test_synapses.py index 397fa1806..c5087fafe 100644 --- a/brian2/tests/test_synapses.py +++ b/brian2/tests/test_synapses.py @@ -3731,7 +3731,6 @@ def test_setting_from_weight_matrix(): def test_synapses_cython_codegen_target_runs(): - old_target = prefs.codegen.target prefs.codegen.target = "cython" @@ -3858,6 +3857,5 @@ def test_synapses_cython_codegen_target_runs(): test_synaptic_subgroups() test_incorrect_connect_N_incoming_outgoing() test_setting_from_weight_matrix() - print("Tests took", time.time() - start) diff --git a/findstr b/findstr new file mode 100644 index 000000000..e69de29bb diff --git a/q b/q new file mode 100644 index 000000000..e69de29bb