@@ -404,32 +404,32 @@ def test_none(self, args: tuple[tuple[float | None, ...], ...]):
404
404
class TestCov :
405
405
def test_basic (self , xp : ModuleType ):
406
406
xp_assert_close (
407
- cov (xp .asarray ([[0 , 2 ], [1 , 1 ], [2 , 0 ]]).T ),
407
+ cov (xp .asarray ([[0 , 2 ], [1 , 1 ], [2 , 0 ]], dtype = xp . float64 ).T ),
408
408
xp .asarray ([[1.0 , - 1.0 ], [- 1.0 , 1.0 ]], dtype = xp .float64 ),
409
409
)
410
410
411
411
def test_complex (self , xp : ModuleType ):
412
- actual = cov (xp .asarray ([[1 , 2 , 3 ], [1j , 2j , 3j ]]))
412
+ actual = cov (xp .asarray ([[1 , 2 , 3 ], [1j , 2j , 3j ]], dtype = xp . complex128 ))
413
413
expect = xp .asarray ([[1.0 , - 1.0j ], [1.0j , 1.0 ]], dtype = xp .complex128 )
414
414
xp_assert_close (actual , expect )
415
415
416
416
@pytest .mark .xfail_xp_backend (Backend .SPARSE , reason = "sparse#877" )
417
417
def test_empty (self , xp : ModuleType ):
418
418
with warnings .catch_warnings (record = True ):
419
419
warnings .simplefilter ("always" , RuntimeWarning )
420
- xp_assert_equal (cov (xp .asarray ([])), xp .asarray (xp .nan , dtype = xp .float64 ))
420
+ xp_assert_equal (cov (xp .asarray ([], dtype = xp . float64 )), xp .asarray (xp .nan , dtype = xp .float64 ))
421
421
xp_assert_equal (
422
- cov (xp .reshape (xp .asarray ([]), (0 , 2 ))),
422
+ cov (xp .reshape (xp .asarray ([], dtype = xp . float64 ), (0 , 2 ))),
423
423
xp .reshape (xp .asarray ([], dtype = xp .float64 ), (0 , 0 )),
424
424
)
425
425
xp_assert_equal (
426
- cov (xp .reshape (xp .asarray ([]), (2 , 0 ))),
426
+ cov (xp .reshape (xp .asarray ([], dtype = xp . float64 ), (2 , 0 ))),
427
427
xp .asarray ([[xp .nan , xp .nan ], [xp .nan , xp .nan ]], dtype = xp .float64 ),
428
428
)
429
429
430
430
def test_combination (self , xp : ModuleType ):
431
- x = xp .asarray ([- 2.1 , - 1 , 4.3 ])
432
- y = xp .asarray ([3 , 1.1 , 0.12 ])
431
+ x = xp .asarray ([- 2.1 , - 1 , 4.3 ], dtype = xp . float64 )
432
+ y = xp .asarray ([3 , 1.1 , 0.12 ], dtype = xp . float64 )
433
433
X = xp .stack ((x , y ), axis = 0 )
434
434
desired = xp .asarray ([[11.71 , - 4.286 ], [- 4.286 , 2.144133 ]], dtype = xp .float64 )
435
435
xp_assert_close (cov (X ), desired , rtol = 1e-6 )
@@ -443,7 +443,7 @@ def test_device(self, xp: ModuleType, device: Device):
443
443
@pytest .mark .skip_xp_backend (Backend .NUMPY_READONLY , reason = "xp=xp" )
444
444
def test_xp (self , xp : ModuleType ):
445
445
xp_assert_close (
446
- cov (xp .asarray ([[0.0 , 2.0 ], [1.0 , 1.0 ], [2.0 , 0.0 ]]).T , xp = xp ),
446
+ cov (xp .asarray ([[0.0 , 2.0 ], [1.0 , 1.0 ], [2.0 , 0.0 ]], dtype = xp . float64 ).T , xp = xp ),
447
447
xp .asarray ([[1.0 , - 1.0 ], [- 1.0 , 1.0 ]], dtype = xp .float64 ),
448
448
)
449
449
0 commit comments