From fe297d91f1a00f2f9bc09cc214ab63de632166e6 Mon Sep 17 00:00:00 2001 From: Sebastian Schmitt <sebastian.schmitt@kip.uni-heidelberg.de> Date: Tue, 22 Mar 2022 19:34:21 +0100 Subject: [PATCH] List comprehension to speed up brunel python example (#1864) --- python/example/brunel.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/python/example/brunel.py b/python/example/brunel.py index 37c415cd..541a72c4 100755 --- a/python/example/brunel.py +++ b/python/example/brunel.py @@ -64,11 +64,16 @@ class brunel_recipe (arbor.recipe): gen = RandomState(gid + self.seed_) connections=[] # Add incoming excitatory connections. - for i in sample_subset(gen, gid, 0, self.ncells_exc_, self.in_degree_exc_): - connections.append(arbor.connection((i,"src"), "tgt", self.weight_exc_, self.delay_)) + connections = [ + arbor.connection((i,"src"), "tgt", self.weight_exc_, self.delay_) + for i in sample_subset(gen, gid, 0, self.ncells_exc_, self.in_degree_exc_) + ] # Add incoming inhibitory connections. - for i in sample_subset(gen, gid, self.ncells_exc_, self.ncells_exc_ + self.ncells_inh_, self.in_degree_inh_): - connections.append(arbor.connection((i,"src"), "tgt", self.weight_inh_, self.delay_)) + connections += [ + arbor.connection((i,"src"), "tgt", self.weight_inh_, self.delay_) + for i in sample_subset(gen, gid, self.ncells_exc_, self.ncells_exc_ + self.ncells_inh_, self.in_degree_inh_) + ] + return connections def cell_description(self, gid): -- GitLab