Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creating selection #85

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ target_link_libraries(sonata_python
PRIVATE fmt::fmt-header-only
PRIVATE pybind11::module
)

add_test(NAME pytest COMMAND python tests/test.py WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
2 changes: 0 additions & 2 deletions python/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,6 @@ PYBIND11_MODULE(_libsonata, m) {
.def("__ne__", &bbp::sonata::operator!=, "Compare selection contents are not equal")
.def("__or__", &bbp::sonata::operator|, "Union of selections")
.def("__and__", &bbp::sonata::operator&, "Intersection of selections");
py::implicitly_convertible<py::list, Selection>();
py::implicitly_convertible<py::tuple, Selection>();

bindPopulationClass<NodePopulation>(m, "NodePopulation", "Collection of nodes with attributes")
.def(
Expand Down
8 changes: 5 additions & 3 deletions src/report_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ auto SpikeReader::openPopulation(const std::string& populationName) const -> con
}

Spikes SpikeReader::Population::get(const Selection& node_ids, double tstart, double tstop) const {
if (node_ids.empty()) {
return {};
}

tstart = tstart < 0 ? tstart_ : tstart;
tstop = tstop < 0 ? tstop_ : tstop;
if (tstart > tstop_ + EPSILON || tstop < tstart_ - EPSILON || tstop < tstart) {
Expand All @@ -123,9 +127,7 @@ Spikes SpikeReader::Population::get(const Selection& node_ids, double tstart, do
auto spikes = spikes_;
filterTimestamp(spikes, tstart, tstop);

if (!node_ids.empty()) {
filterNode(spikes, node_ids);
}
filterNode(spikes, node_ids);

return spikes;
}
Expand Down