def test_place_pwlin_id(self): # Single branch, discontiguous segments. s0p = A.mpoint(0, 0, 0, 10) s0d = A.mpoint(1, 0, 0, 10) s1p = A.mpoint(3, 0, 0, 10) s1d = A.mpoint(4, 0, 0, 10) tree = A.segment_tree() i = tree.append(A.mnpos, s0p, s0d, 1) tree.append(i, s1p, s1d, 2) m = A.morphology(tree) place = A.place_pwlin(m) L0 = place.at(A.location(0, 0)) L0s = place.all_at(A.location(0, 0)) self.assertEqual(s0p, L0) self.assertEqual([s0p], L0s) Lhalf = place.at(A.location(0, 0.5)) Lhalfs = place.all_at(A.location(0, 0.5)) self.assertTrue(s0d == Lhalf or s1p == Lhalf) self.assertTrue([s0d, s1p] == Lhalfs) Chalf = [(s.prox, s.dist) for s in place.segments([A.cable(0, 0., 0.5)])] self.assertEqual([(s0p, s0d)], Chalf) Chalf_all = [(s.prox, s.dist) for s in place.all_segments([A.cable(0, 0., 0.5)])] self.assertEqual([(s0p, s0d), (s1p, s1p)], Chalf_all)
def test_probe_meta(self): sim = self.init_sim(cc2_recipe()) self.assertEqual([A.location(1, 1)], sim.probe_metadata((0, 0))) self.assertEqual([A.location(2, 1)], sim.probe_metadata((0, 1))) self.assertEqual([A.location(1, 1), A.location(2, 1)], sorted(sim.probe_metadata((0, 2)), key=lambda x: (x.branch, x.pos))) # Default CV policy is one per branch, which also gives a tivial CV over the branch point. # Expect metadata cables to be one for each full branch, plus three length-zero cables corresponding to the branch point. self.assertEqual([ A.cable(0, 0, 1), A.cable(0, 1, 1), A.cable(1, 0, 0), A.cable(1, 0, 1), A.cable(2, 0, 0), A.cable(2, 0, 1) ], sorted(sim.probe_metadata((1, 0))[0], key=lambda x: (x.branch, x.prox, x.dist))) # Four expsyn synapses; the two on branch zero should be coalesced, giving a multiplicity of 2. # Expect entries to be in target index order. m11 = sim.probe_metadata((1, 1))[0] self.assertEqual(4, len(m11)) self.assertEqual([0, 1, 2, 3], [x.target for x in m11]) self.assertEqual([2, 2, 1, 1], [x.multiplicity for x in m11]) self.assertEqual([ A.location(0, 0.3), A.location(0, 0.6), A.location(1, 0.3), A.location(2, 0.3) ], [x.location for x in m11])
def test_place_pwlin_isometry(self): # Single branch, discontiguous segments. s0p = A.mpoint(0, 0, 0, 10) s0d = A.mpoint(1, 0, 0, 10) s1p = A.mpoint(3, 0, 0, 10) s1d = A.mpoint(4, 0, 0, 10) tree = A.segment_tree() i = tree.append(A.mnpos, s0p, s0d, 1) tree.append(i, s1p, s1d, 2) m = A.morphology(tree) iso = A.isometry.translate(2, 3, 4) place = A.place_pwlin(m, iso) x0p = iso(s0p) x0d = iso(s0d) x1p = iso(s1p) x1d = iso(s1d) L0 = place.at(A.location(0, 0)) L0s = place.all_at(A.location(0, 0)) self.assertEqual(x0p, L0) self.assertEqual([x0p], L0s) Lhalf = place.at(A.location(0, 0.5)) Lhalfs = place.all_at(A.location(0, 0.5)) self.assertTrue(x0d == Lhalf or x1p == Lhalf) self.assertTrue([x0d, x1p] == Lhalfs) Chalf = [(s.prox, s.dist) for s in place.segments([A.cable(0, 0., 0.5)])] self.assertEqual([(x0p, x0d)], Chalf) Chalf_all = [(s.prox, s.dist) for s in place.all_segments([A.cable(0, 0., 0.5)])] self.assertEqual([(x0p, x0d), (x1p, x1p)], Chalf_all)
def test_probe_addr_metadata(self): recipe = cc_recipe() context = A.context() dd = A.partition_load_balance(recipe, context) sim = A.simulation(recipe, dd, context) all_cv_cables = [A.cable(0, 0, 1)] m = sim.probe_metadata((0, 0)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.0), m[0]) m = sim.probe_metadata((0, 1)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 2)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.02), m[0]) m = sim.probe_metadata((0, 3)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.03), m[0]) m = sim.probe_metadata((0, 4)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 5)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 6)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.06), m[0]) m = sim.probe_metadata((0, 7)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 8)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.08), m[0].location) self.assertEqual(1, m[0].multiplicity) self.assertEqual(0, m[0].target) m = sim.probe_metadata((0, 9)) self.assertEqual(1, len(m)) self.assertEqual(1, len(m[0])) self.assertEqual(A.location(0, 0.09), m[0][0].location) self.assertEqual(1, m[0][0].multiplicity) self.assertEqual(1, m[0][0].target) m = sim.probe_metadata((0, 10)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.10), m[0]) m = sim.probe_metadata((0, 11)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 12)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.12), m[0]) m = sim.probe_metadata((0, 13)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 14)) self.assertEqual(1, len(m)) self.assertEqual(A.location(0, 0.14), m[0]) m = sim.probe_metadata((0, 15)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0]) m = sim.probe_metadata((0, 16)) self.assertEqual(1, len(m)) self.assertEqual(all_cv_cables, m[0])