Skip to content

Commit

Permalink
Review by Luc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu committed Oct 3, 2023
1 parent c375821 commit 1f9980e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/ivoc/scenepic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ ScenePickerImpl::ScenePickerImpl(Scene* scene)
ScenePickerImpl::~ScenePickerImpl() {
Resource::unref(menu_);
Resource::unref(tg_);
for (auto& elem: *bil_) {
delete elem;
for (ButtonItemInfo* bii: *bil_) {
delete bii;
}
delete bil_;
}
Expand Down
8 changes: 3 additions & 5 deletions src/nrncvode/netcvode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3051,27 +3051,25 @@ static OcList* event_info_list_; // netcon or point_process
static void event_info_callback(const TQItem*, int);
static void event_info_callback(const TQItem* q, int) {
DiscreteEvent* d = (DiscreteEvent*) q->data_;
PreSyn* ps;
SelfEvent* se;
switch (d->type()) {
case NetConType:
if (event_info_type_ == NetConType) {
NetCon* nc = (NetCon*) d;
auto* nc = static_cast<NetCon*>(d);
event_info_tvec_->push_back(q->t_);
event_info_list_->append(nc->obj_);
}
break;
case SelfEventType:
if (event_info_type_ == SelfEventType) {
se = (SelfEvent*) d;
auto* se = static_cast<SelfEvent*>(d);
event_info_tvec_->push_back(q->t_);
event_info_flagvec_->push_back(se->flag_);
event_info_list_->append(se->target_->ob);
}
break;
case PreSynType:
if (event_info_type_ == NetConType) {
ps = (PreSyn*) d;
auto* ps = static_cast<PreSyn*>(d);
for (const auto& nc: reverse(ps->dil_)) {
double td = nc->delay_ - ps->delay_;
event_info_tvec_->push_back(q->t_ + td);
Expand Down
16 changes: 8 additions & 8 deletions src/nrniv/nrndae.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void nrndae_deregister(NrnDAE* n) {

int nrndae_extra_eqn_count() {
int neqn = 0;
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
neqn += item->extra_eqn_count();
}
return neqn;
}

void nrndae_update(NrnThread* _nt) {
update_sp13_rhs_based_on_actual_rhs(_nt);
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->update();
}
update_actual_rhs_based_on_sp13_rhs(_nt);
Expand All @@ -46,7 +46,7 @@ void nrndae_alloc() {
if (_nt->_ecell_memb_list) {
neqn += _nt->_ecell_memb_list->nodecount * nlayer;
}
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->alloc(neqn + 1);
neqn += item->extra_eqn_count();
}
Expand All @@ -63,7 +63,7 @@ void nrndae_init() {
(secondorder > 0 || ((cvode_active_ > 0) && (nrn_use_daspk_ == 0)))) {
hoc_execerror("NrnDAEs only work with secondorder==0 or daspk", 0);
}
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->init();
}
for (int it = 0; it < nrn_nthread; ++it) {
Expand All @@ -76,30 +76,30 @@ void nrndae_init() {
void nrndae_rhs(NrnThread* _nt) {
update_sp13_mat_based_on_actual_d(_nt);
update_sp13_rhs_based_on_actual_rhs(_nt);
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->rhs();
}
update_actual_d_based_on_sp13_mat(_nt);
update_actual_rhs_based_on_sp13_rhs(_nt);
}

void nrndae_lhs() {
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->lhs();
}
}

void nrndae_dkmap(std::vector<neuron::container::data_handle<double>>& pv,
std::vector<neuron::container::data_handle<double>>& pvdot) {
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->dkmap(pv, pvdot);
}
}

void nrndae_dkres(double* y, double* yprime, double* delta) {
// c*y' = f(y) so
// delta = c*y' - f(y)
for (auto&& item: nrndae_list) {
for (NrnDAE* item: nrndae_list) {
item->dkres(y, yprime, delta);
}
}
Expand Down
8 changes: 4 additions & 4 deletions test/unit_tests/utils/enumerate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@


TEST_CASE("apply_to_first", "[Neuron]") {
std::vector<double> x{1.0, 2.0, 3.0};
std::vector<double> x{1.0, 2.0, 2.0, 3.0};

apply_to_first(x, 2.0, [](auto it) { *it = 5.0; });
REQUIRE(x == std::vector<double>({1.0, 5.0, 3.0}));
REQUIRE(x == std::vector<double>({1.0, 5.0, 2.0, 3.0}));
}

TEST_CASE("erase_first", "[Neuron]") {
std::vector<double> x{1.0, 2.0, 3.0};
std::vector<double> x{1.0, 2.0, 2.0, 3.0};

erase_first(x, 2.0);
REQUIRE(x == std::vector<double>({1.0, 3.0}));
REQUIRE(x == std::vector<double>({1.0, 2.0, 3.0}));
}

TEST_CASE("reverse", "[Neuron]") {
Expand Down

0 comments on commit 1f9980e

Please sign in to comment.