From 9fed4a91a3f4673a6db8f73594c5758b67f16cfc Mon Sep 17 00:00:00 2001 From: Brent Huisman <brenthuisman@users.noreply.github.com> Date: Fri, 2 Jul 2021 09:21:20 +0200 Subject: [PATCH] Update and rename python example (#1602) - Minor fixes to python examples. - Fix `mpi.py` to use new label API. - Rename `mpi.py`. --- doc/python/decor.rst | 2 +- python/example/network_ring.py | 9 +++++---- python/example/{mpi.py => network_ring_mpi.py} | 11 ++++++----- .../example/{mpi_plot.py => network_ring_mpi_plot.py} | 0 4 files changed, 12 insertions(+), 10 deletions(-) rename python/example/{mpi.py => network_ring_mpi.py} (93%) rename python/example/{mpi_plot.py => network_ring_mpi_plot.py} (100%) diff --git a/doc/python/decor.rst b/doc/python/decor.rst index 8c0104a3..c9412966 100644 --- a/doc/python/decor.rst +++ b/doc/python/decor.rst @@ -1,4 +1,4 @@ -.. pycablecell-decor: +.. _pycablecell-decor: Cable cell decoration ===================== diff --git a/python/example/network_ring.py b/python/example/network_ring.py index 1754ab38..09b3a75c 100755 --- a/python/example/network_ring.py +++ b/python/example/network_ring.py @@ -48,10 +48,10 @@ def make_cable_cell(gid): decor.paint('"dend"', 'pas') # (4) Attach a single synapse. - decor.place('"synapse_site"', 'expsyn', "syn") + decor.place('"synapse_site"', 'expsyn', 'syn') # Attach a spike detector with threshold of -10 mV. - decor.place('"root"', arbor.spike_detector(-10), "detector") + decor.place('"root"', arbor.spike_detector(-10), 'detector') cell = arbor.cable_cell(tree, labels, decor) @@ -88,13 +88,14 @@ class ring_recipe (arbor.recipe): src = (gid-1)%self.ncells w = 0.01 d = 5 - return [arbor.connection((src,"detector"), "syn", w, d)] + return [arbor.connection((src,'detector'), 'syn', w, d)] # (9) Attach a generator to the first cell in the ring. def event_generators(self, gid): if gid==0: sched = arbor.explicit_schedule([1]) - return [arbor.event_generator("syn", 0.1, sched)] + weight = 0.1 + return [arbor.event_generator('syn', weight, sched)] return [] # (10) Place a probe at the root of each cell. diff --git a/python/example/mpi.py b/python/example/network_ring_mpi.py similarity index 93% rename from python/example/mpi.py rename to python/example/network_ring_mpi.py index a7096ede..98a53f69 100644 --- a/python/example/mpi.py +++ b/python/example/network_ring_mpi.py @@ -50,10 +50,10 @@ def make_cable_cell(gid): decor.paint('"dend"', 'pas') # (4) Attach a single synapse. - decor.place('"synapse_site"', 'expsyn') + decor.place('"synapse_site"', 'expsyn', 'syn') # Attach a spike detector with threshold of -10 mV. - decor.place('"root"', arbor.spike_detector(-10)) + decor.place('"root"', arbor.spike_detector(-10), 'detector') cell = arbor.cable_cell(tree, labels, decor) @@ -90,13 +90,14 @@ class ring_recipe (arbor.recipe): src = (gid-1)%self.ncells w = 0.01 d = 5 - return [arbor.connection((src,0), (gid,0), w, d)] + return [arbor.connection((src,'detector'), 'syn', w, d)] # (9) Attach a generator to the first cell in the ring. def event_generators(self, gid): if gid==0: sched = arbor.explicit_schedule([1]) - return [arbor.event_generator((0,0), 0.1, sched)] + weight = 0.1 + return [arbor.event_generator('syn', weight, sched)] return [] # (10) Place a probe at the root of each cell. @@ -133,7 +134,7 @@ sim.run(ncells*5) print('Simulation finished') # (17) Plot the recorded voltages over time. -print("Storing results ...") +print('Storing results ...') df_list = [] for gid in range(ncells): if len(sim.samples(handles[gid])): diff --git a/python/example/mpi_plot.py b/python/example/network_ring_mpi_plot.py similarity index 100% rename from python/example/mpi_plot.py rename to python/example/network_ring_mpi_plot.py -- GitLab