Skip to content

Commit

Permalink
Fix an error in the synapse generation with numpy, if "int" is used a…
Browse files Browse the repository at this point in the history
…s part of the condition

Fixes #835
  • Loading branch information
mstimberg committed Apr 25, 2017
1 parent 9501e37 commit c323a6f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -52,7 +52,7 @@ except:
# however it can't therefore give a jump size of 0, but we could have rand()<p for
# for the first array. Therefore we set start to the actual first place we'd like
# to see a hit minus one, allowing us to have start as the first hit.
jump = _numpy.array(_numpy.ceil(_numpy.log(_np_rand(m))*pconst), dtype=int)
jump = _numpy.array(_numpy.ceil(_numpy.log(_np_rand(m))*pconst), dtype=_numpy.int32)
jump[0] += start-1
samples = _numpy.cumsum(jump)
all_samples.append(samples)
Expand Down
10 changes: 10 additions & 0 deletions brian2/tests/test_synapses.py
Expand Up @@ -312,6 +312,16 @@ def test_connection_random_with_condition():
S17 = Synapses(G, G, 'w:1', 'v+=w')
S17.connect('i!=j', p='j*0.1')

# Forces the use of the "jump algorithm"
big_group = NeuronGroup(10000, 'v: 1', threshold='False')
S18 = Synapses(big_group, big_group, 'w:1', 'v+=w')
S18.connect('i != j', p=0.001)

# See github issue #835 -- this failed when using numpy
S19 = Synapses(big_group, big_group, 'w:1', 'v+=w')
S19.connect('i < int(N_post*0.5)', p=0.001)


with catch_logs() as _: # Ignore warnings about empty synapses
run(0*ms) # for standalone

Expand Down

0 comments on commit c323a6f

Please sign in to comment.