Skip to content
Snippets Groups Projects
Commit 6067f69f authored by Sam Yates's avatar Sam Yates Committed by Ben Cumming
Browse files

Fix bug in target handle unit test. (#275)

Unit test did not take into account that the target handles set by the lowered cell will be grouped by cell.
parent a1a75073
No related branches found
No related tags found
No related merge requests found
...@@ -328,7 +328,7 @@ struct handle_info { ...@@ -328,7 +328,7 @@ struct handle_info {
// test handle <-> mechanism/index correspondence // test handle <-> mechanism/index correspondence
// on a two-cell ball-and-stick system. // on a two-cell ball-and-stick system.
void run_target_handle_test(std::vector<handle_info> handles) { void run_target_handle_test(std::vector<handle_info> all_handles) {
using namespace nest::mc; using namespace nest::mc;
nest::mc::cell cells[] = { nest::mc::cell cells[] = {
...@@ -344,7 +344,9 @@ void run_target_handle_test(std::vector<handle_info> handles) { ...@@ -344,7 +344,9 @@ void run_target_handle_test(std::vector<handle_info> handles) {
EXPECT_EQ(4u, cells[1].segment(1)->num_compartments()); EXPECT_EQ(4u, cells[1].segment(1)->num_compartments());
EXPECT_EQ(5u, cells[1].num_compartments()); EXPECT_EQ(5u, cells[1].num_compartments());
for (auto& x: handles) { std::vector<std::vector<handle_info>> handles(2);
for (auto x: all_handles) {
unsigned seg_id; unsigned seg_id;
double pos; double pos;
...@@ -368,9 +370,10 @@ void run_target_handle_test(std::vector<handle_info> handles) { ...@@ -368,9 +370,10 @@ void run_target_handle_test(std::vector<handle_info> handles) {
} }
cells[x.cell].add_synapse({seg_id, pos}, parameter_list(x.mech)); cells[x.cell].add_synapse({seg_id, pos}, parameter_list(x.mech));
handles[x.cell].push_back(x);
} }
auto n = handles.size(); auto n = all_handles.size();
std::vector<fvm_cell::target_handle> targets(n); std::vector<fvm_cell::target_handle> targets(n);
std::vector<fvm_cell::probe_handle> probes; std::vector<fvm_cell::probe_handle> probes;
...@@ -378,12 +381,16 @@ void run_target_handle_test(std::vector<handle_info> handles) { ...@@ -378,12 +381,16 @@ void run_target_handle_test(std::vector<handle_info> handles) {
fvcell.initialize(cells, targets, probes); fvcell.initialize(cells, targets, probes);
ASSERT_EQ(n, util::size(targets)); ASSERT_EQ(n, util::size(targets));
for (std::size_t i = 0; i<n; ++i) { unsigned i = 0;
// targets are represented by a pair of mechanism index and instance index for (unsigned ci = 0; ci<=1; ++ci) {
const auto& mech = fvcell.mechanisms()[targets[i].first]; for (auto h: handles[ci]) {
const auto& cvidx = mech->node_index(); // targets are represented by a pair of mechanism index and instance index
EXPECT_EQ(handles[i].mech, mech->name()); const auto& mech = fvcell.mechanisms()[targets[i].first];
EXPECT_EQ(handles[i].cv, cvidx[targets[i].second]); const auto& cvidx = mech->node_index();
EXPECT_EQ(h.mech, mech->name());
EXPECT_EQ(h.cv, cvidx[targets[i].second]);
++i;
}
} }
} }
...@@ -414,32 +421,17 @@ TEST(fvm_multi, target_handles_onecell) ...@@ -414,32 +421,17 @@ TEST(fvm_multi, target_handles_onecell)
run_target_handle_test(handles1); run_target_handle_test(handles1);
} }
TEST(fvm_multi, target_handles_twocell_sorted) TEST(fvm_multi, target_handles_twocell)
{ {
SCOPED_TRACE("handles: expsyn only on cells 0 and 1, cvs sorted"); SCOPED_TRACE("handles: expsyn only on cells 0 and 1");
std::vector<handle_info> handles = { std::vector<handle_info> handles = {
{0, "expsyn", 0}, {0, "expsyn", 0},
{1, "expsyn", 3},
{0, "expsyn", 2}, {0, "expsyn", 2},
{0, "expsyn", 4},
{1, "expsyn", 1},
{1, "expsyn", 2}, {1, "expsyn", 2},
{1, "expsyn", 3},
{1, "expsyn", 4}
};
run_target_handle_test(handles);
}
TEST(fvm_multi, target_handles_twocell_unsorted)
{
SCOPED_TRACE("handles: expsyn only on cells 0 and 1, cvs unsorted");
std::vector<handle_info> handles = {
{0, "expsyn", 4}, {0, "expsyn", 4},
{1, "expsyn", 4},
{1, "expsyn", 3},
{0, "expsyn", 2},
{0, "expsyn", 0},
{1, "expsyn", 1}, {1, "expsyn", 1},
{1, "expsyn", 2} {1, "expsyn", 4}
}; };
run_target_handle_test(handles); run_target_handle_test(handles);
} }
...@@ -464,10 +456,10 @@ TEST(fvm_multi, target_handles_general) ...@@ -464,10 +456,10 @@ TEST(fvm_multi, target_handles_general)
SCOPED_TRACE("handles: expsyn and exp2syn on cells 0 and 1"); SCOPED_TRACE("handles: expsyn and exp2syn on cells 0 and 1");
std::vector<handle_info> handles = { std::vector<handle_info> handles = {
{0, "expsyn", 4}, {0, "expsyn", 4},
{1, "exp2syn", 4},
{1, "expsyn", 3},
{0, "exp2syn", 2}, {0, "exp2syn", 2},
{0, "exp2syn", 0}, {0, "exp2syn", 0},
{1, "exp2syn", 4},
{1, "expsyn", 3},
{1, "expsyn", 1}, {1, "expsyn", 1},
{1, "expsyn", 2} {1, "expsyn", 2}
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment