Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List with homogeneous array-like parameter entries only work for the corresponding default parameter type #709

Open
AvidusMauch opened this issue Feb 16, 2021 · 2 comments
Milestone

Comments

@AvidusMauch
Copy link

Lists of array-like parameters, e.g. spike_times in SpikeSourceArray, with homogeneous entries will be simplified and converted to ArrayParameter if they are not the same type as the corresponding default type (Sequence for spike_times).

Minimal example:

#!/usr/bin/env python

import pyNN.mock as sim
import numpy
from pyNN.parameters import Sequence

sim.setup()

spike_times = [1, 2, 3]
spike_sequence = [Sequence(spike_times)] * 2
spike_numpy = [numpy.array(spike_times)] * 2
spike_plain = [spike_times] * 2
pop_sequence = sim.Population(2, sim.SpikeSourceArray(spike_times=spike_sequence))
pop_numpy = sim.Population(2, sim.SpikeSourceArray(spike_times=spike_numpy))
pop_plain = sim.Population(2, sim.SpikeSourceArray(spike_times=spike_plain))

# works
pop_sequence.get("spike_times")
# fails
pop_numpy.get("spike_times")
pop_plain.get("spike_times")

sim.end()
@AvidusMauch
Copy link
Author

This can be workaroundend by changing the default type from Seqeuence to ArrayParameter

@apdavison apdavison added this to the 0.10.1 milestone Dec 1, 2021
@apdavison
Copy link
Member

I may be misunderstanding what the problem is, but the problem you're describing is why the Sequence class was introduced - to avoid confusion over how to interpret arrays/lists of arrays.

Although for simple cases, plain NumPy arrays or lists do work for setting spike times, it is safest to always use Sequence.

@apdavison apdavison modified the milestones: 0.10.1, 0.10.2 Oct 13, 2022
@apdavison apdavison modified the milestones: 0.10.2, 0.11.0 Feb 5, 2023
@apdavison apdavison modified the milestones: 0.11.0, 0.13.0 Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants