Skip to content

Commit 6562250

Browse files
Add unit test to demonstrate #7451 failing case.
As title.
1 parent e617b39 commit 6562250

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎numba/tests/test_np_functions.py‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4461,14 +4461,19 @@ def test_take_along_axis_broadcasting(self):
44614461
arr = np.ones((3, 4, 1))
44624462
ai = np.ones((1, 2, 5), dtype=np.intp)
44634463

4464-
@njit
4465-
def check(a, i):
4466-
return np.take_along_axis(a, i, axis=1)
4464+
def gen(axis):
4465+
@njit
4466+
def impl(a, i):
4467+
return np.take_along_axis(a, i, axis)
4468+
return impl
44674469

4468-
expected = check.py_func(arr, ai)
4469-
actual = check(arr, ai)
4470-
self.assertPreciseEqual(expected, actual)
4471-
self.assertEqual(actual.shape, (3, 2, 5))
4470+
# Check same axis but expressed as positive/negative value
4471+
for i in (1, -2):
4472+
check = gen(i)
4473+
expected = check.py_func(arr, ai)
4474+
actual = check(arr, ai)
4475+
self.assertPreciseEqual(expected, actual)
4476+
self.assertEqual(actual.shape, (3, 2, 5))
44724477

44734478
def test_take_along_axis_exceptions(self):
44744479
arr2d = np.arange(8).reshape(2, 4)

0 commit comments

Comments
 (0)