Skip to content

Commit 64e8c85

Browse files
committed
Update statistics_tests/test_correlation.py
1 parent aba974a commit 64e8c85

File tree

3 files changed

+24
-99
lines changed

3 files changed

+24
-99
lines changed

tests/skipped_tests.tbl

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -309,46 +309,3 @@ tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_bo
309309
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_bound_2
310310
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_goodness_of_fit
311311
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_goodness_of_fit_2
312-
313-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef
314-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_diag_exception
315-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_rowvar
316-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_y
317-
318-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[linear]
319-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[lower]
320-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[higher]
321-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[midpoint]
322-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[linear]
323-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[lower]
324-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[higher]
325-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[midpoint]
326-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[linear]
327-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[lower]
328-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[higher]
329-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[midpoint]
330-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[linear]
331-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[lower]
332-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[higher]
333-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[midpoint]
334-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[linear]
335-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[lower]
336-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[higher]
337-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[midpoint]
338-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[linear]
339-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[lower]
340-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[higher]
341-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[midpoint]
342-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[linear]
343-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[lower]
344-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[higher]
345-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[midpoint]
346-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[linear]
347-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[lower]
348-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[higher]
349-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[midpoint]
350-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[linear]
351-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[lower]
352-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[higher]
353-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[midpoint]
354-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_unxpected_method

tests/skipped_tests_gpu.tbl

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -319,46 +319,3 @@ tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_bo
319319
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_bound_2
320320
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_goodness_of_fit
321321
tests/third_party/cupy/random_tests/test_sample.py::TestRandomIntegers2::test_goodness_of_fit_2
322-
323-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef
324-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_diag_exception
325-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_rowvar
326-
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCorrcoef::test_corrcoef_y
327-
328-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[linear]
329-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[lower]
330-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[higher]
331-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_defaults[midpoint]
332-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[linear]
333-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[lower]
334-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[higher]
335-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_q_list[midpoint]
336-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[linear]
337-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[lower]
338-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[higher]
339-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_no_axis[midpoint]
340-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[linear]
341-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[lower]
342-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[higher]
343-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_neg_axis[midpoint]
344-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[linear]
345-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[lower]
346-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[higher]
347-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_tuple_axis[midpoint]
348-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[linear]
349-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[lower]
350-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[higher]
351-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_scalar_q[midpoint]
352-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[linear]
353-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[lower]
354-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[higher]
355-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_keepdims[midpoint]
356-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[linear]
357-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[lower]
358-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[higher]
359-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_out[midpoint]
360-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[linear]
361-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[lower]
362-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[higher]
363-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_bad_q[midpoint]
364-
tests/third_party/cupy/statistics_tests/test_order.py::TestOrder::test_percentile_unxpected_method

tests/third_party/cupy/statistics_tests/test_correlation.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import sys
21
import unittest
32

43
import numpy
54
import pytest
6-
from dpctl import select_default_device
75

86
import dpnp as cupy
97
from tests.helper import has_support_aspect64
108
from tests.third_party.cupy import testing
119

1210

11+
@pytest.mark.skip("dpnp.corrcoef() is not implemented yet")
1312
class 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

4149
class 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")
155163
class 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")
191201
class 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

Comments
 (0)