We currently have no way of detecting the existence of parameter objects. Since there objects live outside the kernel (at the Python level), they also are not subject to ResetKernel. Fixing this will thus require some careful thought.
import nest
p = nest.random.normal(mean=0, std=1)
nest.local_num_threads = 2
n = nest.Create('iaf_psc_exp')
num_rounds = 10
v = []
for _ in range(num_rounds):
n.set(V_m=p)
v.append(n.V_m)
assert len(set(v)) == num_rounds # all v must differ
The test below will fail if run as is. If the number of threads is changed before
p = nest.random.normal(mean=0, std=1)
all works well. Otherwise, there is also a risk of a seg.fault. This applies at present tonormal
andlognormal
parameters only and is due to the fact that these two parameter types maintain per-thread objects internally (https://github.com/nest/nest-simulator/blob/c6aacad4bb5a0685bdf8414e0bf366ed16a88a9b/nestkernel/parameter.cpp#L95, https://github.com/nest/nest-simulator/blob/c6aacad4bb5a0685bdf8414e0bf366ed16a88a9b/nestkernel/parameter.cpp#L121).We currently have no way of detecting the existence of parameter objects. Since there objects live outside the kernel (at the Python level), they also are not subject to
ResetKernel
. Fixing this will thus require some careful thought.Until we have a proper fix, we should add a clear warning on https://nest-simulator.readthedocs.io/en/stable/neurons/parametrization.html.