Skip to content

When dividing by random parameter, one obtains fixed, not random values #3156

@heplesser

Description

@heplesser

Describe the bug

When initializing neuron or synapse properties with a random parameter appearing as a denominator, NEST assigns fixed values.

To Reproduce

  1. (Minimal) reproducing example
import nest
n = nest.Create('iaf_psc_alpha', 10, {'V_m': 1 / nest.random.uniform(0, 1)})
print(n.V_m)

Expected behavior
Expected results: 10 different membrane potential values
Observed result: 10 identical membrane potential values

Desktop/Environment (please complete the following information):

  • NEST-Version: nest master @ 8dd4b52

Additional context

We have traced the error to the implementation of __rtruediv__() here:

def __rtruediv__(self, lhs):
rhs_inv = CreateParameter("constant", {"value": 1 / float(self.GetValue())})
return rhs_inv._binop("mul", lhs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    I: No breaking changePreviously written code will work as before, no one should note anything changing (aside the fix)S: HighShould be handled nextT: BugWrong statements in the code or documentation

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions