From f8f73c839aa9eae9c4d7787c1f73a2829aa18283 Mon Sep 17 00:00:00 2001
From: Ben Cumming <bcumming@cscs.ch>
Date: Fri, 5 Jul 2019 17:14:10 +0200
Subject: [PATCH] remove connection_shim and fix connection printer (#808)

Remove the dead `cell_connection_shim` from the python wrapper.

Fix the connection printer to take an `arb::cell_connection` argument, to fix a runtime python crash caused by passing an `arb::cell_connection` where a `cell_connection_shim` was expected.
---
 python/recipe.cpp | 32 ++------------------------------
 1 file changed, 2 insertions(+), 30 deletions(-)

diff --git a/python/recipe.cpp b/python/recipe.cpp
index 11f1f80a..af787726 100644
--- a/python/recipe.cpp
+++ b/python/recipe.cpp
@@ -57,39 +57,11 @@ std::vector<arb::event_generator> py_recipe_shim::event_generators(arb::cell_gid
     return gens;
 }
 
-// Wrap arb::cell_connection in a shim that asserts constraints on connection
-// delay when the user attempts to set them in Python.
-struct cell_connection_shim {
-    arb::cell_member_type source;
-    arb::cell_member_type destination;
-    float weight;
-    arb::time_type delay;
-
-    cell_connection_shim(arb::cell_member_type src, arb::cell_member_type dst, float w, arb::time_type del) {
-        source = src;
-        destination = dst;
-        weight = w;
-        set_delay(del);
-    }
-
-    // getter and setter
-    void set_delay(arb::time_type t) {
-        pyarb::assert_throw([](arb::time_type f){ return f>arb::time_type(0); }(t), "connection delay must be positive");
-        delay = t;
-    }
-
-    arb::time_type get_delay() const { return delay; }
-
-    operator arb::cell_connection() const {
-        return arb::cell_connection(source, destination, weight, delay);
-    }
-};
-
 // TODO: implement py_recipe_shim::probe_info
 
-std::string con_to_string(const cell_connection_shim& c) {
+std::string con_to_string(const arb::cell_connection& c) {
     return util::pprintf("<arbor.connection: source ({},{}), destination ({},{}), delay {}, weight {}>",
-         c.source.gid, c.source.index, c.destination.gid, c.destination.index, c.delay, c.weight);
+         c.source.gid, c.source.index, c.dest.gid, c.dest.index, c.delay, c.weight);
 }
 
 std::string gj_to_string(const arb::gap_junction_connection& gc) {
-- 
GitLab