forked from IntelPython/dpnp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the scope of third party tests with the latest changes (IntelP…
…ython#2148) The PR proposes to update scope and content of third party tests with the latest version. That would help to reduce future work while implementing missing functions and to improve code coverage of existing supported functionality. Also PR removes impacted tests from the files with a skip list and replaces that by explicit muting in tests code.
- Loading branch information
1 parent
4875e59
commit 4d636b3
Showing
119 changed files
with
16,869 additions
and
2,083 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import unittest | ||
|
||
import numpy | ||
import pytest | ||
|
||
import dpnp as cupy | ||
from dpnp.tests.third_party.cupy import testing | ||
|
||
pytest.skip( | ||
"packbits() and unpackbits() are not supported yet", allow_module_level=True | ||
) | ||
|
||
|
||
class TestPacking(unittest.TestCase): | ||
|
||
@testing.for_int_dtypes() | ||
@testing.numpy_cupy_array_equal() | ||
def check_packbits(self, data, xp, dtype, bitorder="big"): | ||
# Note numpy <= 1.9 raises an Exception when an input array is bool. | ||
# See https://github.com/numpy/numpy/issues/5377 | ||
a = xp.array(data, dtype=dtype) | ||
return xp.packbits(a, bitorder=bitorder) | ||
|
||
@testing.numpy_cupy_array_equal() | ||
def check_unpackbits(self, data, xp, bitorder="big"): | ||
a = xp.array(data, dtype=xp.uint8) | ||
return xp.unpackbits(a, bitorder=bitorder) | ||
|
||
def test_packbits(self): | ||
self.check_packbits([0]) | ||
self.check_packbits([1]) | ||
self.check_packbits([0, 1]) | ||
self.check_packbits([1, 0, 1, 1, 0, 1, 1, 1]) | ||
self.check_packbits([1, 0, 1, 1, 0, 1, 1, 1, 1]) | ||
self.check_packbits(numpy.arange(24).reshape((2, 3, 4)) % 2) | ||
|
||
def test_packbits_order(self): | ||
for bo in ["big", "little"]: | ||
self.check_packbits([0], bitorder=bo) | ||
self.check_packbits([1], bitorder=bo) | ||
self.check_packbits([0, 1], bitorder=bo) | ||
self.check_packbits([1, 0, 1, 1, 0, 1, 1, 1], bitorder=bo) | ||
self.check_packbits([1, 0, 1, 1, 0, 1, 1, 1, 1], bitorder=bo) | ||
self.check_packbits( | ||
numpy.arange(24).reshape((2, 3, 4)) % 2, bitorder=bo | ||
) | ||
|
||
def test_packbits_empty(self): | ||
# Note packbits of numpy <= 1.11 has a bug against empty arrays. | ||
# See https://github.com/numpy/numpy/issues/8324 | ||
self.check_packbits([]) | ||
|
||
def test_pack_invalid_order(self): | ||
a = cupy.array([10, 20, 30]) | ||
pytest.raises(ValueError, cupy.packbits, a, bitorder="ascendant") | ||
pytest.raises(ValueError, cupy.packbits, a, bitorder=10.4) | ||
|
||
def test_pack_invalid_array(self): | ||
fa = cupy.array([10, 20, 30], dtype=float) | ||
pytest.raises(TypeError, cupy.packbits, fa) | ||
|
||
def test_unpackbits(self): | ||
self.check_unpackbits([]) | ||
self.check_unpackbits([0]) | ||
self.check_unpackbits([1]) | ||
self.check_unpackbits([255]) | ||
self.check_unpackbits([100, 200, 123, 213]) | ||
|
||
def test_unpack_invalid_array(self): | ||
a = cupy.array([10, 20, 30]) | ||
pytest.raises(TypeError, cupy.unpackbits, a) | ||
pytest.raises(TypeError, cupy.unpackbits, a.astype(float)) | ||
|
||
def test_pack_unpack_order(self): | ||
for bo in ["big", "little"]: | ||
self.check_unpackbits([], bitorder=bo) | ||
self.check_unpackbits([0], bitorder=bo) | ||
self.check_unpackbits([1], bitorder=bo) | ||
self.check_unpackbits([255], bitorder=bo) | ||
self.check_unpackbits([100, 200, 123, 213], bitorder=bo) | ||
|
||
def test_unpack_invalid_order(self): | ||
a = cupy.array([10, 20, 30], dtype=cupy.uint8) | ||
pytest.raises(ValueError, cupy.unpackbits, a, bitorder="r") | ||
pytest.raises(ValueError, cupy.unpackbits, a, bitorder=10) |
64 changes: 64 additions & 0 deletions
64
dpnp/tests/third_party/cupy/core_tests/test_array_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import unittest | ||
|
||
import numpy | ||
import pytest | ||
|
||
import dpnp as cupy | ||
from dpnp.tests.third_party.cupy import testing | ||
|
||
pytest.skip( | ||
"__array_function__ protocol is not supported", allow_module_level=True | ||
) | ||
|
||
|
||
class TestArrayFunction(unittest.TestCase): | ||
|
||
@testing.with_requires("numpy>=1.17.0") | ||
def test_array_function(self): | ||
a = numpy.random.randn(100, 100) | ||
a_cpu = numpy.asarray(a) | ||
a_gpu = cupy.asarray(a) | ||
|
||
# The numpy call for both CPU and GPU arrays is intentional to test the | ||
# __array_function__ protocol | ||
qr_cpu = numpy.linalg.qr(a_cpu) | ||
qr_gpu = numpy.linalg.qr(a_gpu) | ||
|
||
if isinstance(qr_cpu, tuple): | ||
for b_cpu, b_gpu in zip(qr_cpu, qr_gpu): | ||
assert b_cpu.dtype == b_gpu.dtype | ||
testing.assert_allclose(b_cpu, b_gpu, atol=1e-4) | ||
else: | ||
assert qr_cpu.dtype == qr_gpu.dtype | ||
testing.assert_allclose(qr_cpu, qr_gpu, atol=1e-4) | ||
|
||
@testing.with_requires("numpy>=1.17.0") | ||
def test_array_function2(self): | ||
a = numpy.random.randn(100, 100) | ||
a_cpu = numpy.asarray(a) | ||
a_gpu = cupy.asarray(a) | ||
|
||
# The numpy call for both CPU and GPU arrays is intentional to test the | ||
# __array_function__ protocol | ||
out_cpu = numpy.sum(a_cpu, axis=1) | ||
out_gpu = numpy.sum(a_gpu, axis=1) | ||
|
||
assert out_cpu.dtype == out_gpu.dtype | ||
testing.assert_allclose(out_cpu, out_gpu, atol=1e-4) | ||
|
||
@testing.with_requires("numpy>=1.17.0") | ||
@testing.numpy_cupy_equal() | ||
def test_array_function_can_cast(self, xp): | ||
return numpy.can_cast(xp.arange(2), "f4") | ||
|
||
@testing.with_requires("numpy>=1.17.0") | ||
@testing.numpy_cupy_equal() | ||
def test_array_function_common_type(self, xp): | ||
return numpy.common_type( | ||
xp.arange(2, dtype="f8"), xp.arange(2, dtype="f4") | ||
) | ||
|
||
@testing.with_requires("numpy>=1.17.0") | ||
@testing.numpy_cupy_equal() | ||
def test_array_function_result_type(self, xp): | ||
return numpy.result_type(3, xp.arange(2, dtype="f8")) |
Oops, something went wrong.