21
21
22
22
from scipy .conftest import array_api_compatible
23
23
skip_xp_backends = pytest .mark .skip_xp_backends
24
+ xfail_xp_backends = pytest .mark .xfail_xp_backends
24
25
pytestmark = [array_api_compatible , pytest .mark .usefixtures ("skip_xp_backends" ),
26
+ pytest .mark .usefixtures ("xfail_xp_backends" ),
25
27
skip_xp_backends (cpu_only = True , exceptions = ['cupy' , 'jax.numpy' ]),]
26
28
27
29
@@ -179,12 +181,10 @@ def test_correlate01(self, xp):
179
181
output = ndimage .convolve1d (array , weights )
180
182
assert_array_almost_equal (output , expected )
181
183
184
+ @xfail_xp_backends ('cupy' , reason = "Differs by a factor of two?" )
182
185
@skip_xp_backends ("jax.numpy" , reasons = ["output array is read-only." ],
183
186
cpu_only = True , exceptions = ['cupy' , 'jax.numpy' ])
184
187
def test_correlate01_overlap (self , xp ):
185
- if is_cupy (xp ):
186
- pytest .xfail ("Differs by a factor of two?" )
187
-
188
188
array = xp .reshape (xp .arange (256 ), (16 , 16 ))
189
189
weights = xp .asarray ([2 ])
190
190
expected = 2 * array
@@ -334,12 +334,12 @@ def test_correlate12(self, xp):
334
334
output = ndimage .convolve (array , kernel )
335
335
assert_array_almost_equal (xp .asarray ([[6 , 8 , 9 ], [9 , 11 , 12 ]]), output )
336
336
337
+ @xfail_xp_backends (np_only = True ,
338
+ reasons = ["output=dtype is numpy-specific" ],
339
+ exceptions = ['cupy' ],)
337
340
@pytest .mark .parametrize ('dtype_array' , types )
338
341
@pytest .mark .parametrize ('dtype_kernel' , types )
339
342
def test_correlate13 (self , dtype_array , dtype_kernel , xp ):
340
- if not (is_numpy (xp ) or is_cupy (xp )):
341
- pytest .xfail ("output=dtype is numpy-specific" )
342
-
343
343
dtype_array = getattr (xp , dtype_array )
344
344
dtype_kernel = getattr (xp , dtype_kernel )
345
345
@@ -356,12 +356,12 @@ def test_correlate13(self, dtype_array, dtype_kernel, xp):
356
356
assert_array_almost_equal (xp .asarray ([[6 , 8 , 9 ], [9 , 11 , 12 ]]), output )
357
357
assert output .dtype .type == dtype_kernel
358
358
359
+ @xfail_xp_backends (np_only = True ,
360
+ reasons = ["output=dtype is numpy-specific" ],
361
+ exceptions = ['cupy' ],)
359
362
@pytest .mark .parametrize ('dtype_array' , types )
360
363
@pytest .mark .parametrize ('dtype_output' , types )
361
364
def test_correlate14 (self , dtype_array , dtype_output , xp ):
362
- if not (is_numpy (xp ) or is_cupy (xp )):
363
- pytest .xfail ("output=dtype is numpy-specific" )
364
-
365
365
dtype_array = getattr (xp , dtype_array )
366
366
dtype_output = getattr (xp , dtype_output )
367
367
@@ -378,11 +378,11 @@ def test_correlate14(self, dtype_array, dtype_output, xp):
378
378
assert_array_almost_equal (xp .asarray ([[6 , 8 , 9 ], [9 , 11 , 12 ]]), output )
379
379
assert output .dtype .type == dtype_output
380
380
381
+ @xfail_xp_backends (np_only = True ,
382
+ reasons = ["output=dtype is numpy-specific" ],
383
+ exceptions = ['cupy' ],)
381
384
@pytest .mark .parametrize ('dtype_array' , types )
382
385
def test_correlate15 (self , dtype_array , xp ):
383
- if not (is_numpy (xp ) or is_cupy (xp )):
384
- pytest .xfail ("output=dtype is numpy-specific" )
385
-
386
386
dtype_array = getattr (xp , dtype_array )
387
387
388
388
kernel = xp .asarray ([[1 , 0 ],
@@ -397,11 +397,11 @@ def test_correlate15(self, dtype_array, xp):
397
397
assert_array_almost_equal (xp .asarray ([[6 , 8 , 9 ], [9 , 11 , 12 ]]), output )
398
398
assert output .dtype .type == xp .float32
399
399
400
+ @xfail_xp_backends (np_only = True ,
401
+ reasons = ["output=dtype is numpy-specific" ],
402
+ exceptions = ['cupy' ],)
400
403
@pytest .mark .parametrize ('dtype_array' , types )
401
404
def test_correlate16 (self , dtype_array , xp ):
402
- if not (is_numpy (xp ) or is_cupy (xp )):
403
- pytest .xfail ("output=dtype is numpy-specific" )
404
-
405
405
dtype_array = getattr (xp , dtype_array )
406
406
407
407
kernel = xp .asarray ([[0.5 , 0 ],
@@ -429,11 +429,11 @@ def test_correlate17(self, xp):
429
429
output = ndimage .convolve1d (array , kernel , origin = - 1 )
430
430
assert_array_almost_equal (tcov , output )
431
431
432
+ @xfail_xp_backends (np_only = True ,
433
+ reasons = ["output=dtype is numpy-specific" ],
434
+ exceptions = ['cupy' ],)
432
435
@pytest .mark .parametrize ('dtype_array' , types )
433
436
def test_correlate18 (self , dtype_array , xp ):
434
- if not (is_numpy (xp ) or is_cupy (xp )):
435
- pytest .xfail ("output=dtype is numpy-specific" )
436
-
437
437
dtype_array = getattr (xp , dtype_array )
438
438
439
439
kernel = xp .asarray ([[1 , 0 ],
@@ -460,11 +460,11 @@ def test_correlate_mode_sequence(self, xp):
460
460
with assert_raises (RuntimeError ):
461
461
ndimage .convolve (array , kernel , mode = ['nearest' , 'reflect' ])
462
462
463
+ @xfail_xp_backends (np_only = True ,
464
+ reasons = ["output=dtype is numpy-specific" ],
465
+ exceptions = ['cupy' ],)
463
466
@pytest .mark .parametrize ('dtype_array' , types )
464
467
def test_correlate19 (self , dtype_array , xp ):
465
- if not (is_numpy (xp ) or is_cupy (xp )):
466
- pytest .xfail ("output=dtype is numpy-specific" )
467
-
468
468
dtype_array = getattr (xp , dtype_array )
469
469
470
470
kernel = xp .asarray ([[1 , 0 ],
@@ -483,12 +483,12 @@ def test_correlate19(self, dtype_array, xp):
483
483
assert_array_almost_equal (xp .asarray ([[3 , 5 , 6 ], [6 , 8 , 9 ]]), output )
484
484
assert output .dtype .type == xp .float32
485
485
486
+ @xfail_xp_backends (np_only = True ,
487
+ reasons = ["output=dtype is numpy-specific" ],
488
+ exceptions = ['cupy' ],)
486
489
@pytest .mark .parametrize ('dtype_array' , types )
487
490
@pytest .mark .parametrize ('dtype_output' , types )
488
491
def test_correlate20 (self , dtype_array , dtype_output , xp ):
489
- if not (is_numpy (xp ) or is_cupy (xp )):
490
- pytest .xfail ("output=dtype is numpy-specific" )
491
-
492
492
dtype_array = getattr (xp , dtype_array )
493
493
dtype_output = getattr (xp , dtype_output )
494
494
@@ -512,12 +512,12 @@ def test_correlate21(self, xp):
512
512
output = ndimage .convolve1d (array , weights , axis = 0 )
513
513
assert_array_almost_equal (output , expected )
514
514
515
+ @xfail_xp_backends (np_only = True ,
516
+ reasons = ["output=dtype is numpy-specific" ],
517
+ exceptions = ['cupy' ],)
515
518
@pytest .mark .parametrize ('dtype_array' , types )
516
519
@pytest .mark .parametrize ('dtype_output' , types )
517
520
def test_correlate22 (self , dtype_array , dtype_output , xp ):
518
- if not (is_numpy (xp ) or is_cupy (xp )):
519
- pytest .xfail ("output=dtype is numpy-specific" )
520
-
521
521
dtype_array = getattr (xp , dtype_array )
522
522
dtype_output = getattr (xp , dtype_output )
523
523
@@ -603,15 +603,14 @@ def test_correlate26(self, xp):
603
603
y = ndimage .correlate1d (xp .ones (1 ), xp .ones (5 ), mode = 'mirror' )
604
604
xp_assert_equal (y , xp .asarray ([5. ]))
605
605
606
+ @xfail_xp_backends (np_only = True ,
607
+ reasons = ["output=dtype is numpy-specific" ],
608
+ exceptions = ['cupy' ],)
606
609
@pytest .mark .parametrize ('dtype_kernel' , complex_types )
607
610
@pytest .mark .parametrize ('dtype_input' , types )
608
611
@pytest .mark .parametrize ('dtype_output' , complex_types )
609
612
def test_correlate_complex_kernel (self , dtype_input , dtype_kernel ,
610
613
dtype_output , xp ):
611
- if not (is_numpy (xp ) or is_cupy (xp )):
612
- # XXX: the issue is in _validate_complex, _correlate_complex
613
- pytest .xfail ("output=dtype are numpy-specific" )
614
-
615
614
dtype_input = getattr (xp , dtype_input )
616
615
dtype_kernel = getattr (xp , dtype_kernel )
617
616
dtype_output = getattr (xp , dtype_output )
@@ -622,6 +621,9 @@ def test_correlate_complex_kernel(self, dtype_input, dtype_kernel,
622
621
[4 , 5 , 6 ]], dtype = dtype_input )
623
622
self ._validate_complex (xp , array , kernel , dtype_output )
624
623
624
+ @xfail_xp_backends (np_only = True ,
625
+ reasons = ["output=dtype is numpy-specific" ],
626
+ exceptions = ['cupy' ],)
625
627
@pytest .mark .parametrize ('dtype_kernel' , complex_types )
626
628
@pytest .mark .parametrize ('dtype_input' , types )
627
629
@pytest .mark .parametrize ('dtype_output' , complex_types )
@@ -634,8 +636,6 @@ def test_correlate_complex_kernel_cval(self, dtype_input, dtype_kernel,
634
636
635
637
if is_cupy (xp ) and mode == 'grid-constant' :
636
638
pytest .xfail ('https://github.com/cupy/cupy/issues/8404' )
637
- elif not is_numpy (xp ):
638
- pytest .xfail ("output= arrays are numpy-specific" )
639
639
640
640
# test use of non-zero cval with complex inputs
641
641
# also verifies that mode 'grid-constant' does not segfault
@@ -646,16 +646,14 @@ def test_correlate_complex_kernel_cval(self, dtype_input, dtype_kernel,
646
646
self ._validate_complex (xp , array , kernel , dtype_output , mode = mode ,
647
647
cval = 5.0 )
648
648
649
+ @xfail_xp_backends ('cupy' , reasons = ["cupy/cupy#8405" ])
649
650
@pytest .mark .parametrize ('dtype_kernel' , complex_types )
650
651
@pytest .mark .parametrize ('dtype_input' , types )
651
652
def test_correlate_complex_kernel_invalid_cval (self , dtype_input ,
652
653
dtype_kernel , xp ):
653
654
dtype_input = getattr (xp , dtype_input )
654
655
dtype_kernel = getattr (xp , dtype_kernel )
655
656
656
- if is_cupy (xp ):
657
- pytest .xfail ("https://github.com/cupy/cupy/issues/8405" )
658
-
659
657
# cannot give complex cval with a real image
660
658
kernel = xp .asarray ([[1 , 0 ],
661
659
[0 , 1 + 1j ]], dtype = dtype_kernel )
@@ -726,7 +724,10 @@ def test_correlate1d_complex_input(self, dtype_input, dtype_kernel,
726
724
array = xp .asarray ([1 , 2j , 3 , 1 + 4j , 5 , 6j ], dtype = dtype_input )
727
725
self ._validate_complex (xp , array , kernel , dtype_output )
728
726
729
- @skip_xp_backends (np_only = True , reasons = ['output=dtype is numpy-specific' ])
727
+ @xfail_xp_backends ('cupy' , reasons = ["cupy/cupy#8405" ])
728
+ @skip_xp_backends (np_only = True ,
729
+ reasons = ['output=dtype is numpy-specific' ],
730
+ exceptions = ['cupy' ])
730
731
@pytest .mark .parametrize ('dtype_kernel' , types )
731
732
@pytest .mark .parametrize ('dtype_input' , complex_types )
732
733
@pytest .mark .parametrize ('dtype_output' , complex_types )
@@ -736,9 +737,6 @@ def test_correlate1d_complex_input_cval(self, dtype_input, dtype_kernel,
736
737
dtype_kernel = getattr (xp , dtype_kernel )
737
738
dtype_output = getattr (xp , dtype_output )
738
739
739
- if is_cupy (xp ):
740
- pytest .xfail ("https://github.com/cupy/cupy/issues/8405" )
741
-
742
740
kernel = xp .asarray ([1 , 0 , 1 ], dtype = dtype_kernel )
743
741
array = xp .asarray ([1 , 2j , 3 , 1 + 4j , 5 , 6j ], dtype = dtype_input )
744
742
self ._validate_complex (xp , array , kernel , dtype_output , mode = 'constant' ,
@@ -757,15 +755,14 @@ def test_correlate_complex_input_and_kernel(self, dtype, dtype_output, xp):
757
755
[1 + 4j , 5 , 6j ]], dtype = dtype )
758
756
self ._validate_complex (xp , array , kernel , dtype_output )
759
757
758
+ @xfail_xp_backends ('cupy' , reasons = ["cupy/cupy#8405" ])
759
+ @skip_xp_backends (np_only = True ,
760
+ reasons = ["output=dtype is numpy-specific" ],
761
+ exceptions = ['cupy' ],)
760
762
@pytest .mark .parametrize ('dtype' , complex_types )
761
763
@pytest .mark .parametrize ('dtype_output' , complex_types )
762
764
def test_correlate_complex_input_and_kernel_cval (self , dtype ,
763
765
dtype_output , xp ):
764
- if not is_numpy (xp ):
765
- pytest .xfail ("output=dtype is numpy-specific" )
766
- elif is_cupy (xp ):
767
- pytest .xfail ("https://github.com/cupy/cupy/issues/8405" )
768
-
769
766
dtype = getattr (xp , dtype )
770
767
dtype_output = getattr (xp , dtype_output )
771
768
0 commit comments