Skip to content
Snippets Groups Projects

Draft: py-pynn: add patch for numpy@1.24:

Closed Eleni Mathioulaki requested to merge spack_v0.21.1_fix_pynn_brian2_test into spack_v0.21.1
1 unresolved thread

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Eleni Mathioulaki changed title from Draft: py-pynn: add patch for numpy@1:24: to Draft: py-pynn: add patch for numpy@1.24:

    changed title from Draft: py-pynn: add patch for numpy@1:24: to Draft: py-pynn: add patch for numpy@1.24:

  • Eleni Mathioulaki added 5 commits

    added 5 commits

    Compare with previous version

  • Hi @adavison,

    During our last Spack update, that included a change from py-numpy@1.23.5 to py-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 :slight_smile:

Please register or sign in to reply