Ticket #108 (closed defect: fixed)

Opened 3 weeks ago

Last modified 3 weeks ago

Population.tset() does not properly handle arrays of arrays

Reported by: mschmucker Assigned to: apdavison
Priority: major Milestone: Release 0.5.0
Component: neuron Version: trunk
Keywords: Cc:

Description

In neuron, Population.tset() fails to set a parameter in a population with an array of arrays. See the example below: Assigning random spike times to a Population of SpikeSourceArray?.

>>> st = numpy.random.random((10,10))
>>> stimpop = Population(10, SpikeSourceArray)
>>> stimpop.tset('spike_times', st)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/micha/mypython//lib64/python2.5/site-packages/pyNN/neuron/__init__.py", line 882, in tset
    values = numpy.reshape(value_array, (self.dim, value_array.size/self.cell.size))
  File "/usr/lib64/python2.5/site-packages/numpy/core/fromnumeric.py", line 116, in reshape
    return reshape(newshape, order=order)

Find attached a patch. It fixes two things: 1. an invalid tuple passed to reshape (line 882) 2. a missing "axis" keyword in array.take, causing the array to be flattened (line 886)

Attachments

fix_tset.diff (1.4 kB) - added by mschmucker on 08/01/08 15:02:24.
a patch fixing this bug

Change History

08/01/08 15:02:24 changed by mschmucker

  • attachment fix_tset.diff added.

a patch fixing this bug

08/01/08 15:47:50 changed by apdavison

  • status changed from new to assigned.
  • version set to trunk.
  • milestone set to Release 0.5.0.

08/01/08 16:41:59 changed by apdavison

  • status changed from assigned to closed.
  • resolution set to fixed.

Fixed in r431. Modified Michael's patch, which only worked for 1D Populations. The value_array for a Population of shape (5,6) should have shape (5,6,X), and should be reshaped to have shape (30,X).