@@ -610,25 +610,36 @@ def test_corrcoef_scalar(self):
610
610
assert_dtype_allclose (result , expected )
611
611
612
612
613
- @pytest .mark .parametrize (
614
- "dtype" , get_all_dtypes (no_bool = True , no_none = True , no_complex = True )
615
- )
616
- def test_cov_rowvar (dtype ):
617
- a = dpnp .array ([[0 , 2 ], [1 , 1 ], [2 , 0 ]], dtype = dtype )
618
- b = numpy .array ([[0 , 2 ], [1 , 1 ], [2 , 0 ]], dtype = dtype )
619
- assert_allclose (dpnp .cov (a .T ), dpnp .cov (a , rowvar = False ))
620
- assert_allclose (numpy .cov (b , rowvar = False ), dpnp .cov (a , rowvar = False ))
613
+ class TestCov :
614
+ @pytest .mark .parametrize (
615
+ "dtype" , get_all_dtypes (no_bool = True , no_none = True , no_complex = True )
616
+ )
617
+ def test_false_rowvar (self , dtype ):
618
+ a = numpy .array ([[0 , 2 ], [1 , 1 ], [2 , 0 ]], dtype = dtype )
619
+ ia = dpnp .array (a )
621
620
621
+ assert_allclose (dpnp .cov (ia .T ), dpnp .cov (ia , rowvar = False ))
622
+ assert_allclose (dpnp .cov (ia , rowvar = False ), numpy .cov (a , rowvar = False ))
622
623
623
- # numpy 2.2 properly transposes 2d array when rowvar=False
624
- @with_requires ("numpy>=2.2" )
625
- @pytest .mark .parametrize (
626
- "dtype" , get_all_dtypes (no_bool = True , no_none = True , no_complex = True )
627
- )
628
- def test_cov_1D_rowvar (dtype ):
629
- a = dpnp .array ([[0 , 1 , 2 ]], dtype = dtype )
630
- b = numpy .array ([[0 , 1 , 2 ]], dtype = dtype )
631
- assert_allclose (numpy .cov (b , rowvar = False ), dpnp .cov (a , rowvar = False ))
624
+ # numpy 2.2 properly transposes 2d array when rowvar=False
625
+ @with_requires ("numpy>=2.2" )
626
+ def test_1D_false_rowvar (self ):
627
+ a = numpy .array ([0 , 1 , 2 ])
628
+ ia = dpnp .array (a )
629
+
630
+ expected = numpy .cov (a , rowvar = False )
631
+ result = dpnp .cov (ia , rowvar = False )
632
+ assert_allclose (expected , result )
633
+
634
+ # numpy 2.2 properly transposes 2d array when rowvar=False
635
+ @with_requires ("numpy>=2.2" )
636
+ def test_2D_rowvar (self ):
637
+ a = numpy .ones ((3 , 1 ))
638
+ ia = dpnp .array (a )
639
+
640
+ expected = numpy .cov (a , ddof = 0 , rowvar = True )
641
+ result = dpnp .cov (ia , ddof = 0 , rowvar = True )
642
+ assert_allclose (expected , result )
632
643
633
644
634
645
@pytest .mark .parametrize ("axis" , [None , 0 , 1 ])
0 commit comments