1- import sys
21import unittest
32
43import numpy
54import pytest
6- from dpctl import select_default_device
75
86import dpnp as cupy
97from tests .helper import has_support_aspect64
108from tests .third_party .cupy import testing
119
1210
11+ @pytest .mark .skip ("dpnp.corrcoef() is not implemented yet" )
1312class TestCorrcoef (unittest .TestCase ):
13+
1414 @testing .for_all_dtypes ()
1515 @testing .numpy_cupy_allclose ()
1616 def test_corrcoef (self , xp , dtype ):
@@ -37,10 +37,16 @@ def test_corrcoef_rowvar(self, xp, dtype):
3737 y = testing .shaped_arange ((2 , 3 ), xp , dtype )
3838 return xp .corrcoef (a , y = y , rowvar = False )
3939
40+ @testing .with_requires ("numpy>=1.20" )
41+ @testing .for_all_dtypes ()
42+ @testing .numpy_cupy_allclose (accept_error = True )
43+ def test_corrcoef_dtype (self , xp , dtype ):
44+ a = testing .shaped_arange ((2 , 3 ), xp , dtype )
45+ y = testing .shaped_arange ((2 , 3 ), xp , dtype )
46+ return xp .corrcoef (a , y = y , dtype = dtype )
47+
4048
4149class TestCov (unittest .TestCase ):
42- # resulting dtype will differ with numpy if no fp64 support by a default device
43- _has_fp64 = select_default_device ().has_aspect_fp64
4450
4551 def generate_input (self , a_shape , y_shape , xp , dtype ):
4652 a = testing .shaped_arange (a_shape , xp , dtype )
@@ -50,7 +56,9 @@ def generate_input(self, a_shape, y_shape, xp, dtype):
5056 return a , y
5157
5258 @testing .for_all_dtypes ()
53- @testing .numpy_cupy_allclose (type_check = _has_fp64 , accept_error = True )
59+ @testing .numpy_cupy_allclose (
60+ type_check = has_support_aspect64 (), accept_error = True
61+ )
5462 def check (
5563 self ,
5664 a_shape ,
@@ -153,6 +161,7 @@ def test_cov_empty(self):
153161)
154162@pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
155163class TestCorrelateShapeCombination (unittest .TestCase ):
164+
156165 @testing .for_all_dtypes (no_float16 = True )
157166 @testing .numpy_cupy_allclose (rtol = 1e-4 )
158167 def test_correlate (self , xp , dtype ):
@@ -161,34 +170,36 @@ def test_correlate(self, xp, dtype):
161170 return xp .correlate (a , b , mode = self .mode )
162171
163172
164- @testing . parameterize ( * testing . product ({ "mode" : ["valid" , "full" , "same" ]}) )
173+ @pytest . mark . parametrize ( "mode" , ["valid" , "full" , "same" ])
165174@pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
166- class TestCorrelate (unittest .TestCase ):
175+ class TestCorrelate :
176+
167177 @testing .for_all_dtypes ()
168178 @testing .numpy_cupy_allclose (rtol = 1e-5 )
169- def test_correlate_non_contiguous (self , xp , dtype ):
179+ def test_correlate_non_contiguous (self , xp , dtype , mode ):
170180 a = testing .shaped_arange ((300 ,), xp , dtype )
171181 b = testing .shaped_arange ((100 ,), xp , dtype )
172- return xp .correlate (a [::200 ], b [10 ::70 ], mode = self . mode )
182+ return xp .correlate (a [::200 ], b [10 ::70 ], mode = mode )
173183
174184 @testing .for_all_dtypes (no_float16 = True )
175185 @testing .numpy_cupy_allclose (rtol = 1e-4 )
176- def test_correlate_large_non_contiguous (self , xp , dtype ):
186+ def test_correlate_large_non_contiguous (self , xp , dtype , mode ):
177187 a = testing .shaped_arange ((10000 ,), xp , dtype )
178188 b = testing .shaped_arange ((1000 ,), xp , dtype )
179- return xp .correlate (a [200 ::], b [10 ::700 ], mode = self . mode )
189+ return xp .correlate (a [200 ::], b [10 ::700 ], mode = mode )
180190
181191 @testing .for_all_dtypes_combination (names = ["dtype1" , "dtype2" ])
182192 @testing .numpy_cupy_allclose (rtol = 1e-2 , type_check = has_support_aspect64 ())
183- def test_correlate_diff_types (self , xp , dtype1 , dtype2 ):
193+ def test_correlate_diff_types (self , xp , dtype1 , dtype2 , mode ):
184194 a = testing .shaped_random ((200 ,), xp , dtype1 )
185195 b = testing .shaped_random ((100 ,), xp , dtype2 )
186- return xp .correlate (a , b , mode = self . mode )
196+ return xp .correlate (a , b , mode = mode )
187197
188198
189199@testing .parameterize (* testing .product ({"mode" : ["valid" , "same" , "full" ]}))
190200@pytest .mark .usefixtures ("allow_fall_back_on_numpy" )
191201class TestCorrelateInvalid (unittest .TestCase ):
202+
192203 @testing .with_requires ("numpy>=1.18" )
193204 @testing .for_all_dtypes ()
194205 def test_correlate_empty (self , dtype ):
0 commit comments