@@ -558,7 +558,7 @@ def test28_reference_internal():
558558 assert msg in str (excinfo .value )
559559
560560@needs_numpy
561- def test29_force_contig_pytorch ():
561+ def test29_force_contig_numpy ():
562562 a = np .array ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]])
563563 b = t .make_contig (a )
564564 assert b is a
@@ -656,3 +656,28 @@ def __dlpack__(self):
656656
657657 arr = DLPackWrapper (np .zeros ((1 )))
658658 assert t .check (arr )
659+
660+ @needs_numpy
661+ def test37_noninteger_stride ():
662+ a = np .array ([[1 , 2 , 3 , 4 , 0 , 0 ], [5 , 6 , 7 , 8 , 0 , 0 ]], dtype = np .float32 )
663+ s = a [:, 0 :4 ] # slice
664+ t .pass_float32 (s )
665+ assert t .get_stride (s , 0 ) == 6 ;
666+ assert t .get_stride (s , 1 ) == 1 ;
667+ v = s .view (np .complex64 )
668+ t .pass_complex64 (v )
669+ assert t .get_stride (v , 0 ) == 3 ;
670+ assert t .get_stride (v , 1 ) == 1 ;
671+
672+ a = np .array ([[1 , 2 , 3 , 4 , 0 ], [5 , 6 , 7 , 8 , 0 ]], dtype = np .float32 )
673+ s = a [:, 0 :4 ] # slice
674+ t .pass_float32 (s )
675+ assert t .get_stride (s , 0 ) == 5 ;
676+ assert t .get_stride (s , 1 ) == 1 ;
677+ v = s .view (np .complex64 )
678+ with pytest .raises (TypeError ) as excinfo :
679+ t .pass_complex64 (v )
680+ assert 'incompatible function arguments' in str (excinfo .value )
681+ with pytest .raises (TypeError ) as excinfo :
682+ t .get_stride (v , 0 );
683+ assert 'incompatible function arguments' in str (excinfo .value )
0 commit comments