Draft: py-pynn: add patch for numpy@1.24:
1 unresolved thread
1 unresolved thread
Merge request reports
Activity
Filter activity
added 5 commits
-
14bc208f...d86c095c - 4 commits from branch
spack_v0.21.1
- 33bc2aef - py-pynn: add patch for numpy@1:24:
-
14bc208f...d86c095c - 4 commits from branch
Hi @adavison,
During our last Spack update, that included a change from
py-numpy@1.23.5
topy-numpy@1.24.4
in the env, one of the pyNN tests for the brian2 backend failed:=================================== FAILURES =================================== _______________________ TestProjection.test_partitioning _______________________ self = <unittests.test_brian.TestProjection testMethod=test_partitioning> def test_partitioning(self): p1 = sim.Population(5, sim.IF_cond_exp()) p2 = sim.Population(7, sim.IF_cond_exp()) a = p1 + p2[1:4] # [0 2 3 4 5][x 1 2 3 x x x] prj = sim.Projection(a, a, MockConnector(), synapse_type=self.syn) presynaptic_indices = np.array([0, 3, 4, 6, 7]) > partitions = prj._partition(presynaptic_indices) test/unittests/test_brian.py:38: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = Projection("assembly67→assembly67"), indices = array([0, 3, 4, 6, 7]) def _partition(self, indices): """ partition indices, in case of Assemblies """ if isinstance(self.pre, common.Assembly): boundaries = np.cumsum([0] + [p.size for p in self.pre.populations]) assert indices.max() < boundaries[-1] > partitions = np.split(indices, np.searchsorted( indices, boundaries[1:-1])) - boundaries[:-1] E ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part. /mnt/spack_v0.21.1/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-10.3.0/py-pynn-0.11.0-63gwwjhiu5vr2d7gz7kbzwknl4basfsd/lib/python3.8/site-packages/pyNN/brian2/projections.py:172: ValueError
From what I can see, this is because starting from
py-numpy@1.24
,Ragged array creation will now always raise a ValueError unless dtype=object is passed.
(see here)In
py-numpy@1.23.5
there was already a warning:VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
With this small patch, all tests are passing. Do you think it's enough? if something else is needed please let me know
I think this patch is fine, but on reflection the original code is anyway not very easy to understand. I've fixed this a slightly different way, and released PyNN 0.12.2
Edited by Andrew Davison