Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.
Merged
Prev Previous commit
Next Next commit
change fallback method for Simulation.node_sets
  • Loading branch information
Joni Herttuainen committed Jun 20, 2023
commit 422a48cc3f6b2a0290c7668b4dd767567e86ca4f
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Improvements

Breaking Changes
~~~~~~~~~~~~~~~~
- ``Circuit.node_sets`` returns ``NodeSets`` object initialized with empty dict when ``node_sets_file`` not present
- ``Circuit.node_sets``, ``Simulation.node_sets`` returns ``NodeSets`` object initialized with empty dict when node sets file is not present
- ``NodeSet.resolved`` is no longer available
- ``FrameReport.node_set`` returns node_set name instead of resolved node set query

Expand Down
6 changes: 2 additions & 4 deletions bluepysnap/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ def get_edge_population_config(self, name):
@cached_property
def node_sets(self):
"""Returns the NodeSets object bound to the circuit."""
if "node_sets_file" in self.config:
return NodeSets.from_file(self.config["node_sets_file"])

return NodeSets.from_dict({})
path = self.to_libsonata.node_sets_path
return NodeSets.from_file(path) if path else NodeSets.from_dict({})

@cached_property
def nodes(self):
Expand Down
4 changes: 2 additions & 2 deletions bluepysnap/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def simulator(self):
@cached_property
def node_sets(self):
"""Returns the NodeSets object bound to the simulation."""
node_sets_file = self.to_libsonata.node_sets_file
return NodeSets.from_file(node_sets_file) if node_sets_file else {}
path = self.to_libsonata.node_sets_file
return NodeSets.from_file(path) if path else NodeSets.from_dict({})

@cached_property
def spikes(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_no_node_set():
os.remove(config_path.parent / "circuit_config.json")

simulation = test_module.Simulation(config_path)
assert simulation.node_sets == {}
assert simulation.node_sets.content == {}


def test_pickle(tmp_path):
Expand Down