Dear Julien,
I encountered results that I could not figure out at all in a model simulation. In an attempt to build a minimal example to reproduce what I thought could boil down to an indexing issue with PopulationViews, I found something quite strange.
I am using ANNarchy 4.8.2.5
from ANNarchy import *
import numpy as np
LeakyIntegratorNeuron = Neuron(
parameters = """
tau = 10.0
baseline = -0.2
""",
equations = """
tau * dmp/dt + mp = baseline + sum(exc)
r = pos(mp)
""")
neurons = Population(geometry=10, neuron=LeakyIntegratorNeuron, name='neurons')
print(neurons.ranks)
popview_post = neurons.neuron(7) + neurons.neuron(8) + neurons.neuron(9)
print(popview_post.ranks)
popview_post = neurons[7:10]
print(popview_post.ranks)
This code prints these ranks:
[0 1 2 3 4 5 6 7 8 9]
[8 9 7]
[7 8 9]
I believe the issue arises from the use of a set when adding PopulationViews
def __add__(self, other):
"""Allows to join two PopulationViews if they have the same population."""
from ANNarchy.core.Neuron import IndividualNeuron
if other.population == self.population:
if isinstance(other, IndividualNeuron):
tmp = list(set(list(self.ranks) + [other.rank]))
return PopulationView(self.population, np.array(tmp))
elif isinstance(other, PopulationView):
tmp = list(set(list(self.ranks) + list(other.ranks)))
return PopulationView(self.population, np.array(tmp))
else:
Messages._error("can only add two PopulationViews of the same population.")
But I'm wondering if that can be true. It was really unexpected behaviour for me, especially since according to the examples in the docs I was expecting both methods to produce an equivalent result.
I am using two PopulationViews of the same population to define pre and post of a Projection and was not getting the results I expected.
Thank you so much for taking a look.
Cheers!
Emma