From 80fd7c5629fecdcfc2bd5ff8fe0006fafa6740b3 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 9 Oct 2024 05:02:17 +0200 Subject: [PATCH 01/10] Add integer datatypes and add types to tests --- .github/workflows/conda-package.yml | 20 +++++++----- dpnp/dpnp_iface_types.py | 12 +++++++ dpnp/tests/config.py | 3 ++ dpnp/tests/helper.py | 13 ++++++++ dpnp/tests/third_party/cupy/testing/_loops.py | 31 ++++++++++++++++--- 5 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 dpnp/tests/config.py diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 136863e85d3..9cb8e5220fa 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -159,7 +159,7 @@ jobs: echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV - name: Install dpnp - run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} + run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} env: TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}' MAMBA_NO_LOW_SPEED_LIMIT: 1 @@ -175,14 +175,15 @@ jobs: - name: Run tests if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | - python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + export DPNP_TEST_ALL_TYPES=1 + python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_linux uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: - timeout_minutes: 10 + timeout_minutes: 45 max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }} retry_on: any command: | @@ -190,7 +191,8 @@ jobs: . $CONDA/etc/profile.d/mamba.sh mamba activate ${{ env.TEST_ENV_NAME }} - python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + export DPNP_TEST_ALL_TYPES=1 + python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests test_windows: name: Test ['windows-2019', python='${{ matrix.python }}'] @@ -282,7 +284,7 @@ jobs: - name: Install dpnp run: | @echo on - mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} + mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} env: TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}' MAMBA_NO_LOW_SPEED_LIMIT: 1 @@ -311,18 +313,20 @@ jobs: - name: Run tests if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | - pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + set DPNP_TEST_ALL_TYPES=1 + pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_win uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: - timeout_minutes: 15 + timeout_minutes: 45 max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }} retry_on: any command: | - python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + set DPNP_TEST_ALL_TYPES=1 + python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests upload: name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}'] diff --git a/dpnp/dpnp_iface_types.py b/dpnp/dpnp_iface_types.py index 9fbe5b377c1..c7605212771 100644 --- a/dpnp/dpnp_iface_types.py +++ b/dpnp/dpnp_iface_types.py @@ -59,8 +59,14 @@ "inf", "int", "int_", + "int8", + "int16", "int32", "int64", + "uint8", + "uint16", + "uint32", + "uint64", "integer", "intc", "intp", @@ -95,8 +101,14 @@ inexact = numpy.inexact int = numpy.int_ int_ = numpy.int_ +int8 = numpy.int8 +int16 = numpy.int16 int32 = numpy.int32 int64 = numpy.int64 +uint8 = numpy.uint8 +uint16 = numpy.uint16 +uint32 = numpy.uint32 +uint64 = numpy.uint64 integer = numpy.integer intc = numpy.intc intp = numpy.intp diff --git a/dpnp/tests/config.py b/dpnp/tests/config.py new file mode 100644 index 00000000000..20a56300ca8 --- /dev/null +++ b/dpnp/tests/config.py @@ -0,0 +1,3 @@ +import os + +all_types = int(os.getenv("DPNP_TEST_ALL_TYPES", 0)) \ No newline at end of file diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 2db95fdeb77..a9b4d5c3fcf 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -5,6 +5,7 @@ from numpy.testing import assert_allclose, assert_array_equal import dpnp +from tests import config def assert_dtype_allclose( @@ -88,6 +89,18 @@ def get_integer_dtypes(): Build a list of integer types supported by DPNP. """ + if config.all_types: + return [ + dpnp.int8, + dpnp.int16, + dpnp.int32, + dpnp.int64, + dpnp.uint8, + dpnp.uint16, + dpnp.uint32, + dpnp.uint64, + ] + return [dpnp.int32, dpnp.int64] diff --git a/dpnp/tests/third_party/cupy/testing/_loops.py b/dpnp/tests/third_party/cupy/testing/_loops.py index aea6e77e042..21e6ff7f651 100644 --- a/dpnp/tests/third_party/cupy/testing/_loops.py +++ b/dpnp/tests/third_party/cupy/testing/_loops.py @@ -12,6 +12,7 @@ from dpctl.tensor._numpy_helper import AxisError import dpnp as cupy +from dpnp.tests import config from dpnp.tests.third_party.cupy.testing import _array, _parameterized from dpnp.tests.third_party.cupy.testing._pytest_impl import is_available @@ -1039,19 +1040,39 @@ def _get_supported_complex_dtypes(): return (numpy.complex64,) +def _get_int_dtypes(): + if config.all_types: + return _signed_dtypes + _unsigned_dtypes + else: + return (numpy.int64, numpy.int32) + + _complex_dtypes = _get_supported_complex_dtypes() _regular_float_dtypes = _get_supported_float_dtypes() -_float_dtypes = _regular_float_dtypes -_signed_dtypes = () +_float_dtypes = _regular_float_dtypes + (numpy.float16,) +_signed_dtypes = tuple(numpy.dtype(i).type for i in "bhilq") _unsigned_dtypes = tuple(numpy.dtype(i).type for i in "BHILQ") -_int_dtypes = _signed_dtypes + _unsigned_dtypes -_int_bool_dtypes = _int_dtypes +_int_dtypes = _get_int_dtypes() +_int_bool_dtypes = _int_dtypes + (numpy.bool_,) _regular_dtypes = _regular_float_dtypes + _int_bool_dtypes _dtypes = _float_dtypes + _int_bool_dtypes def _make_all_dtypes(no_float16, no_bool, no_complex): - return (numpy.int64, numpy.int32) + _get_supported_float_dtypes() + if no_float16: + dtypes = _regular_float_dtypes + else: + dtypes = _float_dtypes + + if no_bool: + dtypes += _int_dtypes + else: + dtypes += _int_bool_dtypes + + if not no_complex: + dtypes += _complex_dtypes + + return dtypes def for_all_dtypes( From bb703b89c5c56e487974ac4b040773df0c3a20b6 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Tue, 3 Dec 2024 04:18:55 +0100 Subject: [PATCH 02/10] Review comments --- .github/workflows/conda-package.yml | 12 ++++++---- doc/reference/dtypes_table.rst | 15 +++++++++++- dpnp/dpnp_iface_types.py | 36 +++++++++++++++++++++-------- dpnp/tests/config.py | 2 +- dpnp/tests/helper.py | 2 +- dpnp/tests/test_random_state.py | 22 +++++++++--------- 6 files changed, 61 insertions(+), 28 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 9cb8e5220fa..5d5cdc30ca0 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -173,12 +173,15 @@ jobs: python -c "import dpnp; print(dpnp.__version__)" - name: Run tests + env: + DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | - export DPNP_TEST_ALL_TYPES=1 python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests + env: + DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_linux uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 @@ -191,7 +194,6 @@ jobs: . $CONDA/etc/profile.d/mamba.sh mamba activate ${{ env.TEST_ENV_NAME }} - export DPNP_TEST_ALL_TYPES=1 python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests test_windows: @@ -311,12 +313,15 @@ jobs: python -c "import dpnp; print(dpnp.__version__)" - name: Run tests + env: + DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | - set DPNP_TEST_ALL_TYPES=1 pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests + env: + DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_win uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 @@ -325,7 +330,6 @@ jobs: max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }} retry_on: any command: | - set DPNP_TEST_ALL_TYPES=1 python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests upload: diff --git a/doc/reference/dtypes_table.rst b/doc/reference/dtypes_table.rst index 6d851da401a..40cf3d742b3 100644 --- a/doc/reference/dtypes_table.rst +++ b/doc/reference/dtypes_table.rst @@ -13,22 +13,35 @@ Table below shows a list of all supported data types (dtypes) and constants of t - Constants * - - :obj:`bool ` + - :obj:`int8 ` + - :obj:`int16 ` - :obj:`int32 ` - :obj:`int64 ` + - :obj:`uint8 ` + - :obj:`uint16 ` + - :obj:`uint32 ` + - :obj:`uint64 ` - :obj:`float32 ` - :obj:`float64 ` - :obj:`complex64 ` - :obj:`complex128 ` - - :obj:`bool_ ` + - :obj:`byte ` - :obj:`cdouble ` - :obj:`csingle ` - :obj:`double ` - :obj:`float16 ` - - :obj:`int ` - :obj:`int_ ` - :obj:`intc ` + - :obj:`intp ` + - :obj:`longlong ` - :obj:`single ` + - :obj:`ubyte ` + - :obj:`uintc ` + - :obj:`uintp ` + - :obj:`ushort ` + - :obj:`ulonglong ` - - :obj:`e ` - :obj:`euler_gamma ` diff --git a/dpnp/dpnp_iface_types.py b/dpnp/dpnp_iface_types.py index c7605212771..e06ed5c122e 100644 --- a/dpnp/dpnp_iface_types.py +++ b/dpnp/dpnp_iface_types.py @@ -40,6 +40,7 @@ __all__ = [ "bool", "bool_", + "byte", "cdouble", "complex128", "complex64", @@ -57,27 +58,34 @@ "iinfo", "inexact", "inf", - "int", "int_", "int8", "int16", "int32", "int64", - "uint8", - "uint16", - "uint32", - "uint64", "integer", "intc", "intp", "issubdtype", "is_type_supported", + "longlong", "nan", "newaxis", "number", "pi", + "short", "signedinteger", "single", + "ubyte", + "uint8", + "uint16", + "uint32", + "uint64", + "uintc", + "uintp", + "unsignedinteger", + "ushort", + "ulonglong", ] @@ -87,6 +95,7 @@ # ============================================================================= bool = numpy.bool_ bool_ = numpy.bool_ +byte = numpy.byte cdouble = numpy.cdouble complex128 = numpy.complex128 complex64 = numpy.complex64 @@ -99,22 +108,29 @@ float64 = numpy.float64 floating = numpy.floating inexact = numpy.inexact -int = numpy.int_ int_ = numpy.int_ int8 = numpy.int8 int16 = numpy.int16 int32 = numpy.int32 int64 = numpy.int64 -uint8 = numpy.uint8 -uint16 = numpy.uint16 -uint32 = numpy.uint32 -uint64 = numpy.uint64 integer = numpy.integer intc = numpy.intc intp = numpy.intp +longlong = numpy.longlong number = numpy.number +short = numpy.short signedinteger = numpy.signedinteger single = numpy.single +ubyte = numpy.ubyte +uint8 = numpy.uint8 +uint16 = numpy.uint16 +uint32 = numpy.uint32 +uint64 = numpy.uint64 +uintc = numpy.uintc +uintp = numpy.uintp +unsignedinteger = numpy.unsignedinteger +ushort = numpy.ushort +ulonglong = numpy.ulonglong # ============================================================================= diff --git a/dpnp/tests/config.py b/dpnp/tests/config.py index 20a56300ca8..322cffadfa0 100644 --- a/dpnp/tests/config.py +++ b/dpnp/tests/config.py @@ -1,3 +1,3 @@ import os -all_types = int(os.getenv("DPNP_TEST_ALL_TYPES", 0)) \ No newline at end of file +all_types = int(os.getenv("DPNP_TEST_ALL_TYPES", 0)) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index a9b4d5c3fcf..315c4c41da1 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -5,7 +5,7 @@ from numpy.testing import assert_allclose, assert_array_equal import dpnp -from tests import config +from dpnp.tests import config def assert_dtype_allclose( diff --git a/dpnp/tests/test_random_state.py b/dpnp/tests/test_random_state.py index 7107a919c4e..35ff4154cde 100644 --- a/dpnp/tests/test_random_state.py +++ b/dpnp/tests/test_random_state.py @@ -241,7 +241,7 @@ def test_fallback(self, loc, scale): float, dpnp.int64, dpnp.int32, - dpnp.int, + dpnp.int_, int, numpy.clongdouble, dpnp.complex128, @@ -254,7 +254,7 @@ def test_fallback(self, loc, scale): "float", "dpnp.int64", "dpnp.int32", - "dpnp.int", + "dpnp.int_", "int", "numpy.clongdouble", "dpnp.complex128", @@ -364,8 +364,8 @@ def test_wrong_dims(self): class TestRandInt: @pytest.mark.parametrize( "dtype", - [int, dpnp.int32, dpnp.int], - ids=["int", "dpnp.int32", "dpnp.int"], + [int, dpnp.int32, dpnp.int_], + ids=["int", "dpnp.int32", "dpnp.int_"], ) @pytest.mark.parametrize( "usm_type", @@ -377,7 +377,7 @@ def test_distr(self, dtype, usm_type): low = 1 high = 10 - if dtype == dpnp.int and dtype != dpnp.dtype("int32"): + if dtype == dpnp.int_ and dtype != dpnp.dtype("int32"): pytest.skip( "dtype isn't alias on dpnp.int32 on the target OS, so there will be a fallback" ) @@ -564,10 +564,10 @@ def test_bounds_fallback(self, low, high): @pytest.mark.usefixtures("allow_fall_back_on_numpy") @pytest.mark.parametrize( "dtype", - [dpnp.int64, dpnp.int, dpnp.bool, dpnp.bool_, bool], + [dpnp.int64, dpnp.int_, dpnp.bool, dpnp.bool_, bool], ids=[ "dpnp.int64", - "dpnp.int", + "dpnp.int_", "dpnp.bool", "dpnp.bool_", "bool", @@ -579,7 +579,7 @@ def test_dtype_fallback(self, dtype): high = 37 if not dtype in {dpnp.bool_, bool} else 2 size = (3, 2, 5) - if dtype == dpnp.int and dtype == dpnp.dtype("int32"): + if dtype == dpnp.int_ and dtype == dpnp.dtype("int32"): pytest.skip( "dtype is alias on dpnp.int32 on the target OS, so no fallback here" ) @@ -1155,7 +1155,7 @@ def test_fallback(self, low, high): dpnp.float16, float, dpnp.int64, - dpnp.int, + dpnp.int_, int, numpy.clongdouble, dpnp.complex128, @@ -1167,7 +1167,7 @@ def test_fallback(self, low, high): "dpnp.float16", "float", "dpnp.int64", - "dpnp.int", + "dpnp.int_", "int", "numpy.clongdouble", "dpnp.complex128", @@ -1177,7 +1177,7 @@ def test_fallback(self, low, high): ], ) def test_invalid_dtype(self, dtype): - if dtype == dpnp.int and dtype == dpnp.dtype("int32"): + if dtype == dpnp.int_ and dtype == dpnp.dtype("int32"): pytest.skip( "dtype is alias on dpnp.int32 on the target OS, so no error here" ) From fe0c5421696047d193db569b1784b0e7b5d7ccfc Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Tue, 3 Dec 2024 16:18:46 +0100 Subject: [PATCH 03/10] Make TestPad ordered --- dpnp/tests/test_arraypad.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/dpnp/tests/test_arraypad.py b/dpnp/tests/test_arraypad.py index 34a71eec707..16b7c23c75e 100644 --- a/dpnp/tests/test_arraypad.py +++ b/dpnp/tests/test_arraypad.py @@ -30,7 +30,11 @@ class TestPad: "empty": {}, } - @pytest.mark.parametrize("mode", _all_modes.keys()) + # .keys() returns set which is not ordered + # consistent order is required by xdist plugin + _modes = sorted(_all_modes.keys()) + + @pytest.mark.parametrize("mode", _modes) def test_basic(self, mode): a_np = numpy.arange(100) a_dp = dpnp.array(a_np) @@ -43,7 +47,7 @@ def test_basic(self, mode): else: assert_array_equal(result, expected) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_memory_layout_persistence(self, mode): """Test if C and F order is preserved for all pad modes.""" x = dpnp.ones((5, 10), order="C") @@ -52,13 +56,13 @@ def test_memory_layout_persistence(self, mode): assert dpnp.pad(x, 5, mode).flags.f_contiguous @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_dtype_persistence(self, dtype, mode): arr = dpnp.zeros((3, 2, 1), dtype=dtype) result = dpnp.pad(arr, 1, mode=mode) assert result.dtype == dtype - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_non_contiguous_array(self, mode): a_np = numpy.arange(24).reshape(4, 6)[::2, ::2] a_dp = dpnp.arange(24).reshape(4, 6)[::2, ::2] @@ -73,12 +77,14 @@ def test_non_contiguous_array(self, mode): # TODO: include "linear_ramp" when dpnp issue gh-2084 is resolved @pytest.mark.parametrize("pad_width", [0, (0, 0), ((0, 0), (0, 0))]) - @pytest.mark.parametrize("mode", _all_modes.keys() - {"linear_ramp"}) + @pytest.mark.parametrize( + "mode", [m for m in _modes if m not in {"linear_ramp"}] + ) def test_zero_pad_width(self, pad_width, mode): arr = dpnp.arange(30).reshape(6, 5) assert_array_equal(arr, dpnp.pad(arr, pad_width, mode=mode)) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_pad_non_empty_dimension(self, mode): a_np = numpy.ones((2, 0, 2)) a_dp = dpnp.array(a_np) @@ -95,14 +101,14 @@ def test_pad_non_empty_dimension(self, mode): ((3, 4, 5), (0, 1, 2)), ], ) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_misshaped_pad_width1(self, pad_width, mode): arr = dpnp.arange(30).reshape((6, 5)) match = "operands could not be broadcast together" with pytest.raises(ValueError, match=match): dpnp.pad(arr, pad_width, mode) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_misshaped_pad_width2(self, mode): arr = dpnp.arange(30).reshape((6, 5)) match = ( @@ -115,7 +121,7 @@ def test_misshaped_pad_width2(self, mode): @pytest.mark.parametrize( "pad_width", [-2, (-2,), (3, -1), ((5, 2), (-2, 3)), ((-4,), (2,))] ) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_negative_pad_width(self, pad_width, mode): arr = dpnp.arange(30).reshape((6, 5)) match = "index can't contain negative values" @@ -126,14 +132,14 @@ def test_negative_pad_width(self, pad_width, mode): "pad_width", ["3", "word", None, 3.4, complex(1, -1), ((-2.1, 3), (3, 2))], ) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_bad_type(self, pad_width, mode): arr = dpnp.arange(30).reshape((6, 5)) match = "`pad_width` must be of integral type." with pytest.raises(TypeError, match=match): dpnp.pad(arr, pad_width, mode) - @pytest.mark.parametrize("mode", _all_modes.keys()) + @pytest.mark.parametrize("mode", _modes) def test_kwargs(self, mode): """Test behavior of pad's kwargs for the given mode.""" allowed = self._all_modes[mode] @@ -439,7 +445,7 @@ def test_pad_empty_dim_valid(self, mode): @pytest.mark.parametrize( "mode", - _all_modes.keys() - {"constant", "empty"}, + [m for m in _modes if m not in {"constant", "empty"}], ) def test_pad_empty_dim_invalid(self, mode): match = ( From cc58539ed74d01c256f96fe780207fd59a2ad058 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Sun, 8 Dec 2024 18:18:16 +0100 Subject: [PATCH 04/10] Add separate job for full types --- .github/workflows/conda-package.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 5d5cdc30ca0..4ee794810ef 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -173,15 +173,11 @@ jobs: python -c "import dpnp; print(dpnp.__version__)" - name: Run tests - env: - DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests - env: - DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_linux uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 @@ -196,6 +192,13 @@ jobs: python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + - name: Run full tests + if: matrix.python == '3.12' + env: + DPNP_TEST_ALL_TYPES: 1 + run: | + pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + test_windows: name: Test ['windows-2019', python='${{ matrix.python }}'] @@ -313,25 +316,28 @@ jobs: python -c "import dpnp; print(dpnp.__version__)" - name: Run tests - env: - DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE != 'true' run: | pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests - name: Run tests - env: - DPNP_TEST_ALL_TYPES: 1 if: env.RERUN_TESTS_ON_FAILURE == 'true' id: run_tests_win uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: - timeout_minutes: 45 + timeout_minutes: 15 max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }} retry_on: any command: | python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + - name: Run full tests + if: matrix.python == '3.12' + env: + DPNP_TEST_ALL_TYPES: 1 + run: | + pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + upload: name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}'] From 42d54e6c17cfaeedb867ed4deb899f0f385168d9 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Sun, 8 Dec 2024 22:10:38 +0100 Subject: [PATCH 05/10] Remove float16 dtype and move all dtype tests to separate task --- .github/workflows/conda-package.yml | 195 +++++++++++++++++- dpnp/tests/third_party/cupy/testing/_loops.py | 2 +- 2 files changed, 195 insertions(+), 2 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 4ee794810ef..11f791ebaa2 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -192,8 +192,85 @@ jobs: python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + test_linux_all_dtypes: + name: Test ['ubuntu-latest', python='${{ matrix.python }}'] + + needs: build + + runs-on: ubuntu-latest + + defaults: + run: + shell: bash -el {0} + + strategy: + matrix: + python: ['3.12'] + + continue-on-error: true + + env: + channel-path: '${{ github.workspace }}/channel/' + pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/' + extracted-pkg-path: '${{ github.workspace }}/pkg/' + ver-json-path: '${{ github.workspace }}/version.json' + + steps: + - name: Download artifact + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + path: ${{ env.pkg-path-in-channel }} + + - name: Extract package archive + run: | + mkdir -p ${{ env.extracted-pkg-path }} + tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }} + + - name: Setup miniconda + uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0 + with: + miniforge-version: latest + use-mamba: 'true' + channels: conda-forge + conda-remove-defaults: 'true' + python-version: ${{ matrix.python }} + activate-environment: ${{ env.TEST_ENV_NAME }} + + - name: Install conda-index + run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} + + - name: Create conda channel + run: | + python -m conda_index ${{ env.channel-path }} + + - name: Test conda channel + run: | + mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }} + cat ${{ env.ver-json-path }} + + - name: Get package version + run: | + export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}") + + echo PACKAGE_VERSION=${PACKAGE_VERSION} + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + + - name: Install dpnp + run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} + env: + TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}' + MAMBA_NO_LOW_SPEED_LIMIT: 1 + + - name: List installed packages + run: mamba list + + - name: Smoke test + run: | + python -c "import dpnp, dpctl; dpctl.lsplatform()" + python -c "import dpnp; print(dpnp.__version__)" + - name: Run full tests - if: matrix.python == '3.12' env: DPNP_TEST_ALL_TYPES: 1 run: | @@ -331,6 +408,122 @@ jobs: command: | python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests + test_windows_all_dtypes: + name: Test ['windows-2019', python='${{ matrix.python }}'] + + needs: build + + runs-on: windows-2019 + + defaults: + run: + shell: cmd /C CALL {0} + + strategy: + matrix: + python: ['3.12'] + + continue-on-error: true + + env: + channel-path: '${{ github.workspace }}\channel\' + pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\' + extracted-pkg-path: '${{ github.workspace }}\pkg' + ver-json-path: '${{ github.workspace }}\version.json' + workdir: '${{ github.workspace }}' + + steps: + - name: Download artifact + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }} + path: ${{ env.pkg-path-in-channel }} + + - name: Extract package archive + run: | + @echo on + mkdir -p ${{ env.extracted-pkg-path }} + + set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2"" + FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO ( + SET FULL_PACKAGE_PATH=%%F + ) + echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH% + + python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")" + dir ${{ env.extracted-pkg-path }} + + - name: Setup miniconda + uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0 + with: + miniforge-version: latest + use-mamba: 'true' + channels: conda-forge + conda-remove-defaults: 'true' + python-version: ${{ matrix.python }} + activate-environment: ${{ env.TEST_ENV_NAME }} + + - name: Store conda paths as envs + run: | + @echo on + (echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV% + (echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV% + + - name: Install conda-index + run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }} + + - name: Create conda channel + run: | + @echo on + python -m conda_index ${{ env.channel-path }} + + - name: Test conda channel + run: | + @echo on + mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }} + + - name: Dump version.json + run: more ${{ env.ver-json-path }} + + - name: Get package version + run: | + @echo on + set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}" + FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO ( + set PACKAGE_VERSION=%%F + ) + echo PACKAGE_VERSION: %PACKAGE_VERSION% + (echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV% + + - name: Install dpnp + run: | + @echo on + mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }} + env: + TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}' + MAMBA_NO_LOW_SPEED_LIMIT: 1 + + - name: List installed packages + run: mamba list + + - name: Activate OCL CPU RT + shell: pwsh + run: | + $script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1" + if (Test-Path $script_path) { + &$script_path + } else { + Write-Warning "File $script_path was NOT found!" + } + # Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default + $cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg" + Get-Content -Tail 5 -Path $cl_cfg + + - name: Smoke test + run: | + python -c "import dpnp, dpctl; dpctl.lsplatform()" + python -c "import dpnp; print(dpnp.__version__)" + - name: Run full tests if: matrix.python == '3.12' env: diff --git a/dpnp/tests/third_party/cupy/testing/_loops.py b/dpnp/tests/third_party/cupy/testing/_loops.py index ff604493c6d..686d7f9d0b1 100644 --- a/dpnp/tests/third_party/cupy/testing/_loops.py +++ b/dpnp/tests/third_party/cupy/testing/_loops.py @@ -1049,7 +1049,7 @@ def _get_int_dtypes(): _complex_dtypes = _get_supported_complex_dtypes() _regular_float_dtypes = _get_supported_float_dtypes() -_float_dtypes = _regular_float_dtypes + (numpy.float16,) +_float_dtypes = _regular_float_dtypes # + (numpy.float16,) _signed_dtypes = tuple(numpy.dtype(i).type for i in "bhilq") _unsigned_dtypes = tuple(numpy.dtype(i).type for i in "BHILQ") _int_dtypes = _get_int_dtypes() From 67244af5de215c97e22c4a0c2eca386b8156142e Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 11 Dec 2024 14:10:40 +0100 Subject: [PATCH 06/10] Some stuff --- .github/workflows/conda-package.yml | 4 +- dpnp/tests/config.py | 5 +- dpnp/tests/helper.py | 22 ++++++++- dpnp/tests/test_absolute.py | 4 +- dpnp/tests/test_arraycreation.py | 9 +++- .../cupy/random_tests/test_distributions.py | 6 ++- dpnp/tests/third_party/cupy/testing/_loops.py | 49 ++++++++++++++++--- 7 files changed, 81 insertions(+), 18 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 11f791ebaa2..76e578a5813 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -272,7 +272,7 @@ jobs: - name: Run full tests env: - DPNP_TEST_ALL_TYPES: 1 + DPNP_TEST_ALL_INT_TYPES: 1 run: | pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests @@ -527,7 +527,7 @@ jobs: - name: Run full tests if: matrix.python == '3.12' env: - DPNP_TEST_ALL_TYPES: 1 + DPNP_TEST_ALL_INT_TYPES: 1 run: | pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests diff --git a/dpnp/tests/config.py b/dpnp/tests/config.py index 322cffadfa0..0069efe23ee 100644 --- a/dpnp/tests/config.py +++ b/dpnp/tests/config.py @@ -1,3 +1,6 @@ import os -all_types = int(os.getenv("DPNP_TEST_ALL_TYPES", 0)) +all_int_types = int(os.getenv("DPNP_TEST_ALL_INT_TYPES", 0)) +float16_types = int(os.getenv("DPNP_TEST_FLOAT_16", 0)) +complex_types = int(os.getenv("DPNP_TEST_COMPLEX_TYPES", 0)) +bool_types = int(os.getenv("DPNP_TEST_BOOL_TYPES", 0)) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index 0a55f13cbe7..f2e6a8fa830 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -89,7 +89,7 @@ def get_integer_dtypes(): Build a list of integer types supported by DPNP. """ - if config.all_types: + if config.all_int_types: return [ dpnp.int8, dpnp.int16, @@ -147,7 +147,13 @@ def get_float_complex_dtypes(no_float16=True, device=None): def get_all_dtypes( - no_bool=False, no_float16=True, no_complex=False, no_none=False, device=None + no_bool=False, + no_float16=True, + no_complex=False, + no_none=False, + device=None, + xfail_dtypes=None, + exclude=None, ): """ Build a list of types supported by DPNP based on input flags and device capabilities. @@ -171,6 +177,18 @@ def get_all_dtypes( # add None value to validate a default dtype if not no_none: dtypes.append(None) + + def mark_xfail(dtype): + if xfail_dtypes is not None and dtype in xfail_dtypes: + return pytest.param(dtype, marks=pytest.mark.xfail) + return dtype + + def not_excluded(dtype): + if exclude is None: + return True + return dtype not in exclude + + dtypes = [mark_xfail(dtype) for dtype in dtypes if not_excluded(dtype)] return dtypes diff --git a/dpnp/tests/test_absolute.py b/dpnp/tests/test_absolute.py index 1c6a42e98c6..3f5c4860f24 100644 --- a/dpnp/tests/test_absolute.py +++ b/dpnp/tests/test_absolute.py @@ -13,9 +13,9 @@ @pytest.mark.parametrize("func", ["abs", "absolute"]) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) def test_abs(func, dtype): - a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9], dtype=dtype) + a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9]).astype(dtype=dtype) ia = dpnp.array(a) result = getattr(dpnp, func)(ia) diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index 909d4d464b0..d892faf9d48 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -708,10 +708,17 @@ def test_dpctl_tensor_input(func, args): ids=["1", "5", "numpy.array(10)", "dpnp.array(17)", "dpt.asarray(100)"], ) @pytest.mark.parametrize( - "dtype", get_all_dtypes(no_bool=True, no_float16=False) + "dtype", + get_all_dtypes( + no_bool=True, no_float16=False, exclude=[numpy.uint8, dpnp.int8] + ), ) @pytest.mark.parametrize("retstep", [True, False]) def test_linspace(start, stop, num, dtype, retstep): + if numpy.issubdtype(dtype, numpy.unsignedinteger): + start = abs(start) + stop = abs(stop) + res_np = numpy.linspace(start, stop, num, dtype=dtype, retstep=retstep) res_dp = dpnp.linspace(start, stop, num, dtype=dtype, retstep=retstep) diff --git a/dpnp/tests/third_party/cupy/random_tests/test_distributions.py b/dpnp/tests/third_party/cupy/random_tests/test_distributions.py index 16ad014645a..93781d009d0 100644 --- a/dpnp/tests/third_party/cupy/random_tests/test_distributions.py +++ b/dpnp/tests/third_party/cupy/random_tests/test_distributions.py @@ -22,7 +22,7 @@ def check_distribution(self, dist_name, params, dtype=None): np_out = numpy.asarray( getattr(numpy.random, dist_name)(size=self.shape, **params), dtype ) - dt_kward = {dtype: dtype} if dtype else {} + dt_kward = {"dtype": dtype} if dtype else {} cp_out = getattr(_distributions, dist_name)( size=self.shape, **dt_kward, **cp_params ) @@ -72,12 +72,14 @@ def test_beta(self, a_dtype, b_dtype): "shape": [(4, 3, 2), (3, 2)], "n_shape": [(), (3, 2)], "p_shape": [(), (3, 2)], - "dtype": _int_dtypes, # to escape timeout + # "dtype": _int_dtypes, # to escape timeout + "dtype": [None], # no dtype supported } ) ) class TestDistributionsBinomial(RandomDistributionsTestCase): + @pytest.mark.skip() @testing.for_signed_dtypes("n_dtype") @testing.for_float_dtypes("p_dtype") def test_binomial(self, n_dtype, p_dtype): diff --git a/dpnp/tests/third_party/cupy/testing/_loops.py b/dpnp/tests/third_party/cupy/testing/_loops.py index 686d7f9d0b1..e9a0fde7104 100644 --- a/dpnp/tests/third_party/cupy/testing/_loops.py +++ b/dpnp/tests/third_party/cupy/testing/_loops.py @@ -8,6 +8,7 @@ from typing import Tuple, Type import numpy +import pytest from dpctl import select_default_device from dpctl.tensor._numpy_helper import AxisError @@ -979,7 +980,7 @@ def test_func(*args, **kw): return decorator -def for_dtypes(dtypes, name="dtype"): +def for_dtypes(dtypes, name="dtype", xfail_dtypes=None): """Decorator for parameterized dtype test. Args: @@ -1010,7 +1011,11 @@ def test_func(*args, **kw): try: kw[name] = numpy.dtype(dtype).type - impl(*args, **kw) + if xfail_dtypes is not None and dtype in xfail_dtypes: + impl_ = pytest.mark.xfail(impl) + else: + impl_ = impl + impl_(*args, **kw) except _skip_classes as e: print("skipped: {} = {} ({})".format(name, dtype, e)) except Exception: @@ -1041,19 +1046,47 @@ def _get_supported_complex_dtypes(): def _get_int_dtypes(): - if config.all_types: + if config.all_int_types: return _signed_dtypes + _unsigned_dtypes else: return (numpy.int64, numpy.int32) +def _get_float_dtypes(): + if config.float16_types: + return _regular_float_dtypes + (numpy.float16,) + else: + return _regular_float_dtypes + + +def _get_signed_dtypes(): + if config.all_int_types: + return tuple(numpy.dtype(i).type for i in "bhilq") + else: + return (numpy.int32,) + + +def _get_unsigned_dtypes(): + if config.all_int_types: + return tuple(numpy.dtype(i).type for i in "BHILQ") + else: + return (numpy.uint32,) + + +def _get_int_bool_dtypes(): + if config.bool_types: + return _int_dtypes + (numpy.bool_,) + else: + return _int_dtypes + + _complex_dtypes = _get_supported_complex_dtypes() _regular_float_dtypes = _get_supported_float_dtypes() -_float_dtypes = _regular_float_dtypes # + (numpy.float16,) -_signed_dtypes = tuple(numpy.dtype(i).type for i in "bhilq") -_unsigned_dtypes = tuple(numpy.dtype(i).type for i in "BHILQ") +_float_dtypes = _get_float_dtypes() +_signed_dtypes = _get_signed_dtypes() +_unsigned_dtypes = _get_unsigned_dtypes() _int_dtypes = _get_int_dtypes() -_int_bool_dtypes = _int_dtypes + (numpy.bool_,) +_int_bool_dtypes = _get_int_bool_dtypes() _regular_dtypes = _regular_float_dtypes + _int_bool_dtypes _dtypes = _float_dtypes + _int_bool_dtypes @@ -1069,7 +1102,7 @@ def _make_all_dtypes(no_float16, no_bool, no_complex): else: dtypes += _int_bool_dtypes - if not no_complex: + if config.complex_types and not no_complex: dtypes += _complex_dtypes return dtypes From 2b83fcec83321f84f8b963763c10aa6d2ca4108f Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 11 Dec 2024 14:22:47 +0100 Subject: [PATCH 07/10] Restore timeout --- .github/workflows/conda-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index 76e578a5813..8ff31e7205e 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -182,7 +182,7 @@ jobs: id: run_tests_linux uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0 with: - timeout_minutes: 45 + timeout_minutes: 10 max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }} retry_on: any command: | From 148c7d35633bc599170871b753cdcdcae755e261 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 11 Dec 2024 14:27:53 +0100 Subject: [PATCH 08/10] do not exclude [u]int8 from linspace --- dpnp/tests/test_arraycreation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dpnp/tests/test_arraycreation.py b/dpnp/tests/test_arraycreation.py index d892faf9d48..445c348a95d 100644 --- a/dpnp/tests/test_arraycreation.py +++ b/dpnp/tests/test_arraycreation.py @@ -709,9 +709,7 @@ def test_dpctl_tensor_input(func, args): ) @pytest.mark.parametrize( "dtype", - get_all_dtypes( - no_bool=True, no_float16=False, exclude=[numpy.uint8, dpnp.int8] - ), + get_all_dtypes(no_bool=True, no_float16=False), ) @pytest.mark.parametrize("retstep", [True, False]) def test_linspace(start, stop, num, dtype, retstep): From 8ea4606026a462b3128b1749fcc549fd5d0ef676 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 11 Dec 2024 14:44:13 +0100 Subject: [PATCH 09/10] Add reson for skiping test_binomial --- dpnp/tests/third_party/cupy/random_tests/test_distributions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpnp/tests/third_party/cupy/random_tests/test_distributions.py b/dpnp/tests/third_party/cupy/random_tests/test_distributions.py index 93781d009d0..ebed860fd29 100644 --- a/dpnp/tests/third_party/cupy/random_tests/test_distributions.py +++ b/dpnp/tests/third_party/cupy/random_tests/test_distributions.py @@ -79,7 +79,7 @@ def test_beta(self, a_dtype, b_dtype): ) class TestDistributionsBinomial(RandomDistributionsTestCase): - @pytest.mark.skip() + @pytest.mark.skip("n and p params as arrays are not supported") @testing.for_signed_dtypes("n_dtype") @testing.for_float_dtypes("p_dtype") def test_binomial(self, n_dtype, p_dtype): From 209d447f22376895eae11a2c249ea93926b5bc01 Mon Sep 17 00:00:00 2001 From: Alexander Kalistratov Date: Wed, 11 Dec 2024 15:09:49 +0100 Subject: [PATCH 10/10] Fix import error & la.Norm tests --- dpnp/tests/helper.py | 1 + dpnp/tests/test_linalg.py | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dpnp/tests/helper.py b/dpnp/tests/helper.py index f2e6a8fa830..44945dc4c8b 100644 --- a/dpnp/tests/helper.py +++ b/dpnp/tests/helper.py @@ -2,6 +2,7 @@ import dpctl import numpy +import pytest from numpy.testing import assert_allclose, assert_array_equal import dpnp diff --git a/dpnp/tests/test_linalg.py b/dpnp/tests/test_linalg.py index 810258d3f3f..f239adae84f 100644 --- a/dpnp/tests/test_linalg.py +++ b/dpnp/tests/test_linalg.py @@ -2124,7 +2124,9 @@ def test_0D(self, ord, axis): assert_dtype_allclose(result, expected) @pytest.mark.usefixtures("suppress_divide_numpy_warnings") - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(xfail_dtypes=[dpnp.uint64]) + ) @pytest.mark.parametrize( "ord", [None, -dpnp.inf, -2, -1, 0, 1, 2, 3.5, dpnp.inf] ) @@ -2139,7 +2141,9 @@ def test_1D(self, dtype, ord, axis, keepdims): assert_dtype_allclose(result, expected) @pytest.mark.usefixtures("suppress_divide_numpy_warnings") - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize( + "dtype", get_all_dtypes(xfail_dtypes=[dpnp.uint64]) + ) @pytest.mark.parametrize( "ord", [None, -dpnp.inf, -2, -1, 1, 2, 3, dpnp.inf, "fro", "nuc"] ) @@ -2164,7 +2168,12 @@ def test_2D(self, dtype, ord, axis, keepdims): assert_dtype_allclose(result, expected) @pytest.mark.usefixtures("suppress_divide_numpy_warnings") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize( + "dtype", + get_all_dtypes( + no_none=True, xfail_dtypes=[dpnp.uint16, dpnp.uint32, dpnp.uint64] + ), + ) @pytest.mark.parametrize( "ord", [None, -dpnp.inf, -2, -1, 1, 2, 3, dpnp.inf, "fro", "nuc"] ) @@ -2195,7 +2204,10 @@ def test_ND(self, dtype, ord, axis, keepdims): assert_dtype_allclose(result, expected) @pytest.mark.usefixtures("suppress_divide_numpy_warnings") - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize( + "dtype", + get_all_dtypes(xfail_dtypes=[dpnp.uint16, dpnp.uint32, dpnp.uint64]), + ) @pytest.mark.parametrize( "ord", [None, -dpnp.inf, -2, -1, 1, 2, 3, dpnp.inf, "fro", "nuc"] )