Skip to content

Commit

Permalink
Regression test for issue 2637
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolossus committed Aug 9, 2023
1 parent 300fa23 commit 83220ea
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions testsuite/pytests/sli2py_regressions/test_issue_2637.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
#
# test_issue_2637.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

"""
Regression test for Issue #2637 (GitHub).
This set of tests ensures that a ``NodeCollection`` can be sliced with
a Python ``list`` of NumPy integers.
"""

import numpy as np
import pytest

import nest


@pytest.mark.parametrize("dtype", [int, np.int32, np.int64])
def test_nc_slice_list_of_numpy_ints(dtype):
"""
Ensure that a list of NumPy integers can slice a ``NodeCollection``.
"""

nc = nest.Create("iaf_psc_alpha", 2)
slice_arr = np.array([0, 1], dtype=dtype)
slice_lst = list(slice_arr)
nc_slice = nc[slice_lst]

0 comments on commit 83220ea

Please sign in to comment.