Skip to content
Snippets Groups Projects
Unverified Commit eed84f93 authored by Nora Abi Akar's avatar Nora Abi Akar Committed by GitHub
Browse files

Throw exception when probes attached to cells that don't support them in recipes (#1283)

parent 0df4aa65
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,11 @@ namespace arb {
using arb::util::pprintf;
bad_cell_probe::bad_cell_probe(cell_kind kind, cell_gid_type gid):
arbor_exception(pprintf("recipe::get_grobe() is not supported for cell with gid {} of kind {})", gid, kind)),
gid(gid),
kind(kind)
{}
bad_cell_description::bad_cell_description(cell_kind kind, cell_gid_type gid):
arbor_exception(pprintf("recipe::get_cell_kind(gid={}) -> {} does not match the cell type provided by recipe::get_cell_description(gid={})", gid, kind, gid)),
gid(gid),
......
#include <chrono>
#include <exception>
#include <arbor/arbexcept.hpp>
#include <arbor/benchmark_cell.hpp>
#include <arbor/recipe.hpp>
#include <arbor/schedule.hpp>
......@@ -17,6 +18,12 @@ benchmark_cell_group::benchmark_cell_group(const std::vector<cell_gid_type>& gid
const recipe& rec):
gids_(gids)
{
for (auto gid: gids_) {
if (!rec.get_probes(gid).empty()) {
throw bad_cell_probe(cell_kind::benchmark, gid);
}
}
cells_.reserve(gids_.size());
for (auto gid: gids_) {
cells_.push_back(util::any_cast<benchmark_cell>(rec.get_cell_description(gid)));
......
......@@ -29,6 +29,12 @@ struct arbor_exception: std::runtime_error {
// Recipe errors:
struct bad_cell_probe: arbor_exception {
bad_cell_probe(cell_kind kind, cell_gid_type gid);
cell_gid_type gid;
cell_kind kind;
};
struct bad_cell_description: arbor_exception {
bad_cell_description(cell_kind kind, cell_gid_type gid);
cell_gid_type gid;
......
#include <arbor/arbexcept.hpp>
#include <lif_cell_group.hpp>
#include "profile/profiler_macro.hpp"
......@@ -9,6 +11,11 @@ using namespace arb;
lif_cell_group::lif_cell_group(const std::vector<cell_gid_type>& gids, const recipe& rec):
gids_(gids)
{
for (auto gid: gids_) {
if (!rec.get_probes(gid).empty()) {
throw bad_cell_probe(cell_kind::lif, gid);
}
}
// Default to no binning of events
set_binning_policy(binning_kind::none, 0);
......
......@@ -15,6 +15,12 @@ namespace arb {
spike_source_cell_group::spike_source_cell_group(const std::vector<cell_gid_type>& gids, const recipe& rec):
gids_(gids)
{
for (auto gid: gids_) {
if (!rec.get_probes(gid).empty()) {
throw bad_cell_probe(cell_kind::spike_source, gid);
}
}
time_sequences_.reserve(gids_.size());
for (auto gid: gids_) {
try {
......
#include "../gtest.h"
#include <arbor/arbexcept.hpp>
#include <arbor/cable_cell.hpp>
#include <arbor/domain_decomposition.hpp>
#include <arbor/lif_cell.hpp>
#include <arbor/load_balance.hpp>
......@@ -122,6 +124,40 @@ private:
float weight_, delay_;
};
// LIF cell with probe
class probe_recipe: public arb::recipe {
public:
probe_recipe() {}
cell_size_type num_cells() const override {
return 1;
}
cell_kind get_cell_kind(cell_gid_type gid) const override {
return cell_kind::lif;
}
std::vector<cell_connection> connections_on(cell_gid_type gid) const override {
return {};
}
util::unique_any get_cell_description(cell_gid_type gid) const override {
return lif_cell();
}
cell_size_type num_sources(cell_gid_type) const override {
return 1;
}
cell_size_type num_targets(cell_gid_type) const override {
return 1;
}
std::vector<probe_info> get_probes(cell_gid_type gid) const override{
return {arb::cable_probe_membrane_voltage{mlocation{0, 0}}};
}
};
TEST(lif_cell_group, throw) {
probe_recipe rec;
auto context = make_context();
auto decomp = partition_load_balance(rec, context);
EXPECT_THROW(simulation(rec, decomp, context), bad_cell_probe);
}
TEST(lif_cell_group, recipe)
{
ring_recipe rr(100, 1, 0.1);
......
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