leaflabs / WaspNet.jl

GNU General Public License v2.0
13 stars 6 forks source link

update! function raises warning #7

Closed PikaPei closed 3 years ago

PikaPei commented 4 years ago

Hello, nice project! I followed the example in the documentation but something wrong happened. Here are my codes.

using WaspNet
neuronLIF = WaspNet.LIF(8., 10.E2, 30., 40., -55., -55., 0.)
update!(neuronLIF, 0., 0.001, 0)

It raised warning: Warning: Neurons should use update, not update! function And the result of println(neuronLIF.state) is -55.0.

SBuercklin commented 4 years ago

The neuron implementation was changed from using an array in the neuron to store the state dynamically. Now, neurons are stored in immutable structs with non-array-fields with a new neuron constructed on every iteration with an updated struct.

This means that the bang-mutating notation is incorrect; update!(neuronLIF, 0., 0.001, 0) no longer updates neuronLIF in place because neuronLIF and its fields are immutable. The correct call to replace it is neuronLIF = update(neuronLIF, 0., 0.001, 0)

I forgot to update the docs to reflect this. I'll update the docs this weekend and close the issue when that's complete.

PikaPei commented 3 years ago

Sorry, I just noticed the release notes. Thanks for your kind reply and update!

SBuercklin commented 3 years ago

@PikaPei I've updated the docs and the gh-pages branch so the online docs should reflect the correct syntax.

Thanks for pointing this out!