From 7c7b2284733493d178578a1fb65b936eab752622 Mon Sep 17 00:00:00 2001 From: Ben Cumming <bcumming@cscs.ch> Date: Fri, 29 Oct 2021 11:31:23 +0200 Subject: [PATCH] improve error diagnostics in python recipe (#1743) --- python/recipe.cpp | 4 ++++ python/recipe.hpp | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/python/recipe.cpp b/python/recipe.cpp index de2cb132..83172209 100644 --- a/python/recipe.cpp +++ b/python/recipe.cpp @@ -14,6 +14,7 @@ #include <arbor/morph/primitives.hpp> #include <arbor/recipe.hpp> +#include "arbor/cable_cell_param.hpp" #include "conversion.hpp" #include "error.hpp" #include "event_generator.hpp" @@ -70,6 +71,9 @@ static std::any convert_gprop(pybind11::object o) { if (o.is(pybind11::none())) { return {}; } + if (!pybind11::isinstance<arb::cable_cell_global_properties>(o)) { + throw pyarb_error("recipe.global_properties must return a valid description of cable cell properties of type arbor.cable_global_properties"); + } return pybind11::cast<arb::cable_cell_global_properties>(o); } diff --git a/python/recipe.hpp b/python/recipe.hpp index 9956b724..a8a658ab 100644 --- a/python/recipe.hpp +++ b/python/recipe.hpp @@ -48,7 +48,6 @@ public: virtual pybind11::object global_properties(arb::cell_kind kind) const { return pybind11::none(); }; - //TODO: virtual pybind11::object global_properties(arb::cell_kind kind) const {return pybind11::none();}; }; class py_recipe_trampoline: public py_recipe { -- GitLab