Skip to content

Commit

Permalink
Merge pull request #2205 from stinebuu/update_doc
Browse files Browse the repository at this point in the history
Update outdated code snippets in documentation
  • Loading branch information
jougs authored Nov 12, 2021
2 parents 3da76dd + 2dcbf4e commit 186e5b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
19 changes: 9 additions & 10 deletions doc/userdoc/guides/parallel_computing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -288,18 +288,17 @@ of all four neurons are recorded to files.
.. code-block:: python
import nest
from nest import Create, Connect, Simulate
nest.total_num_virtual_procs = 4
pg = Create("poisson_generator", params={"rate": 50000.0})
n = Create("iaf_psc_alpha", 4)
sr = Create("spike_recorder", params={"record_to": "ascii"})
Connect(pg, [n[0]], syn_spec={'weight': 1000.0, 'delay': 1.0})
Connect([n[0]], [n[1]], syn_spec={'weight': 1000.0, 'delay': 1.0})
Connect([n[1]], [n[2]], syn_spec={'weight': 1000.0, 'delay': 1.0})
Connect([n[2]], [n[3]], syn_spec={'weight': 1000.0, 'delay': 1.0})
Connect(n, sr)
Simulate(100.0)
pg = nest.Create("poisson_generator", params={"rate": 50000.0})
n = nest.Create("iaf_psc_alpha", 4)
sr = nest.Create("spike_recorder", params={"record_to": "ascii"})
nest.Connect(pg, n[0], syn_spec={"weight": 1000.0, "delay": 1.0})
nest.Connect(n[0], n[1], syn_spec={"weight": 1000.0, "delay": 1.0})
nest.Connect(n[1], n[2], syn_spec={"weight": 1000.0, "delay": 1.0})
nest.Connect(n[2], n[3], syn_spec={"weight": 1000.0, "delay": 1.0})
nest.Connect(n, sr)
nest.Simulate(100.0)
The script is run three times using different numbers of MPI processes,
but 4 virtual processes in every run:
Expand Down
6 changes: 3 additions & 3 deletions doc/userdoc/guides/weight_normalization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ This would look something like:

.. code-block:: python
def normalize_weights(neuron_gids_to_be_normalized, w_target=1):
for neur in neuron_gids_to_be_normalized:
conn = nest.GetConnections(target=[neur])
def normalize_weights(neurons_to_be_normalized, w_target=1):
for neuron in neurons_to_be_normalized:
conn = nest.GetConnections(target=neuron)
w = np.array(conn.weight)
w_normed = w / sum(abs(w)) # L1-norm
conn.weight = w_target * w_normed
Expand Down

0 comments on commit 186e5b3

Please sign in to comment.