diff --git a/arbor/morph/label_parse.cpp b/arbor/morph/label_parse.cpp index 7321bdef6011812f6b551153deb0f0d719e20a70..01b11a2080833fa041a5adf278e3ee3d7defec7b 100644 --- a/arbor/morph/label_parse.cpp +++ b/arbor/morph/label_parse.cpp @@ -181,79 +181,91 @@ struct make_fold { std::unordered_multimap<std::string, evaluator> eval_map { // Functions that return regions - {"nil", make_call<>(arb::reg::nil, - "'nil' with 0 arguments")}, - {"all", make_call<>(arb::reg::all, - "'all' with 0 arguments")}, - {"tag", make_call<int>(arb::reg::tagged, - "'tag' with 1 argment: (tag_id:integer)")}, + {"nil", make_call<>(arb::reg::nil, + "'nil' with 0 arguments")}, + {"all", make_call<>(arb::reg::all, + "'all' with 0 arguments")}, + {"tag", make_call<int>(arb::reg::tagged, + "'tag' with 1 argment: (tag_id:integer)")}, {"segment", make_call<int>(arb::reg::segment, - "'segment' with 1 argment: (segment_id:integer)")}, - {"branch", make_call<int>(arb::reg::branch, - "'branch' with 1 argument: (branch_id:integer)")}, - {"cable", make_call<int, double, double>(arb::reg::cable, - "'cable' with 3 arguments: (branch_id:integer prox:real dist:real)")}, - {"region", make_call<std::string>(arb::reg::named, - "'region' with 1 argument: (name:string)")}, - {"distal-interval", make_call<arb::locset, double>(arb::reg::distal_interval, + "'segment' with 1 argment: (segment_id:integer)")}, + {"branch", make_call<int>(arb::reg::branch, + "'branch' with 1 argument: (branch_id:integer)")}, + {"cable", make_call<int, double, double>(arb::reg::cable, + "'cable' with 3 arguments: (branch_id:integer prox:real dist:real)")}, + {"region", make_call<std::string>(arb::reg::named, + "'region' with 1 argument: (name:string)")}, + {"distal-interval", make_call<arb::locset, double>(arb::reg::distal_interval, "'distal-interval' with 2 arguments: (start:locset extent:real)")}, {"distal-interval", make_call<arb::locset>( [](arb::locset ls){return arb::reg::distal_interval(std::move(ls), std::numeric_limits<double>::max());}, "'distal-interval' with 1 argument: (start:locset)")}, - {"proximal-interval",make_call<arb::locset, double>(arb::reg::proximal_interval, - "'proximal-interval' with 2 arguments: (start:locset extent:real)")}, + {"proximal-interval", make_call<arb::locset, double>(arb::reg::proximal_interval, + "'proximal-interval' with 2 arguments: (start:locset extent:real)")}, {"proximal-interval", make_call<arb::locset>( - [](arb::locset ls){return arb::reg::proximal_interval(std::move(ls), std::numeric_limits<double>::max());}, - "'proximal_interval' with 1 argument: (start:locset)")}, + [](arb::locset ls){return arb::reg::proximal_interval(std::move(ls), std::numeric_limits<double>::max());}, + "'proximal_interval' with 1 argument: (start:locset)")}, {"complete", make_call<arb::region>(arb::reg::complete, - "'complete' with 1 argment: (reg:region)")}, - {"radius-lt",make_call<arb::region, double>(arb::reg::radius_lt, - "'radius-lt' with 2 arguments: (reg:region radius:real)")}, - {"radius-le",make_call<arb::region, double>(arb::reg::radius_le, - "'radius-le' with 2 arguments: (reg:region radius:real)")}, - {"radius-gt",make_call<arb::region, double>(arb::reg::radius_gt, - "'radius-gt' with 2 arguments: (reg:region radius:real)")}, - {"radius-ge",make_call<arb::region, double>(arb::reg::radius_ge, - "'radius-ge' with 2 arguments: (reg:region radius:real)")}, - {"z-dist-from-root-lt",make_call<double>(arb::reg::z_dist_from_root_lt, - "'z-dist-from-root-lt' with 1 arguments: (distance:real)")}, - {"z-dist-from-root-le",make_call<double>(arb::reg::z_dist_from_root_le, - "'z-dist-from-root-le' with 1 arguments: (distance:real)")}, - {"z-dist-from-root-gt",make_call<double>(arb::reg::z_dist_from_root_gt, - "'z-dist-from-root-gt' with 1 arguments: (distance:real)")}, - {"z-dist-from-root-ge",make_call<double>(arb::reg::z_dist_from_root_ge, - "'z-dist-from-root-ge' with 1 arguments: (distance:real)")}, - {"join", make_fold<arb::region>(static_cast<arb::region(*)(arb::region, arb::region)>(arb::join), - "'join' with at least 2 arguments: (region region [...region])")}, - {"intersect",make_fold<arb::region>(static_cast<arb::region(*)(arb::region, arb::region)>(arb::intersect), - "'intersect' with at least 2 arguments: (region region [...region])")}, + "'complete' with 1 argment: (reg:region)")}, + {"radius-lt", make_call<arb::region, double>(arb::reg::radius_lt, + "'radius-lt' with 2 arguments: (reg:region radius:real)")}, + {"radius-le", make_call<arb::region, double>(arb::reg::radius_le, + "'radius-le' with 2 arguments: (reg:region radius:real)")}, + {"radius-gt", make_call<arb::region, double>(arb::reg::radius_gt, + "'radius-gt' with 2 arguments: (reg:region radius:real)")}, + {"radius-ge", make_call<arb::region, double>(arb::reg::radius_ge, + "'radius-ge' with 2 arguments: (reg:region radius:real)")}, + {"z-dist-from-root-lt", make_call<double>(arb::reg::z_dist_from_root_lt, + "'z-dist-from-root-lt' with 1 arguments: (distance:real)")}, + {"z-dist-from-root-le", make_call<double>(arb::reg::z_dist_from_root_le, + "'z-dist-from-root-le' with 1 arguments: (distance:real)")}, + {"z-dist-from-root-gt", make_call<double>(arb::reg::z_dist_from_root_gt, + "'z-dist-from-root-gt' with 1 arguments: (distance:real)")}, + {"z-dist-from-root-ge", make_call<double>(arb::reg::z_dist_from_root_ge, + "'z-dist-from-root-ge' with 1 arguments: (distance:real)")}, + {"complement", make_call<arb::region>(arb::complement, + "'complement' with 1 argment: (reg:region)")}, + {"difference", make_call<arb::region, arb::region>(arb::difference, + "'difference' with 2 argments: (reg:region, reg:region)")}, + {"join", make_fold<arb::region>(static_cast<arb::region(*)(arb::region, arb::region)>(arb::join), + "'join' with at least 2 arguments: (region region [...region])")}, + {"intersect", make_fold<arb::region>(static_cast<arb::region(*)(arb::region, arb::region)>(arb::intersect), + "'intersect' with at least 2 arguments: (region region [...region])")}, // Functions that return locsets - {"root", make_call<>(arb::ls::root, - "'root' with 0 arguments")}, + {"root", make_call<>(arb::ls::root, + "'root' with 0 arguments")}, {"location", make_call<int, double>([](int bid, double pos){return arb::ls::location(arb::msize_t(bid), pos);}, - "'location' with 2 arguments: (branch_id:integer position:real)")}, + "'location' with 2 arguments: (branch_id:integer position:real)")}, {"terminal", make_call<>(arb::ls::terminal, - "'terminal' with 0 arguments")}, - {"distal", make_call<arb::region>(arb::ls::most_distal, - "'distal' with 1 argument: (reg:region)")}, - {"proximal",make_call<arb::region>(arb::ls::most_proximal, - "'proximal' with 1 argument: (reg:region)")}, - {"uniform",make_call<arb::region, int, int, int>(arb::ls::uniform, - "'uniform' with 4 arguments: (reg:region, first:int, last:int, seed:int)")}, - {"on-branches",make_call<double>(arb::ls::on_branches, - "'on-branches' with 1 argument: (pos:double)")}, - {"on-components",make_call<double, arb::region>(arb::ls::on_components, - "'on-components' with 2 arguments: (pos:double, reg:region)")}, - {"locset", make_call<std::string>(arb::ls::named, - "'locset' with 1 argument: (name:string)")}, - {"restrict", make_call<arb::locset, arb::region>(arb::ls::restrict, - "'restrict' with 2 arguments: (ls:locset, reg:region)")}, - {"join", make_fold<arb::locset>(static_cast<arb::locset(*)(arb::locset, arb::locset)>(arb::join), - "'join' with at least 2 arguments: (locset locset [...locset])")}, - {"sum", make_fold<arb::locset>(static_cast<arb::locset(*)(arb::locset, arb::locset)>(arb::sum), - "'sum' with at least 2 arguments: (locset locset [...locset])")}, + "'terminal' with 0 arguments")}, + {"distal", make_call<arb::region>(arb::ls::most_distal, + "'distal' with 1 argument: (reg:region)")}, + {"proximal", make_call<arb::region>(arb::ls::most_proximal, + "'proximal' with 1 argument: (reg:region)")}, + {"uniform", make_call<arb::region, int, int, int>(arb::ls::uniform, + "'uniform' with 4 arguments: (reg:region, first:int, last:int, seed:int)")}, + {"on-branches", make_call<double>(arb::ls::on_branches, + "'on-branches' with 1 argument: (pos:double)")}, + {"on-components", make_call<double, arb::region>(arb::ls::on_components, + "'on-components' with 2 arguments: (pos:double, reg:region)")}, + {"boundary", make_call<arb::region>(arb::ls::boundary, + "'boundary' with 1 argument: (reg:region)")}, + {"cboundary", make_call<arb::region>(arb::ls::cboundary, + "'cboundary' with 1 argument: (reg:region)")}, + {"segment-boundaries", make_call<>(arb::ls::segment_boundaries, + "'segment-boundaries' with 0 arguments")}, + {"support", make_call<arb::locset>(arb::ls::support, + "'support' with 1 argument (ls:locset)")}, + {"locset", make_call<std::string>(arb::ls::named, + "'locset' with 1 argument: (name:string)")}, + {"restrict", make_call<arb::locset, arb::region>(arb::ls::restrict, + "'restrict' with 2 arguments: (ls:locset, reg:region)")}, + {"join", make_fold<arb::locset>(static_cast<arb::locset(*)(arb::locset, arb::locset)>(arb::join), + "'join' with at least 2 arguments: (locset locset [...locset])")}, + {"sum", make_fold<arb::locset>(static_cast<arb::locset(*)(arb::locset, arb::locset)>(arb::sum), + "'sum' with at least 2 arguments: (locset locset [...locset])")}, }; parse_hopefully<std::any> eval(const s_expr& e); diff --git a/arbor/morph/locset.cpp b/arbor/morph/locset.cpp index 2e89ec2c9faacb255ef1449cceefa0a11da5df35..ea37fb008f41dc4eebdc478753917c475a1ecd46 100644 --- a/arbor/morph/locset.cpp +++ b/arbor/morph/locset.cpp @@ -146,7 +146,7 @@ mlocation_list thingify_(const segments_&, const mprovider& p) { } std::ostream& operator<<(std::ostream& o, const segments_& x) { - return o << "(segment_boundaries)"; + return o << "(segment-boundaries)"; } diff --git a/test/unit/test_s_expr.cpp b/test/unit/test_s_expr.cpp index 970e972ed0b077fc93462ecf6e05eaf19b965676..697e7b30fa8a2b962e8a13019142de9403c478ab 100644 --- a/test/unit/test_s_expr.cpp +++ b/test/unit/test_s_expr.cpp @@ -210,6 +210,8 @@ TEST(regloc, round_tripping) { "(radius-gt (tag 3) 1)", "(radius-ge (tag 4) 3)", "(intersect (cable 2 0 0.5) (region \"axon\"))", + "(complement (region \"axon\"))", + "(difference (region \"axon\") (region \"soma\"))", }; for (auto l: region_literals) { EXPECT_EQ(l, round_trip_label<arb::region>(l)); @@ -228,6 +230,10 @@ TEST(regloc, round_tripping) { "(on-components 0.3 (segment 2))", "(join (terminal) (root))", "(sum (terminal) (root))", + "(boundary (tag 2))", + "(cboundary (join (tag 2) (region \"dend\")))", + "(segment-boundaries)", + "(support (distal (tag 2)))", }; for (auto l: locset_literals) { EXPECT_EQ(l, round_trip_label<arb::locset>(l));