Skip to content
Snippets Groups Projects
Commit 16c17ff0 authored by Benjamin Cumming's avatar Benjamin Cumming
Browse files

fix generation of parent indexes from basic tree + compartment description

parent 5a97abdd
No related branches found
No related tags found
No related merge requests found
......@@ -45,8 +45,8 @@ TEST(run, init)
cell.segment(1)->set_compartments(2);
//using fvm_cell = fvm::fvm_cell<double, int>;
//fvm_cell fvcell(cell);
using fvm_cell = fvm::fvm_cell<double, int>;
fvm_cell fvcell(cell);
// print out the parameters if you want...
//std::cout << soma_hh << "\n";
}
......
......@@ -253,11 +253,69 @@ TEST(cell_tree, json_load)
TEST(tree, make_parent_index)
{
// just the soma
{
std::vector<int> parent_index = {0};
std::vector<int> counts = {1};
nest::mc::tree t(parent_index);
auto new_parent_index = make_parent_index(t, counts);
EXPECT_EQ(parent_index.size(), new_parent_index.size());
}
// just a soma with 5 compartments
{
std::vector<int> parent_index = {0};
std::vector<int> counts = {5};
nest::mc::tree t(parent_index);
auto new_parent_index = make_parent_index(t, counts);
EXPECT_EQ(new_parent_index.size(), counts[0]);
EXPECT_EQ(new_parent_index[0], 0);
for(auto i=1; i<new_parent_index.size(); ++i) {
EXPECT_EQ(new_parent_index[i], i-1);
}
}
// some trees with single compartment per segment
{
auto trees = {
// 0
// |
// 1
std::vector<int>{0,0},
// 0
// / \
// 1 2
std::vector<int>{0,0,0},
// 0
// / \
// 1 4
// / \ |\
// 2 3 5 6
std::vector<int>{0,0,0,1,1,2,2}
};
for(auto &parent_index : trees) {
std::vector<int> counts(parent_index.size(), 1);
nest::mc::tree t(parent_index);
auto new_parent_index = make_parent_index(t, counts);
EXPECT_EQ(parent_index, new_parent_index);
}
}
// a tree with multiple compartments per segment
//
// 0
// / \
// 1 8
// / \
// 2 9
// /
// 3
// / \
// 4 6
// / \
// 5 7
{
std::vector<int> parent_index = {0,0,1,2,3,4,3,6,0,8};
std::vector<int> counts = {1,3,2,2,2};
tree t(parent_index);
auto new_pid = make_parent_index(t, counts);
EXPECT_EQ(parent_index.size(), new_pid.size());
nest::mc::tree t(parent_index);
auto new_parent_index = make_parent_index(t, counts);
EXPECT_EQ(parent_index, new_parent_index);
}
}
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