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

Fix `load_component` of label-dict (#1859)

parent a365e6ef
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
#include <iomanip> #include <iomanip>
#include <arbor/cable_cell.hpp> #include <arbor/cable_cell.hpp>
#include <arbor/util/any_visitor.hpp>
#include <arborio/cableio.hpp> #include <arborio/cableio.hpp>
#include "error.hpp" #include "error.hpp"
#include "util.hpp" #include "util.hpp"
#include "strprintf.hpp" #include "strprintf.hpp"
#include "proxy.hpp"
namespace pyarb { namespace pyarb {
...@@ -95,7 +97,18 @@ void register_cable_loader(pybind11::module& m) { ...@@ -95,7 +97,18 @@ void register_cable_loader(pybind11::module& m) {
pybind11::class_<arborio::cable_cell_component> cable_component(m, "cable_component"); pybind11::class_<arborio::cable_cell_component> cable_component(m, "cable_component");
cable_component cable_component
.def_readwrite("meta_data", &arborio::cable_cell_component::meta, "cable-cell component meta-data.") .def_readwrite("meta_data", &arborio::cable_cell_component::meta, "cable-cell component meta-data.")
.def_readwrite("component", &arborio::cable_cell_component::component, "cable-cell component.") .def_property_readonly(
"component",
[](const arborio::cable_cell_component& c) {
using py_cable_cell_variant = std::variant<arb::morphology, pyarb::label_dict_proxy, arb::decor, arb::cable_cell>;
auto cable_cell_variant_visitor = arb::util::overload(
[&](const arb::morphology& p) { return py_cable_cell_variant(p);},
[&](const arb::label_dict& p) { return py_cable_cell_variant(label_dict_proxy(p));},
[&](const arb::decor& p) { return py_cable_cell_variant(p);},
[&](const arb::cable_cell& p) { return py_cable_cell_variant(p);});
return std::visit(cable_cell_variant_visitor, c.component);
},
"cable-cell component.")
.def("__repr__", [](const arborio::cable_cell_component& comp) { .def("__repr__", [](const arborio::cable_cell_component& comp) {
std::stringstream stream; std::stringstream stream;
arborio::write_component(stream, comp); arborio::write_component(stream, comp);
......
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