From 74f8bb2687a87ddda9b4c60298cdbc7dfc1ad7c5 Mon Sep 17 00:00:00 2001 From: Sam Yates <sam@quux.dropbear.id.au> Date: Wed, 20 Jul 2016 11:15:15 +0200 Subject: [PATCH] Address PR review: no functional changes * Remove vestigial #if 0 * Add missing cstring include, std:: in validate.cpp * Simpler synapse index logic in fvm_cell.hpp --- src/fvm_cell.hpp | 44 ++++------------------------ tests/validation/validate.cpp | 3 +- tests/validation/validation_data.hpp | 2 ++ 3 files changed, 10 insertions(+), 39 deletions(-) diff --git a/src/fvm_cell.hpp b/src/fvm_cell.hpp index 05bce5bd..2fa86fd9 100644 --- a/src/fvm_cell.hpp +++ b/src/fvm_cell.hpp @@ -183,11 +183,6 @@ private: /// the potential in mV in each CV vector_type voltage_; -#if 0 - /// synapses - using synapse_type = - mechanisms::ExpSyn::mechanism_ExpSyn<value_type, size_type>; -#endif std::size_t synapse_index_; // synapses at the end of mechanisms_, from here /// the set of mechanisms present in the cell @@ -344,49 +339,22 @@ fvm_cell<T, I>::fvm_cell(nest::mc::cell const& cell) synapse_index_ = mechanisms_.size(); - std::multimap<std::string, int> syn_map; - for (const auto& syn: cell.synapses()) { - syn_map.insert({syn.mechanism.name(), find_compartment_index(syn.location, graph)}); + std::map<std::string, std::vector<int>> syn_map; + for (const auto& syn : cell.synapses()) { + syn_map[syn.mechanism.name()].push_back(find_compartment_index(syn.location, graph)); } - auto syn_i = syn_map.begin(); - while (syn_i!=syn_map.end()) { - const auto& mech_name = syn_i->first; + for (const auto &syni : syn_map) { + const auto& mech_name = syni.first; auto& helper = nest::mc::mechanisms::get_mechanism_helper(mech_name); - auto span = syn_map.equal_range(mech_name); - auto num_comp = std::distance(span.first, span.second); - - index_type compartment_index(num_comp); - for (auto p = compartment_index.data(); syn_i!=span.second; ++p, ++syn_i) { - *p = syn_i->second; - } + index_type compartment_index(syni.second); auto mech = helper->new_mechanism(voltage_, current_, compartment_index); mech->set_areas(cv_areas_); mechanisms_.push_back(std::move(mech)); } -#if 0 - // add the synapses - std::vector<size_type> synapse_indexes; - synapse_indexes.reserve(cell.synapses().size()); - for(auto loc : cell.synapses()) { - synapse_indexes.push_back( - find_compartment_index(loc, graph) - ); - } - - mechanisms_.push_back( - mechanisms::make_mechanism<synapse_type>( - voltage_, current_, index_view(synapse_indexes) - ) - ); - synapse_index_ = mechanisms_.size()-1; - // don't forget to give point processes access to cv_areas_ - mechanisms_[synapse_index_]->set_areas(cv_areas_); -#endif - ///////////////////////////////////////////// // build the ion species diff --git a/tests/validation/validate.cpp b/tests/validation/validate.cpp index 1e71cde2..b89a7b54 100644 --- a/tests/validation/validate.cpp +++ b/tests/validation/validate.cpp @@ -1,3 +1,4 @@ +#include <cstring> #include <iostream> #include <fstream> #include <numeric> @@ -14,7 +15,7 @@ int usage(const char* argv0) { int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - if (argv[1] && (!strcmp(argv[1], "-p") || !strcmp(argv[1], "--path"))) { + if (argv[1] && (!std::strcmp(argv[1], "-p") || !std::strcmp(argv[1], "--path"))) { if (argv[2]) { testing::g_validation_data.set_path(argv[2]); } diff --git a/tests/validation/validation_data.hpp b/tests/validation/validation_data.hpp index 66ea5bc8..2aeb2f39 100644 --- a/tests/validation/validation_data.hpp +++ b/tests/validation/validation_data.hpp @@ -1,5 +1,7 @@ #pragma once +#include <string> + #include <json/src/json.hpp> #ifndef DATADIR -- GitLab