Skip to content

Commit

Permalink
add small tests to test reports use simulation node sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Joni Herttuainen committed Oct 23, 2023
1 parent 1fec7bb commit 0f3f028
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/data/node_sets_simple.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"Layer23": {
"layer": [2,3]
},
"test_nodes": {
"node_id": [0,2]
}
}
3 changes: 3 additions & 0 deletions tests/test_frame_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
):
Expand Down
1 change: 1 addition & 0 deletions tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions tests/test_spike_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down

0 comments on commit 0f3f028

Please sign in to comment.