Skip to content

Commit

Permalink
Reduced the node's selection before getting properties (#196)
Browse files Browse the repository at this point in the history
* Reduced the node's selection before getting properties
* fixes #195
* much faster; hat tip @matz-e for noticing the problem
* enlarge allowed pickles for python 3.10
  • Loading branch information
mgeplf committed Apr 24, 2023
1 parent 839c910 commit bc870f6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions bluepysnap/nodes/node_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,6 @@ def get(self, group=None, properties=None):
(pandas.core.frame.DataFrame, (1, 1))
"""
result = self._data
if properties is not None:
for p in utils.ensure_list(properties):
self._check_property(p)
result = result[properties]

if group is not None:
if isinstance(group, (int, np.integer)):
self._check_id(group)
Expand All @@ -456,6 +451,11 @@ def get(self, group=None, properties=None):
group = self.ids(group)
result = result.loc[group]

if properties is not None:
for p in utils.ensure_list(properties):
self._check_property(p)
result = result[properties]

return result

def positions(self, group=None):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edges/test_edge_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def test_pickle(self, tmp_path):
with open(pickle_path, "rb") as fd:
edge_population = pickle.load(fd)

assert pickle_path.stat().st_size < 250
assert pickle_path.stat().st_size <= 250
assert edge_population.name == "default"


Expand Down
2 changes: 1 addition & 1 deletion tests/test_edges/test_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,5 +784,5 @@ def test_pickle(self, tmp_path):
with open(pickle_path, "rb") as fd:
test_obj = pickle.load(fd)

assert pickle_path.stat().st_size < 150
assert pickle_path.stat().st_size < 170
assert test_obj.size == 8
2 changes: 1 addition & 1 deletion tests/test_nodes/test_node_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def test_pickle(self, tmp_path):
with open(pickle_path, "rb") as fd:
test_obj = pickle.load(fd)

assert pickle_path.stat().st_size < 190
assert pickle_path.stat().st_size <= 200
assert test_obj.size == 3


Expand Down
2 changes: 1 addition & 1 deletion tests/test_nodes/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,5 +426,5 @@ def test_pickle(self, tmp_path):
with open(pickle_path, "rb") as fd:
test_obj = pickle.load(fd)

assert pickle_path.stat().st_size < 150
assert pickle_path.stat().st_size < 170
assert test_obj.size == 7

0 comments on commit bc870f6

Please sign in to comment.