Skip to content

Commit e8f9f54

Browse files
committed
TST: Fixup test (need to use alignment in stride not offset)
1 parent 935ef6f commit e8f9f54

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

numpy/_core/tests/test_ufunc.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ def test_ufunc_types(ufunc):
27252725
@pytest.mark.parametrize('ufunc', [getattr(np, x) for x in dir(np)
27262726
if isinstance(getattr(np, x), np.ufunc)])
27272727
@np._no_nep50_warning()
2728-
def test_ufunc_noncontiguous_or_offset(ufunc):
2728+
def test_ufunc_noncontiguous(ufunc):
27292729
'''
27302730
Check that contiguous and non-contiguous calls to ufuncs
27312731
have the same results for values in range(9)
@@ -2739,15 +2739,14 @@ def test_ufunc_noncontiguous_or_offset(ufunc):
27392739
args_c = [np.empty(6, t) for t in inp]
27402740
# non contiguous (3 step)
27412741
args_n = [np.empty(18, t)[::3] for t in inp]
2742-
# If alignment != itemsize, `args_o` is (probably) not itemsize aligned
2743-
# something that SIMD code needs.
2742+
# alignment != itemsize is possible. So create an array with such
2743+
# an odd step manually.
27442744
args_o = []
27452745
for t in inp:
2746-
dtype = np.dtype(t)
2747-
start = dtype.alignment
2748-
stop = start + 6 * dtype.itemsize
2749-
a = np.empty(7 * dtype.itemsize, dtype="b")[start:stop].view(dtype)
2750-
args_o.append(a)
2746+
orig_dt = np.dtype(t)
2747+
off_dt = f"S{orig_dt.alignment}" # offset by alignment
2748+
dtype = np.dtype([("_", off_dt), ("t", orig_dt)], align=False)
2749+
args_o.append(np.empty(6, dtype="b")["t"])
27512750

27522751
for a in args_c + args_n + args_o:
27532752
a.flat = range(1,7)

0 commit comments

Comments
 (0)