From 9209351ae4960be3dd381c278b2eca98af09e7de Mon Sep 17 00:00:00 2001 From: Anton <100830759+antonwolfy@users.noreply.github.com> Date: Mon, 23 Jan 2023 18:04:28 +0100 Subject: [PATCH] Add support of NumPy 1.24 (#1276) * Set minimum required versions & fix debug building * Add support of numpy 1.24 --- conda-recipe/meta.yaml | 2 +- dpnp/backend/include/dpnp_iface_fptr.hpp | 4 +-- dpnp/dparray.pyx | 10 +++--- dpnp/dpnp_algo/dpnp_algo.pyx | 2 +- dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx | 4 +-- dpnp/dpnp_array.py | 6 ++-- dpnp/dpnp_iface_arraycreation.py | 6 ++-- dpnp/dpnp_iface_mathematical.py | 6 ++-- dpnp/dpnp_iface_statistics.py | 6 ++-- dpnp/dpnp_iface_types.py | 8 ++--- dpnp/dpnp_utils/dpnp_algo_utils.pyx | 4 +-- examples/example4.py | 8 ++--- tests/skipped_tests.tbl | 14 +------- tests/skipped_tests_gpu.tbl | 14 +------- tests/test_arraycreation.py | 24 ++++++------- tests/test_dparray.py | 14 ++++---- tests/test_logic.py | 8 ++--- tests/test_random_state.py | 36 +++++++++++-------- .../cupy/creation_tests/test_ranges.py | 2 +- .../cupy/indexing_tests/test_generate.py | 2 +- .../cupy/indexing_tests/test_insert.py | 2 +- .../cupy/math_tests/test_arithmetic.py | 5 +-- 22 files changed, 85 insertions(+), 102 deletions(-) diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 6004b945bb6..3e411e354a9 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -8,7 +8,7 @@ requirements: host: - python - setuptools - - numpy >=1.19,<1.23a0 + - numpy >=1.19,<1.25a0 - cython - cmake >=3.19 - dpctl >=0.13 diff --git a/dpnp/backend/include/dpnp_iface_fptr.hpp b/dpnp/backend/include/dpnp_iface_fptr.hpp index 8e209d38317..126fdd24f3b 100644 --- a/dpnp/backend/include/dpnp_iface_fptr.hpp +++ b/dpnp/backend/include/dpnp_iface_fptr.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// Copyright (c) 2016-2022, Intel Corporation +// Copyright (c) 2016-2023, Intel Corporation // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -391,7 +391,7 @@ enum class DPNPFuncType : size_t DPNP_FT_DOUBLE, /**< analog of numpy.float32 or double */ DPNP_FT_CMPLX64, /**< analog of numpy.complex64 or std::complex */ DPNP_FT_CMPLX128, /**< analog of numpy.complex128 or std::complex */ - DPNP_FT_BOOL /**< analog of numpy.bool or numpy.bool_ or bool */ + DPNP_FT_BOOL /**< analog of numpy.bool_ or bool */ }; /** diff --git a/dpnp/dparray.pyx b/dpnp/dparray.pyx index 859bf49d59a..dffbf6f65d1 100644 --- a/dpnp/dparray.pyx +++ b/dpnp/dparray.pyx @@ -1,7 +1,7 @@ # cython: language_level=3 # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -462,7 +462,7 @@ cdef class dparray: return ( < long * > self._dparray_data)[lin_idx] elif self.dtype == numpy.int32: return ( < int * > self._dparray_data)[lin_idx] - elif self.dtype == numpy.bool: + elif self.dtype == numpy.bool_: return ( < cpp_bool * > self._dparray_data)[lin_idx] elif self.dtype == numpy.complex128: return ( < double complex * > self._dparray_data)[lin_idx] @@ -489,7 +489,7 @@ cdef class dparray: ( < long * > self._dparray_data)[lin_idx] = value elif self.dtype == numpy.int32: ( < int * > self._dparray_data)[lin_idx] = value - elif self.dtype == numpy.bool: + elif self.dtype == numpy.bool_: ( < cpp_bool * > self._dparray_data)[lin_idx] = < cpp_bool > value elif self.dtype == numpy.complex64: ( < float complex * > self._dparray_data)[lin_idx] = value @@ -876,7 +876,7 @@ cdef class dparray: """ - if not numpy.issubsctype(self.dtype, numpy.complex): + if not numpy.issubsctype(self.dtype, numpy.complex_): return self else: return conjugate(self) @@ -889,7 +889,7 @@ cdef class dparray: """ - if not numpy.issubsctype(self.dtype, numpy.complex): + if not numpy.issubsctype(self.dtype, numpy.complex_): return self else: return conjugate(self) diff --git a/dpnp/dpnp_algo/dpnp_algo.pyx b/dpnp/dpnp_algo/dpnp_algo.pyx index a41be19b606..aaa7334e18a 100644 --- a/dpnp/dpnp_algo/dpnp_algo.pyx +++ b/dpnp/dpnp_algo/dpnp_algo.pyx @@ -276,7 +276,7 @@ cdef dpnp_DPNPFuncType_to_dtype(size_t type): elif type == DPNP_FT_CMPLX128: return numpy.complex128 elif type == DPNP_FT_BOOL: - return numpy.bool + return numpy.bool_ else: utils.checker_throw_type_error("dpnp_DPNPFuncType_to_dtype", type) diff --git a/dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx b/dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx index c1c24a27747..1ec69c55311 100644 --- a/dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx +++ b/dpnp/dpnp_algo/dpnp_algo_arraycreation.pyx @@ -1,7 +1,7 @@ # cython: language_level=3 # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -434,7 +434,7 @@ cpdef utils.dpnp_descriptor dpnp_trace(utils.dpnp_descriptor arr, offset=0, axis return result -cpdef utils.dpnp_descriptor dpnp_tri(N, M=None, k=0, dtype=numpy.float): +cpdef utils.dpnp_descriptor dpnp_tri(N, M=None, k=0, dtype=dpnp.float): if M is None: M = N diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 82c271fa7d9..57f057ae760 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -493,7 +493,7 @@ def conj(self): """ - if not numpy.issubsctype(self.dtype, numpy.complex): + if not numpy.issubsctype(self.dtype, numpy.complex_): return self else: return dpnp.conjugate(self) @@ -506,7 +506,7 @@ def conjugate(self): """ - if not numpy.issubsctype(self.dtype, numpy.complex): + if not numpy.issubsctype(self.dtype, numpy.complex_): return self else: return dpnp.conjugate(self) diff --git a/dpnp/dpnp_iface_arraycreation.py b/dpnp/dpnp_iface_arraycreation.py index 5fb4d8c7a4d..03d8b818520 100644 --- a/dpnp/dpnp_iface_arraycreation.py +++ b/dpnp/dpnp_iface_arraycreation.py @@ -2,7 +2,7 @@ # distutils: language = c++ # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -1280,7 +1280,7 @@ def trace(x1, offset=0, axis1=0, axis2=1, dtype=None, out=None): return call_origin(numpy.trace, x1, offset, axis1, axis2, dtype, out) -def tri(N, M=None, k=0, dtype=numpy.float, **kwargs): +def tri(N, M=None, k=0, dtype=dpnp.float, **kwargs): """ An array with ones at and below the given diagonal and zeros elsewhere. @@ -1315,7 +1315,7 @@ def tri(N, M=None, k=0, dtype=numpy.float, **kwargs): elif not isinstance(k, int): pass else: - if dtype is numpy.float: + if dtype is dpnp.float: sycl_queue = dpnp.get_normalized_queue_device(sycl_queue=None, device=None) dtype = map_dtype_to_device(dpnp.float64, sycl_queue.sycl_device) return dpnp_tri(N, M, k, dtype).get_pyobj() diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 26b81a67dd9..ce9f340e8e4 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -2,7 +2,7 @@ # distutils: language = c++ # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -1545,11 +1545,11 @@ def subtract(x1, x2, dtype=None, out=None, where=True, **kwargs): pass elif x1_desc and x1_desc.ndim == 0: pass - elif x1_desc and x1_desc.dtype == numpy.bool: + elif x1_desc and x1_desc.dtype == dpnp.bool: pass elif x2_desc and x2_desc.ndim == 0: pass - elif x2_desc and x2_desc.dtype == numpy.bool: + elif x2_desc and x2_desc.dtype == dpnp.bool: pass elif dtype is not None: pass diff --git a/dpnp/dpnp_iface_statistics.py b/dpnp/dpnp_iface_statistics.py index 27eaf4a115f..ab92f8cc625 100644 --- a/dpnp/dpnp_iface_statistics.py +++ b/dpnp/dpnp_iface_statistics.py @@ -2,7 +2,7 @@ # distutils: language = c++ # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2020, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -299,7 +299,7 @@ def cov(x1, y=None, rowvar=True, bias=False, ddof=None, fweights=None, aweights= return call_origin(numpy.cov, x1, y, rowvar, bias, ddof, fweights, aweights) -def histogram(a, bins=10, range=None, normed=None, weights=None, density=None): +def histogram(a, bins=10, range=None, density=None, weights=None): """ Compute the histogram of a dataset. For full documentation refer to :obj:`numpy.histogram`. @@ -323,7 +323,7 @@ def histogram(a, bins=10, range=None, normed=None, weights=None, density=None): 1.0 """ - return call_origin(numpy.histogram, a=a, bins=bins, range=range, normed=normed, weights=weights, density=density) + return call_origin(numpy.histogram, a=a, bins=bins, range=range, density=density, weights=weights) def max(x1, axis=None, out=None, keepdims=False, initial=None, where=True): diff --git a/dpnp/dpnp_iface_types.py b/dpnp/dpnp_iface_types.py index dfcf599bf3b..787dcaa473b 100644 --- a/dpnp/dpnp_iface_types.py +++ b/dpnp/dpnp_iface_types.py @@ -2,7 +2,7 @@ # distutils: language = c++ # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2020, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -59,7 +59,7 @@ "void" ] -bool = numpy.bool +bool = numpy.bool_ bool_ = numpy.bool_ complex128 = numpy.complex128 complex64 = numpy.complex64 @@ -67,11 +67,11 @@ float16 = numpy.float16 float32 = numpy.float32 float64 = numpy.float64 -float = numpy.float +float = numpy.float_ int32 = numpy.int32 int64 = numpy.int64 integer = numpy.integer -int = numpy.int +int = numpy.int_ longcomplex = numpy.longcomplex diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index c09bef8ec48..2e04dd96bd6 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -1,7 +1,7 @@ # cython: language_level=3 # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2022, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -399,7 +399,7 @@ cdef tuple get_shape_dtype(object input_obj): # shape and dtype does not match with siblings. if ((return_shape != elem_shape) or (return_dtype != elem_dtype)): - return (elem_shape, numpy.dtype(numpy.object)) + return (elem_shape, numpy.dtype(numpy.object_)) list_shape.push_back(len(input_obj)) list_shape.insert(list_shape.end(), return_shape.begin(), return_shape.end()) diff --git a/examples/example4.py b/examples/example4.py index 0790f84d10a..6705149d52b 100755 --- a/examples/example4.py +++ b/examples/example4.py @@ -1,7 +1,7 @@ # cython: language_level=3 # -*- coding: utf-8 -*- # ***************************************************************************** -# Copyright (c) 2016-2020, Intel Corporation +# Copyright (c) 2016-2023, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -40,7 +40,7 @@ """ for function in [numpy.sqrt, numpy.fabs, numpy.reciprocal, numpy.square, numpy.cbrt, numpy.degrees, numpy.radians]: print() - for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]: + for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]: data = numpy.array([1, 2, 3, 4], dtype=test_type) result = function(data) print(f"input:{data.dtype.name:10}: outout:{result.dtype.name:10}: name:{function.__name__}") @@ -50,8 +50,8 @@ """ for function in [numpy.equal, numpy.arctan2]: print() - for input1_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]: - for input2_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool]: + for input1_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]: + for input2_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_]: data1 = numpy.array([1, 2, 3, 4], dtype=input1_type) data2 = numpy.array([11, 21, 31, 41], dtype=input2_type) result = function(data1, data2) diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index b8b02e95bbf..df4a1423650 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -35,54 +35,42 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct tests/test_arraymanipulation.py::TestHstack::test_generator tests/test_arraymanipulation.py::TestVstack::test_generator + tests/test_dparray.py::test_astype[[]-float64-float64] tests/test_dparray.py::test_astype[[]-float64-float32] tests/test_dparray.py::test_astype[[]-float64-int64] tests/test_dparray.py::test_astype[[]-float64-int32] tests/test_dparray.py::test_astype[[]-float64-bool] -tests/test_dparray.py::test_astype[[]-float64-bool_] tests/test_dparray.py::test_astype[[]-float64-complex] tests/test_dparray.py::test_astype[[]-float32-float64] tests/test_dparray.py::test_astype[[]-float32-float32] tests/test_dparray.py::test_astype[[]-float32-int64] tests/test_dparray.py::test_astype[[]-float32-int32] tests/test_dparray.py::test_astype[[]-float32-bool] -tests/test_dparray.py::test_astype[[]-float32-bool_] tests/test_dparray.py::test_astype[[]-float32-complex] tests/test_dparray.py::test_astype[[]-int64-float64] tests/test_dparray.py::test_astype[[]-int64-float32] tests/test_dparray.py::test_astype[[]-int64-int64] tests/test_dparray.py::test_astype[[]-int64-int32] tests/test_dparray.py::test_astype[[]-int64-bool] -tests/test_dparray.py::test_astype[[]-int64-bool_] tests/test_dparray.py::test_astype[[]-int64-complex] tests/test_dparray.py::test_astype[[]-int32-float64] tests/test_dparray.py::test_astype[[]-int32-float32] tests/test_dparray.py::test_astype[[]-int32-int64] tests/test_dparray.py::test_astype[[]-int32-int32] tests/test_dparray.py::test_astype[[]-int32-bool] -tests/test_dparray.py::test_astype[[]-int32-bool_] tests/test_dparray.py::test_astype[[]-int32-complex] tests/test_dparray.py::test_astype[[]-bool-float64] tests/test_dparray.py::test_astype[[]-bool-float32] tests/test_dparray.py::test_astype[[]-bool-int64] tests/test_dparray.py::test_astype[[]-bool-int32] tests/test_dparray.py::test_astype[[]-bool-bool] -tests/test_dparray.py::test_astype[[]-bool-bool_] tests/test_dparray.py::test_astype[[]-bool-complex] -tests/test_dparray.py::test_astype[[]-bool_-float64] -tests/test_dparray.py::test_astype[[]-bool_-float32] -tests/test_dparray.py::test_astype[[]-bool_-int64] -tests/test_dparray.py::test_astype[[]-bool_-int32] -tests/test_dparray.py::test_astype[[]-bool_-bool] -tests/test_dparray.py::test_astype[[]-bool_-bool_] -tests/test_dparray.py::test_astype[[]-bool_-complex] tests/test_dparray.py::test_astype[[]-complex-float64] tests/test_dparray.py::test_astype[[]-complex-float32] tests/test_dparray.py::test_astype[[]-complex-int64] tests/test_dparray.py::test_astype[[]-complex-int32] tests/test_dparray.py::test_astype[[]-complex-bool] -tests/test_dparray.py::test_astype[[]-complex-bool_] tests/test_dparray.py::test_astype[[]-complex-complex] tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]] diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index 01a2bb21dc9..5426e386bbc 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -301,54 +301,42 @@ tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_3_{extern tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpctl_memory tests/test_arraymanipulation.py::TestHstack::test_generator tests/test_arraymanipulation.py::TestVstack::test_generator + tests/test_dparray.py::test_astype[[]-float64-float64] tests/test_dparray.py::test_astype[[]-float64-float32] tests/test_dparray.py::test_astype[[]-float64-int64] tests/test_dparray.py::test_astype[[]-float64-int32] tests/test_dparray.py::test_astype[[]-float64-bool] -tests/test_dparray.py::test_astype[[]-float64-bool_] tests/test_dparray.py::test_astype[[]-float64-complex] tests/test_dparray.py::test_astype[[]-float32-float64] tests/test_dparray.py::test_astype[[]-float32-float32] tests/test_dparray.py::test_astype[[]-float32-int64] tests/test_dparray.py::test_astype[[]-float32-int32] tests/test_dparray.py::test_astype[[]-float32-bool] -tests/test_dparray.py::test_astype[[]-float32-bool_] tests/test_dparray.py::test_astype[[]-float32-complex] tests/test_dparray.py::test_astype[[]-int64-float64] tests/test_dparray.py::test_astype[[]-int64-float32] tests/test_dparray.py::test_astype[[]-int64-int64] tests/test_dparray.py::test_astype[[]-int64-int32] tests/test_dparray.py::test_astype[[]-int64-bool] -tests/test_dparray.py::test_astype[[]-int64-bool_] tests/test_dparray.py::test_astype[[]-int64-complex] tests/test_dparray.py::test_astype[[]-int32-float64] tests/test_dparray.py::test_astype[[]-int32-float32] tests/test_dparray.py::test_astype[[]-int32-int64] tests/test_dparray.py::test_astype[[]-int32-int32] tests/test_dparray.py::test_astype[[]-int32-bool] -tests/test_dparray.py::test_astype[[]-int32-bool_] tests/test_dparray.py::test_astype[[]-int32-complex] tests/test_dparray.py::test_astype[[]-bool-float64] tests/test_dparray.py::test_astype[[]-bool-float32] tests/test_dparray.py::test_astype[[]-bool-int64] tests/test_dparray.py::test_astype[[]-bool-int32] tests/test_dparray.py::test_astype[[]-bool-bool] -tests/test_dparray.py::test_astype[[]-bool-bool_] tests/test_dparray.py::test_astype[[]-bool-complex] -tests/test_dparray.py::test_astype[[]-bool_-float64] -tests/test_dparray.py::test_astype[[]-bool_-float32] -tests/test_dparray.py::test_astype[[]-bool_-int64] -tests/test_dparray.py::test_astype[[]-bool_-int32] -tests/test_dparray.py::test_astype[[]-bool_-bool] -tests/test_dparray.py::test_astype[[]-bool_-bool_] -tests/test_dparray.py::test_astype[[]-bool_-complex] tests/test_dparray.py::test_astype[[]-complex-float64] tests/test_dparray.py::test_astype[[]-complex-float32] tests/test_dparray.py::test_astype[[]-complex-int64] tests/test_dparray.py::test_astype[[]-complex-int32] tests/test_dparray.py::test_astype[[]-complex-bool] -tests/test_dparray.py::test_astype[[]-complex-bool_] tests/test_dparray.py::test_astype[[]-complex-complex] tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]] diff --git a/tests/test_arraycreation.py b/tests/test_arraycreation.py index 5bb9795bbac..e0500848e9b 100644 --- a/tests/test_arraycreation.py +++ b/tests/test_arraycreation.py @@ -246,7 +246,7 @@ def test_geomspace(dtype, num, endpoint): ids=['0', '1', '4']) @pytest.mark.parametrize("dtype", [numpy.float64, numpy.float32, numpy.int64, numpy.int32, - numpy.bool, numpy.complex64, numpy.complex128, None], + numpy.bool_, numpy.complex64, numpy.complex128, None], ids=['float64', 'float32', 'int64', 'int32', 'bool', 'complex64', 'complex128', 'None']) def test_identity(n, dtype): @@ -344,8 +344,8 @@ def test_trace(array, offset, type, dtype): [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], ids=['-5', '-4', '-3', '-2', '-1', '0', '1', '2', '3', '4', '5']) @pytest.mark.parametrize("dtype", - [numpy.float64, numpy.float32, float, numpy.int64, numpy.int32, numpy.int, numpy.float, int], - ids=['float64', 'float32', 'numpy.float', 'float', 'int64', 'int32', 'numpy.int', 'int']) + [numpy.float64, numpy.float32, float, numpy.int64, numpy.int32, numpy.int_, numpy.float_, int], + ids=['numpy.float64', 'numpy.float32', 'float', 'numpy.int64', 'numpy.int32', 'numpy.int', 'numpy.float', 'int']) def test_tri(N, M, k, dtype): func = lambda xp: xp.tri(N, M, k, dtype=dtype) @@ -428,7 +428,7 @@ def test_triu_size_null(k): '[0, 3, 5]']) @pytest.mark.parametrize("dtype", [numpy.float64, numpy.float32, numpy.int64, numpy.int32, - numpy.bool, numpy.complex64, numpy.complex128], + numpy.bool_, numpy.complex64, numpy.complex128], ids=['float64', 'float32', 'int64', 'int32', 'bool', 'complex64', 'complex128']) @pytest.mark.parametrize("n", @@ -464,7 +464,7 @@ def test_vander(array, dtype, n, increase): ids=['1.5', '2', '1.5+0.j']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -488,7 +488,7 @@ def test_full(shape, fill_value, dtype, order): ids=['1.5', '2', '1.5+0.j']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -545,7 +545,7 @@ def test_full_invalid_fill_value(fill_value): ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -563,7 +563,7 @@ def test_zeros(shape, dtype, order): ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -584,7 +584,7 @@ def test_zeros_like(array, dtype, order): ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -602,7 +602,7 @@ def test_empty(shape, dtype, order): ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -623,7 +623,7 @@ def test_empty_like(array, dtype, order): ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", @@ -644,7 +644,7 @@ def test_ones(shape, dtype, order): ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) @pytest.mark.parametrize("dtype", [None, numpy.complex128, numpy.complex64, numpy.float64, numpy.float32, - numpy.float16, numpy.int64, numpy.int32, numpy.bool], + numpy.float16, numpy.int64, numpy.int32, numpy.bool_], ids=['None', 'complex128', 'complex64', 'float64', 'float32', 'float16', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("order", diff --git a/tests/test_dparray.py b/tests/test_dparray.py index 6ff1672b853..745884f6a07 100644 --- a/tests/test_dparray.py +++ b/tests/test_dparray.py @@ -5,11 +5,11 @@ @pytest.mark.parametrize("res_dtype", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_, numpy.complex], - ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_', 'complex']) + [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_, numpy.complex_], + ids=['float64', 'float32', 'int64', 'int32', 'bool', 'complex']) @pytest.mark.parametrize("arr_dtype", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_, numpy.complex], - ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_', 'complex']) + [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_, numpy.complex_], + ids=['float64', 'float32', 'int64', 'int32', 'bool', 'complex']) @pytest.mark.parametrize("arr", [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], ids=['[-2, -1, 0, 1, 2]', '[[-2, -1], [1, 2]]', '[]']) @@ -22,8 +22,8 @@ def test_astype(arr, arr_dtype, res_dtype): @pytest.mark.parametrize("arr_dtype", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_, numpy.complex], - ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_', 'complex']) + [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_, numpy.complex_], + ids=['float64', 'float32', 'int64', 'int32', 'bool', 'complex']) @pytest.mark.parametrize("arr", [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], ids=['[-2, -1, 0, 1, 2]', '[[-2, -1], [1, 2]]', '[]']) @@ -51,7 +51,7 @@ def test_flags(shape, order): @pytest.mark.parametrize("dtype", - [numpy.complex64, numpy.float32, numpy.int64, numpy.int32, numpy.bool], + [numpy.complex64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_], ids=['complex64', 'float32', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("strides", [(1, 4) , (4, 1)], diff --git a/tests/test_logic.py b/tests/test_logic.py index b3280be0761..7fefe91826f 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -6,8 +6,8 @@ @pytest.mark.parametrize("type", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_], - ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_']) + [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_], + ids=['float64', 'float32', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("shape", [(0,), (4,), (2, 3), (2, 2, 2)], ids=['(0,)', '(4,)', '(2,3)', '(2,2,2)']) @@ -63,8 +63,8 @@ def test_allclose(type): @pytest.mark.parametrize("type", - [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool, numpy.bool_], - ids=['float64', 'float32', 'int64', 'int32', 'bool', 'bool_']) + [numpy.float64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_], + ids=['float64', 'float32', 'int64', 'int32', 'bool']) @pytest.mark.parametrize("shape", [(0,), (4,), (2, 3), (2, 2, 2)], ids=['(0,)', '(4,)', '(2,3)', '(2,2,2)']) diff --git a/tests/test_random_state.py b/tests/test_random_state.py index b93f52411c5..1a5d554e14d 100644 --- a/tests/test_random_state.py +++ b/tests/test_random_state.py @@ -34,8 +34,8 @@ def get_default_floating(): class TestNormal: @pytest.mark.parametrize("dtype", - [dpnp.float32, dpnp.float64, None], - ids=['float32', 'float64', 'None']) + [dpnp.float32, dpnp.float64, dpnp.float, None], + ids=['float32', 'float64', 'float', 'None']) @pytest.mark.parametrize("usm_type", ["host", "device", "shared"], ids=['host', 'device', 'shared']) @@ -173,9 +173,9 @@ def test_fallback(self, loc, scale): @pytest.mark.parametrize("dtype", - [dpnp.float16, dpnp.float, float, dpnp.integer, dpnp.int64, dpnp.int32, dpnp.int, int, + [dpnp.float16, float, dpnp.integer, dpnp.int64, dpnp.int32, dpnp.int, int, dpnp.longcomplex, dpnp.complex128, dpnp.complex64, dpnp.bool, dpnp.bool_], - ids=['dpnp.float16', 'dpnp.float', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int32', 'dpnp.int', 'int', + ids=['dpnp.float16', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int32', 'dpnp.int', 'int', 'dpnp.longcomplex', 'dpnp.complex128', 'dpnp.complex64', 'dpnp.bool', 'dpnp.bool_']) def test_invalid_dtype(self, dtype): # dtype must be float32 or float64 @@ -257,8 +257,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, dpnp.integer], + ids=['int', 'dpnp.int32', 'dpnp.int', 'dpnp.integer']) @pytest.mark.parametrize("usm_type", ["host", "device", "shared"], ids=['host', 'device', 'shared']) @@ -267,6 +267,9 @@ def test_distr(self, dtype, usm_type): low = 1 high = 10 + if dtype in (dpnp.int, dpnp.integer) and dtype != dpnp.dtype('int32'): + pytest.skip("dtype isn't alias on dpnp.int32 on the target OS, so there will be a fallback") + sycl_queue = dpctl.SyclQueue() data = RandomState(seed, sycl_queue=sycl_queue).randint(low=low, high=high, @@ -421,16 +424,16 @@ def test_bounds_fallback(self, low, high): @pytest.mark.usefixtures("allow_fall_back_on_numpy") @pytest.mark.parametrize("dtype", - [dpnp.int64, dpnp.integer, dpnp.bool, dpnp.bool_, bool], - ids=['dpnp.int64', 'dpnp.integer', 'dpnp.bool', 'dpnp.bool_', 'bool']) + [dpnp.int64, dpnp.int, dpnp.integer, dpnp.bool, dpnp.bool_, bool], + ids=['dpnp.int64', 'dpnp.int', 'dpnp.integer', 'dpnp.bool', 'dpnp.bool_', 'bool']) def test_dtype_fallback(self, dtype): seed = 157 low = -3 if not dtype in {dpnp.bool_, bool} else 0 high = 37 if not dtype in {dpnp.bool_, bool} else 2 size = (3, 2, 5) - if dtype == dpnp.integer and dtype == dpnp.dtype('int32'): - pytest.skip("dpnp.integer is alias on dpnp.int32 on the target OS, so no fallback here") + if dtype in (dpnp.int, dpnp.integer) and dtype == dpnp.dtype('int32'): + pytest.skip("dtype is alias on dpnp.int32 on the target OS, so no fallback here") # dtype must be int or dpnp.int32, in other cases it will be a fallback to numpy actual = RandomState(seed).randint(low=low, high=high, size=size, dtype=dtype).asnumpy() @@ -714,8 +717,8 @@ class TestUniform: [[1.23, 10.54], [10.54, 1.23]], ids=['(low, high)=[1.23, 10.54]', '(low, high)=[10.54, 1.23]']) @pytest.mark.parametrize("dtype", - [dpnp.float32, dpnp.float64, dpnp.int32, None], - ids=['float32', 'float64', 'int32', 'None']) + [dpnp.float32, dpnp.float64, dpnp.float, dpnp.int32, None], + ids=['float32', 'float64', 'float', 'int32', 'None']) @pytest.mark.parametrize("usm_type", ["host", "device", "shared"], ids=['host', 'device', 'shared']) @@ -831,12 +834,15 @@ def test_fallback(self, low, high): @pytest.mark.parametrize("dtype", - [dpnp.float16, dpnp.float, float, dpnp.integer, dpnp.int64, dpnp.int, int, + [dpnp.float16, float, dpnp.integer, dpnp.int64, dpnp.int, int, dpnp.longcomplex, dpnp.complex128, dpnp.complex64, dpnp.bool, dpnp.bool_], - ids=['dpnp.float16', 'dpnp.float', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int', 'int', + ids=['dpnp.float16', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int', 'int', 'dpnp.longcomplex', 'dpnp.complex128', 'dpnp.complex64', 'dpnp.bool', 'dpnp.bool_']) def test_invalid_dtype(self, dtype): - # dtype must be float32 or float64 + if dtype in (dpnp.int, dpnp.integer) and dtype == dpnp.dtype('int32'): + pytest.skip("dtype is alias on dpnp.int32 on the target OS, so no error here") + + # dtype must be int32, float32 or float64 assert_raises(TypeError, RandomState().uniform, dtype=dtype) diff --git a/tests/third_party/cupy/creation_tests/test_ranges.py b/tests/third_party/cupy/creation_tests/test_ranges.py index 75960e492c1..4d5bc03f81b 100644 --- a/tests/third_party/cupy/creation_tests/test_ranges.py +++ b/tests/third_party/cupy/creation_tests/test_ranges.py @@ -54,7 +54,7 @@ def test_arange8(self, xp, dtype): def test_arange9(self): for xp in (numpy, cupy): - with pytest.raises(ValueError): + with pytest.raises((ValueError, TypeError)): xp.arange(10, dtype=xp.bool_) @testing.numpy_cupy_array_equal() diff --git a/tests/third_party/cupy/indexing_tests/test_generate.py b/tests/third_party/cupy/indexing_tests/test_generate.py index d10e503bcec..2bb0404ab59 100644 --- a/tests/third_party/cupy/indexing_tests/test_generate.py +++ b/tests/third_party/cupy/indexing_tests/test_generate.py @@ -28,7 +28,7 @@ def test_indices_list2(self, xp, dtype): def test_indices_list3(self): for xp in (numpy, cupy): - with pytest.raises(ValueError): + with pytest.raises((ValueError, TypeError)): xp.indices((1, 2, 3, 4), dtype=xp.bool_) diff --git a/tests/third_party/cupy/indexing_tests/test_insert.py b/tests/third_party/cupy/indexing_tests/test_insert.py index ed6a156e884..fdcc5357e19 100644 --- a/tests/third_party/cupy/indexing_tests/test_insert.py +++ b/tests/third_party/cupy/indexing_tests/test_insert.py @@ -42,7 +42,7 @@ class TestPlaceRaises(unittest.TestCase): def test_place_empty_value_error(self, dtype): for xp in (numpy, cupy): a = testing.shaped_arange(self.shape, xp, dtype) - mask = testing.shaped_arange(self.shape, xp, numpy.int) % 2 == 0 + mask = testing.shaped_arange(self.shape, xp, numpy.int_) % 2 == 0 vals = testing.shaped_random((0,), xp, dtype) with pytest.raises(ValueError): xp.place(a, mask, vals) diff --git a/tests/third_party/cupy/math_tests/test_arithmetic.py b/tests/third_party/cupy/math_tests/test_arithmetic.py index 28771b4979b..158f5cc1442 100644 --- a/tests/third_party/cupy/math_tests/test_arithmetic.py +++ b/tests/third_party/cupy/math_tests/test_arithmetic.py @@ -1,5 +1,6 @@ import itertools import unittest +import warnings import numpy import pytest @@ -130,8 +131,8 @@ def check_binary(self, xp): func = getattr(xp, self.name) with testing.NumpyError(divide='ignore'): - with numpy.warnings.catch_warnings(): - numpy.warnings.filterwarnings('ignore') + with warnings.catch_warnings(): + warnings.filterwarnings('ignore') if self.use_dtype: y = func(arg1, arg2, dtype=self.dtype) else: