|
7 | 7 | import pytest |
8 | 8 |
|
9 | 9 | import dpnp as cupy |
| 10 | +from dpnp.tests.helper import has_support_aspect64 |
10 | 11 | from dpnp.tests.third_party.cupy import testing |
11 | 12 |
|
12 | 13 |
|
@@ -60,7 +61,9 @@ def skip_inplace_numpy_uint64_casting_error(xp, x_type, y_type): |
60 | 61 | class TestArrayElementwiseOp: |
61 | 62 |
|
62 | 63 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
63 | | - @testing.numpy_cupy_allclose(rtol=1e-6, accept_error=TypeError) |
| 64 | + @testing.numpy_cupy_allclose( |
| 65 | + rtol=1e-6, accept_error=TypeError, type_check=has_support_aspect64() |
| 66 | + ) |
64 | 67 | @cast_exception_type() |
65 | 68 | def check_array_scalar_op( |
66 | 69 | self, |
@@ -214,7 +217,9 @@ def test_ne_scalar(self): |
214 | 217 | self.check_array_scalar_op(operator.ne) |
215 | 218 |
|
216 | 219 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
217 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 220 | + @testing.numpy_cupy_allclose( |
| 221 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 222 | + ) |
218 | 223 | @cast_exception_type() |
219 | 224 | def check_array_array_op( |
220 | 225 | self, |
@@ -278,7 +283,12 @@ def test_ifloordiv_array(self): |
278 | 283 | ) |
279 | 284 |
|
280 | 285 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
281 | | - @testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-6, accept_error=TypeError) |
| 286 | + @testing.numpy_cupy_allclose( |
| 287 | + atol=1e-5, |
| 288 | + rtol=1e-6, |
| 289 | + accept_error=TypeError, |
| 290 | + type_check=has_support_aspect64(), |
| 291 | + ) |
282 | 292 | def check_pow_array(self, xp, x_type, y_type): |
283 | 293 | a = xp.array([[1, 2, 3], [4, 5, 6]], x_type) |
284 | 294 | b = xp.array([[6, 5, 4], [3, 2, 1]], y_type) |
@@ -332,7 +342,9 @@ def test_ne_array(self): |
332 | 342 | self.check_array_array_op(operator.ne) |
333 | 343 |
|
334 | 344 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
335 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 345 | + @testing.numpy_cupy_allclose( |
| 346 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 347 | + ) |
336 | 348 | @cast_exception_type() |
337 | 349 | def check_array_broadcasted_op( |
338 | 350 | self, |
@@ -400,7 +412,12 @@ def test_broadcasted_ifloordiv(self): |
400 | 412 | ) |
401 | 413 |
|
402 | 414 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
403 | | - @testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-6, accept_error=TypeError) |
| 415 | + @testing.numpy_cupy_allclose( |
| 416 | + atol=1e-5, |
| 417 | + rtol=1e-6, |
| 418 | + accept_error=TypeError, |
| 419 | + type_check=has_support_aspect64(), |
| 420 | + ) |
404 | 421 | def check_broadcasted_pow(self, xp, x_type, y_type): |
405 | 422 | a = xp.array([[1, 2, 3], [4, 5, 6]], x_type) |
406 | 423 | b = xp.array([[1], [2]], y_type) |
@@ -458,7 +475,7 @@ def test_broadcasted_ne(self): |
458 | 475 | self.check_array_broadcasted_op(operator.ne) |
459 | 476 |
|
460 | 477 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
461 | | - @testing.numpy_cupy_allclose(rtol=1e-6) |
| 478 | + @testing.numpy_cupy_allclose(rtol=1e-6, type_check=has_support_aspect64()) |
462 | 479 | def check_array_doubly_broadcasted_op( |
463 | 480 | self, op, xp, x_type, y_type, no_bool=False, no_complex=False |
464 | 481 | ): |
@@ -525,7 +542,7 @@ def test_doubly_broadcasted_ne(self): |
525 | 542 | self.check_array_doubly_broadcasted_op(operator.ne) |
526 | 543 |
|
527 | 544 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
528 | | - @testing.numpy_cupy_allclose() |
| 545 | + @testing.numpy_cupy_allclose(type_check=has_support_aspect64()) |
529 | 546 | def check_array_reversed_op(self, op, xp, x_type, y_type, no_bool=False): |
530 | 547 | if no_bool and x_type == numpy.bool_ and y_type == numpy.bool_: |
531 | 548 | return xp.array(True) |
@@ -567,7 +584,9 @@ def test_array_reversed_mul(self): |
567 | 584 | ], |
568 | 585 | ) |
569 | 586 | @testing.for_all_dtypes(no_bool=True) |
570 | | - @testing.numpy_cupy_allclose(accept_error=OverflowError) |
| 587 | + @testing.numpy_cupy_allclose( |
| 588 | + accept_error=OverflowError, type_check=has_support_aspect64() |
| 589 | + ) |
571 | 590 | def test_typecast_(self, xp, op, dtype, val): |
572 | 591 | a = op(val, (testing.shaped_arange((5,), xp, dtype) - 2)) |
573 | 592 | return a |
@@ -618,7 +637,9 @@ def test_iadd_array_boolarray(self): |
618 | 637 | class TestArrayIntElementwiseOp: |
619 | 638 |
|
620 | 639 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
621 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 640 | + @testing.numpy_cupy_allclose( |
| 641 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 642 | + ) |
622 | 643 | @cast_exception_type() |
623 | 644 | def check_array_scalar_op(self, op, xp, x_type, y_type, swap=False): |
624 | 645 | a = xp.array([[0, 1, 2], [1, 0, 2]], dtype=x_type) |
@@ -666,7 +687,9 @@ def test_rmod_scalar(self): |
666 | 687 | self.check_array_scalar_op(operator.mod, swap=True) |
667 | 688 |
|
668 | 689 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
669 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 690 | + @testing.numpy_cupy_allclose( |
| 691 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 692 | + ) |
670 | 693 | @cast_exception_type() |
671 | 694 | def check_array_scalarzero_op(self, op, xp, x_type, y_type, swap=False): |
672 | 695 | a = xp.array([[0, 1, 2], [1, 0, 2]], dtype=x_type) |
@@ -714,7 +737,9 @@ def test_rmod_scalarzero(self): |
714 | 737 | self.check_array_scalarzero_op(operator.mod, swap=True) |
715 | 738 |
|
716 | 739 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
717 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 740 | + @testing.numpy_cupy_allclose( |
| 741 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 742 | + ) |
718 | 743 | @cast_exception_type() |
719 | 744 | def check_array_array_op(self, op, xp, x_type, y_type, inplace=False): |
720 | 745 | if inplace: |
@@ -763,7 +788,9 @@ def test_imod_array(self): |
763 | 788 | self.check_array_array_op(operator.imod, inplace=True) |
764 | 789 |
|
765 | 790 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
766 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 791 | + @testing.numpy_cupy_allclose( |
| 792 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 793 | + ) |
767 | 794 | @cast_exception_type() |
768 | 795 | def check_array_broadcasted_op(self, op, xp, x_type, y_type, inplace=False): |
769 | 796 | if inplace: |
@@ -812,7 +839,9 @@ def test_broadcasted_imod(self): |
812 | 839 | self.check_array_broadcasted_op(operator.imod, inplace=True) |
813 | 840 |
|
814 | 841 | @testing.for_all_dtypes_combination(names=["x_type", "y_type"]) |
815 | | - @testing.numpy_cupy_allclose(accept_error=TypeError) |
| 842 | + @testing.numpy_cupy_allclose( |
| 843 | + accept_error=TypeError, type_check=has_support_aspect64() |
| 844 | + ) |
816 | 845 | @cast_exception_type() |
817 | 846 | def check_array_doubly_broadcasted_op(self, op, xp, x_type, y_type): |
818 | 847 | a = xp.array([[[0, 1, 2]], [[1, 0, 2]]], dtype=x_type) |
@@ -890,7 +919,7 @@ class CustomInt(int): |
890 | 919 | pass |
891 | 920 |
|
892 | 921 |
|
893 | | -@pytest.mark.parametrize("dtype", ["int32", "float64"]) |
| 922 | +@pytest.mark.parametrize("dtype", ["int32", cupy.default_float_type()]) |
894 | 923 | @pytest.mark.parametrize( |
895 | 924 | "value", |
896 | 925 | [ |
|
0 commit comments