@@ -2725,7 +2725,7 @@ def test_ufunc_types(ufunc):
2725
2725
@pytest .mark .parametrize ('ufunc' , [getattr (np , x ) for x in dir (np )
2726
2726
if isinstance (getattr (np , x ), np .ufunc )])
2727
2727
@np ._no_nep50_warning ()
2728
- def test_ufunc_noncontiguous_or_offset (ufunc ):
2728
+ def test_ufunc_noncontiguous (ufunc ):
2729
2729
'''
2730
2730
Check that contiguous and non-contiguous calls to ufuncs
2731
2731
have the same results for values in range(9)
@@ -2739,15 +2739,14 @@ def test_ufunc_noncontiguous_or_offset(ufunc):
2739
2739
args_c = [np .empty (6 , t ) for t in inp ]
2740
2740
# non contiguous (3 step)
2741
2741
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 .
2744
2744
args_o = []
2745
2745
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" ])
2751
2750
2752
2751
for a in args_c + args_n + args_o :
2753
2752
a .flat = range (1 ,7 )
0 commit comments