From 0f3f0280888f4d1610013674b7fa7850c7dd5708 Mon Sep 17 00:00:00 2001 From: Joni Herttuainen Date: Mon, 23 Oct 2023 18:22:45 +0200 Subject: [PATCH] add small tests to test reports use simulation node sets --- tests/data/node_sets_simple.json | 3 +++ tests/test_frame_report.py | 3 +++ tests/test_simulation.py | 1 + tests/test_spike_report.py | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/tests/data/node_sets_simple.json b/tests/data/node_sets_simple.json index 49c44c56..fce05e65 100644 --- a/tests/data/node_sets_simple.json +++ b/tests/data/node_sets_simple.json @@ -1,5 +1,8 @@ { "Layer23": { "layer": [2,3] + }, + "test_nodes": { + "node_id": [0,2] } } diff --git a/tests/test_frame_report.py b/tests/test_frame_report.py index f5ca8b71..90c23a15 100644 --- a/tests/test_frame_report.py +++ b/tests/test_frame_report.py @@ -328,6 +328,9 @@ def _assert_frame_equal(df1, df2): ids = CircuitNodeIds.from_arrays(["default", "default", "default2"], [0, 2, 1]) _assert_frame_equal(self.test_obj.get(group=ids, t_step=t_step), self.df.loc[:, [0, 2]]) + # test that simulation node_set is used + _assert_frame_equal(self.test_obj.get("test_nodes", t_step=t_step), self.df.loc[:, [0, 2]]) + with pytest.raises( BluepySnapError, match="All node IDs must be >= 0 and < 3 for population 'default'" ): diff --git a/tests/test_simulation.py b/tests/test_simulation.py index abb62ad7..b4efb99e 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -61,6 +61,7 @@ def test_all(): expected_content = { **json.loads((TEST_DATA_DIR / "node_sets.json").read_text()), "Layer23": {"layer": [2, 3]}, + "test_nodes": {"node_id": [0, 2]}, } assert simulation.node_sets.content == expected_content diff --git a/tests/test_spike_report.py b/tests/test_spike_report.py index 77a4ea10..46bb3189 100644 --- a/tests/test_spike_report.py +++ b/tests/test_spike_report.py @@ -226,6 +226,12 @@ def test_get(self): self.test_obj.get(group="Layer23"), _create_series([0, 0], [0.2, 1.3]) ) + # test that simulation node_set is used + pdt.assert_series_equal( + self.test_obj.get("test_nodes"), + _create_series([2, 0, 2, 0], [0.1, 0.2, 0.7, 1.3]), + ) + # no 0.1, 0.7 from ("default2", 2) ids = CircuitNodeIds.from_arrays(["default", "default", "default2"], [0, 1, 2]) npt.assert_array_equal(self.test_obj.get(ids), _create_series([0, 1, 0], [0.2, 0.3, 1.3]))