From da391afc02c3c40c3bb01977cddce479221174e7 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 19 Jun 2023 10:30:25 -0500 Subject: [PATCH 1/2] Added pre-commit hooks --- .pre-commit-config.yaml | 19 +- LICENSE.txt | 22 +- benchmarks/pytest_benchmark/README.md | 2 +- benchmarks/pytest_benchmark/test_random.py | 20 +- conda-recipe/build.sh | 0 conda-recipe/run_test.sh | 0 doc/Makefile | 2 +- doc/_templates/autosummary/class.rst | 2 +- doc/conf.py | 6 +- doc/reference/linalg.rst | 2 +- doc/reference/math.rst | 2 +- dpnp/__init__.py | 4 +- dpnp/backend/cmake/Modules/README.md | 2 +- dpnp/backend/cmake/Modules/TBBConfig.cmake | 14 +- dpnp/backend/cmake/Modules/oneDPLConfig.cmake | 0 dpnp/backend/kernels/dpnp_krnl_linalg.cpp | 2 +- dpnp/backend/kernels/dpnp_krnl_random.cpp | 2 +- dpnp/backend/src/dpnp_fptr.hpp | 2 +- dpnp/backend/src/dpnp_random_state.cpp | 2 +- dpnp/dpnp_algo/dpnp_elementwise_common.py | 20 +- dpnp/dpnp_array.py | 26 +- dpnp/dpnp_container.py | 50 +-- dpnp/dpnp_flatiter.py | 8 +- dpnp/dpnp_iface.py | 40 +- dpnp/dpnp_iface_arraycreation.py | 106 ++--- dpnp/dpnp_iface_bitwise.py | 16 +- dpnp/dpnp_iface_indexing.py | 38 +- dpnp/dpnp_iface_libmath.py | 2 +- dpnp/dpnp_iface_linearalgebra.py | 20 +- dpnp/dpnp_iface_logic.py | 36 +- dpnp/dpnp_iface_manipulation.py | 54 +-- dpnp/dpnp_iface_mathematical.py | 88 ++--- dpnp/dpnp_iface_statistics.py | 2 +- dpnp/dpnp_iface_trigonometric.py | 2 +- dpnp/dpnp_iface_types.py | 94 ++--- dpnp/dpnp_utils/dpnp_utils_statistics.py | 6 +- dpnp/fft/dpnp_iface_fft.py | 52 +-- dpnp/linalg/dpnp_iface_linalg.py | 38 +- dpnp/linalg/dpnp_utils_linalg.py | 6 +- dpnp/random/dpnp_iface_random.py | 26 +- dpnp/random/dpnp_random_state.py | 32 +- dpnp/to_numba/dpnp_iface_to_numba.py | 6 +- dpnp/version.py | 0 examples/example1.py | 14 +- examples/example10.py | 12 +- examples/example2.py | 4 +- examples/example4.py | 6 +- examples/example7.py | 12 +- scripts/azure-pipelines.yml | 2 +- scripts/build_deps_dpctl.sh | 2 +- scripts/build_deps_dpctl_win.bat | 4 +- scripts/build_locally.py | 116 +++--- scripts/gen_coverage.py | 116 +++--- scripts/install_cmake_win.bat | 0 scripts/install_system_deps.sh | 4 +- scripts/install_system_deps_win.bat | 0 setup.py | 14 +- tests/conftest.py | 12 +- tests/test_absolute.py | 16 +- tests/test_amin_amax.py | 20 +- tests/test_arithmetic.py | 4 +- tests/test_arraycreation.py | 230 +++++------ tests/test_arraymanipulation.py | 88 ++--- tests/test_bitwise.py | 6 +- tests/test_counting.py | 4 +- tests/test_dot.py | 6 +- tests/test_dparray.py | 88 ++--- tests/test_fft.py | 20 +- tests/test_flat.py | 6 +- tests/test_histograms.py | 8 +- tests/test_indexing.py | 104 ++--- tests/test_linalg.py | 78 ++-- tests/test_logic.py | 30 +- tests/test_manipulation.py | 20 +- tests/test_mathematical.py | 242 ++++++------ tests/test_outer.py | 2 +- tests/test_random.py | 84 ++-- tests/test_random_state.py | 148 +++---- tests/test_sort.py | 18 +- tests/test_statistics.py | 28 +- tests/test_strides.py | 112 +++--- tests/test_sum.py | 2 +- tests/test_sycl_queue.py | 364 +++++++++--------- tests/test_umath.py | 42 +- tests/test_usm_type.py | 86 ++--- tests/tests_perf/data_generator.py | 8 +- tests/tests_perf/examples/sinAB_test.py | 2 +- .../math_tests/test_black_scholes.py | 6 +- tests/tests_perf/math_tests/test_dpnp.py | 6 +- .../math_tests/test_mathematical.py | 6 +- .../math_tests/test_trigonometric.py | 18 +- tests/tests_perf/test_perf_base.py | 70 ++-- .../core_tests/test_ndarray_conversion.py | 2 +- .../core_tests/test_ndarray_copy_and_view.py | 4 +- .../cupy/core_tests/test_ndarray_math.py | 2 +- .../cupy/core_tests/test_ndarray_reduction.py | 2 +- .../cupy/creation_tests/test_from_data.py | 8 +- .../cupy/creation_tests/test_matrix.py | 14 +- .../cupy/creation_tests/test_ranges.py | 16 +- tests/third_party/cupy/fft_tests/test_fft.py | 18 +- .../cupy/indexing_tests/test_generate.py | 2 +- .../cupy/indexing_tests/test_indexing.py | 24 +- .../cupy/indexing_tests/test_insert.py | 14 +- .../cupy/linalg_tests/test_eigenvalue.py | 12 +- .../cupy/linalg_tests/test_einsum.py | 16 +- .../cupy/linalg_tests/test_product.py | 24 +- .../cupy/logic_tests/test_comparison.py | 2 +- .../cupy/logic_tests/test_content.py | 6 +- .../cupy/manipulation_tests/test_basic.py | 6 +- .../cupy/manipulation_tests/test_dims.py | 8 +- .../cupy/manipulation_tests/test_shape.py | 2 +- .../cupy/manipulation_tests/test_tiling.py | 8 +- .../cupy/manipulation_tests/test_transpose.py | 4 +- .../cupy/math_tests/test_arithmetic.py | 6 +- .../cupy/math_tests/test_matmul.py | 6 +- .../cupy/math_tests/test_rounding.py | 4 +- .../cupy/math_tests/test_sumprod.py | 22 +- .../cupy/random_tests/test_distributions.py | 48 +-- .../cupy/random_tests/test_sample.py | 22 +- .../cupy/sorting_tests/test_search.py | 36 +- .../cupy/sorting_tests/test_sort.py | 20 +- .../cupy/statistics_tests/test_correlation.py | 12 +- .../cupy/statistics_tests/test_histogram.py | 2 +- .../cupy/statistics_tests/test_meanvar.py | 42 +- tests/third_party/cupy/testing/helper.py | 4 +- .../third_party/intel/test_zero_copy_test1.py | 4 +- tests/third_party/intel/zero-copy-test1.py | 20 +- 127 files changed, 1810 insertions(+), 1795 deletions(-) mode change 100644 => 100755 conda-recipe/build.sh mode change 100644 => 100755 conda-recipe/run_test.sh mode change 100755 => 100644 dpnp/backend/cmake/Modules/oneDPLConfig.cmake mode change 100644 => 100755 dpnp/version.py mode change 100755 => 100644 examples/example1.py mode change 100755 => 100644 examples/example2.py mode change 100755 => 100644 examples/example4.py mode change 100755 => 100644 examples/example7.py mode change 100755 => 100644 scripts/build_deps_dpctl_win.bat mode change 100755 => 100644 scripts/install_cmake_win.bat mode change 100755 => 100644 scripts/install_system_deps_win.bat mode change 100755 => 100644 tests/conftest.py mode change 100644 => 100755 tests/tests_perf/data_generator.py mode change 100644 => 100755 tests/tests_perf/test_perf_base.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 76b1a74376d..e641920f57d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,8 +2,25 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/PyCQA/bandit - rev: '1.7.0' + rev: '1.7.5' hooks: - id: bandit pass_filenames: false args: ["-r", "dpnp", "-lll"] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-ast + - id: check-builtin-literals + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-toml + - id: debug-statements + - id: destroyed-symlinks + - id: double-quote-string-fixer + - id: end-of-file-fixer + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: trailing-whitespace diff --git a/LICENSE.txt b/LICENSE.txt index 5bebac93a3a..9b32f02892f 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,22 +1,22 @@ -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 +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -- Redistributions of source code must retain the above copyright notice, +- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -- Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/benchmarks/pytest_benchmark/README.md b/benchmarks/pytest_benchmark/README.md index 154860e39ea..d3c7478509a 100644 --- a/benchmarks/pytest_benchmark/README.md +++ b/benchmarks/pytest_benchmark/README.md @@ -20,7 +20,7 @@ pytest-benchmark compare results.json --csv=results.csv --group-by='name' ``` ## Optional: creating histogram -Note: make sure that `pytest-benchmark[histogram]` installed +Note: make sure that `pytest-benchmark[histogram]` installed ```bash # example pip install pytest-benchmark[histogram] diff --git a/benchmarks/pytest_benchmark/test_random.py b/benchmarks/pytest_benchmark/test_random.py index 61f46f95ba4..dc8d8b8807a 100644 --- a/benchmarks/pytest_benchmark/test_random.py +++ b/benchmarks/pytest_benchmark/test_random.py @@ -37,36 +37,36 @@ NNUMBERS = 2**26 -@pytest.mark.parametrize("function", [dpnp.random.beta, np.random.beta], - ids=["dpnp", "numpy"]) +@pytest.mark.parametrize('function', [dpnp.random.beta, np.random.beta], + ids=['dpnp', 'numpy']) def test_beta(benchmark, function): result = benchmark.pedantic(target=function, args=(4.0, 5.0, NNUMBERS,), rounds=ROUNDS, iterations=ITERATIONS) -@pytest.mark.parametrize("function", [dpnp.random.exponential, np.random.exponential], - ids=["dpnp", "numpy"]) +@pytest.mark.parametrize('function', [dpnp.random.exponential, np.random.exponential], + ids=['dpnp', 'numpy']) def test_exponential(benchmark, function): result = benchmark.pedantic(target=function, args=(4.0, NNUMBERS,), rounds=ROUNDS, iterations=ITERATIONS) -@pytest.mark.parametrize("function", [dpnp.random.gamma, np.random.gamma], - ids=["dpnp", "numpy"]) +@pytest.mark.parametrize('function', [dpnp.random.gamma, np.random.gamma], + ids=['dpnp', 'numpy']) def test_gamma(benchmark, function): result = benchmark.pedantic(target=function, args=(2.0, 4.0, NNUMBERS,), rounds=ROUNDS, iterations=ITERATIONS) -@pytest.mark.parametrize("function", [dpnp.random.normal, np.random.normal], - ids=["dpnp", "numpy"]) +@pytest.mark.parametrize('function', [dpnp.random.normal, np.random.normal], + ids=['dpnp', 'numpy']) def test_normal(benchmark, function): result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,), rounds=ROUNDS, iterations=ITERATIONS) -@pytest.mark.parametrize("function", [dpnp.random.uniform, np.random.uniform], - ids=["dpnp", "numpy"]) +@pytest.mark.parametrize('function', [dpnp.random.uniform, np.random.uniform], + ids=['dpnp', 'numpy']) def test_uniform(benchmark, function): result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,), rounds=ROUNDS, iterations=ITERATIONS) diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh old mode 100644 new mode 100755 diff --git a/conda-recipe/run_test.sh b/conda-recipe/run_test.sh old mode 100644 new mode 100755 diff --git a/doc/Makefile b/doc/Makefile index a580a4e46f0..22f09a08be2 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -17,4 +17,4 @@ help: # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/doc/_templates/autosummary/class.rst b/doc/_templates/autosummary/class.rst index e129f15ee81..90e3fe72754 100644 --- a/doc/_templates/autosummary/class.rst +++ b/doc/_templates/autosummary/class.rst @@ -50,4 +50,4 @@ {% for item in attributes %} .. autoattribute:: {{ item }} {%- endfor %} -{% endif %} {% endblock %} \ No newline at end of file +{% endif %} {% endblock %} diff --git a/doc/conf.py b/doc/conf.py index 3f1469ea3ad..e1465a6d441 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -94,10 +94,10 @@ # a list of builtin themes. # # html_theme = 'alabaster' -html_theme = "sphinx_rtd_theme" +html_theme = 'sphinx_rtd_theme' html_theme_options = { - "sidebarwidth": 30, - "nosidebar": False, + 'sidebarwidth': 30, + 'nosidebar': False, } # Theme options are theme-specific and customize the look and feel of a theme diff --git a/doc/reference/linalg.rst b/doc/reference/linalg.rst index 564ba432447..00c1332c9ac 100644 --- a/doc/reference/linalg.rst +++ b/doc/reference/linalg.rst @@ -9,7 +9,7 @@ Matrix and vector products .. autosummary:: :toctree: generated/ :nosignatures: - + dpnp.cross dpnp.dot dpnp.linalg.multi_dot diff --git a/doc/reference/math.rst b/doc/reference/math.rst index 634ccadc8f5..dee52ba710f 100644 --- a/doc/reference/math.rst +++ b/doc/reference/math.rst @@ -182,4 +182,4 @@ Miscellaneous dpnp.blackman dpnp.hamming dpnp.hanning - dpnp.kaiser \ No newline at end of file + dpnp.kaiser diff --git a/dpnp/__init__.py b/dpnp/__init__.py index a081a909923..0a7bcfb3a6d 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.py @@ -39,10 +39,10 @@ # are not installed under any of default paths where Python is searching. from platform import system if system() == 'Windows': - if hasattr(os, "add_dll_directory"): + if hasattr(os, 'add_dll_directory'): os.add_dll_directory(mypath) os.add_dll_directory(dpctlpath) - os.environ["PATH"] = os.pathsep.join([os.getenv("PATH", ""), mypath, dpctlpath]) + os.environ['PATH'] = os.pathsep.join([os.getenv('PATH', ''), mypath, dpctlpath]) from dpnp.dpnp_array import dpnp_array as ndarray from dpnp.dpnp_flatiter import flatiter as flatiter diff --git a/dpnp/backend/cmake/Modules/README.md b/dpnp/backend/cmake/Modules/README.md index 02b4c40e0a4..0a6b2df4089 100644 --- a/dpnp/backend/cmake/Modules/README.md +++ b/dpnp/backend/cmake/Modules/README.md @@ -5,4 +5,4 @@ package. Once it is added, expected 2023.2.0, this vendored package is to be removed. tbb-devel script has been modified to allow it to work correctly in conda -environment. \ No newline at end of file +environment. diff --git a/dpnp/backend/cmake/Modules/TBBConfig.cmake b/dpnp/backend/cmake/Modules/TBBConfig.cmake index 6a3f4f7a43a..55811100c93 100644 --- a/dpnp/backend/cmake/Modules/TBBConfig.cmake +++ b/dpnp/backend/cmake/Modules/TBBConfig.cmake @@ -32,7 +32,7 @@ endif() get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_DIR}" REALPATH) get_filename_component(_tbb_root "${_tbb_root}/../../.." ABSOLUTE) - + set(TBB_INTERFACE_VERSION ) set(_tbb_bin_version 12) @@ -60,7 +60,7 @@ if (UNIX) set(_tbb_lib_prefix "lib") set(_tbb_lib_dir_conda "lib") set(_bin_version "") -elseif (WIN32) +elseif (WIN32) set(_bin_version "") set(_tbb_lib_prefix "") set(_tbb_lib_ext ".dll") @@ -82,21 +82,21 @@ if(WIN32) endif() if(UNIX) - find_library(_tbb_release_lib + find_library(_tbb_release_lib NAMES ${_tbb_lib_prefix}${_tbb_component}${_bin_version}${_tbb_lib_ext} PATHS ${_tbb_root} HINTS ENV TBB_ROOT_HINT PATH_SUFFIXES "${_tbb_lib_dir_conda}" "lib/${_tbb_subdir}") else() - find_file(_tbb_release_lib + find_file(_tbb_release_lib NAMES ${_tbb_lib_prefix}${_tbb_component}${_bin_version}${_tbb_lib_ext} PATHS ${_tbb_root} HINTS ENV TBB_ROOT_HINT PATH_SUFFIXES "${_tbb_lib_dir_conda}" "lib/${_tbb_subdir}") if (EXISTS "${_tbb_release_lib}") - find_library(_tbb_release_impllib + find_library(_tbb_release_impllib NAMES ${_tbb_lib_prefix}${_tbb_component}${_bin_version}${_tbb_impllib_ext} PATHS ${_tbb_root} HINTS ENV TBB_ROOT_HINT @@ -105,13 +105,13 @@ endif() endif() if (NOT TBB_FIND_RELEASE_ONLY) - find_library(_tbb_debug_lib + find_library(_tbb_debug_lib NAMES ${_tbb_lib_prefix}${_tbb_component}${_bin_version}_debug.${_tbb_lib_ext} PATHS ${_tbb_root} HINTS ENV TBB_ROOT_HINT PATH_SUFFIXES "${_tbb_lib_dir_conda}" "lib/${_tbb_subdir}") if(WIN32 AND EXISTS "${_tbb_debug_lib}") - find_library(_tbb_debug_impllib + find_library(_tbb_debug_impllib NAMES ${_tbb_lib_prefix}${_tbb_component}${_bin_version}_debug.${_tbb_impllib_ext} PATHS ${_tbb_root} HINTS ENV TBB_ROOT_HINT diff --git a/dpnp/backend/cmake/Modules/oneDPLConfig.cmake b/dpnp/backend/cmake/Modules/oneDPLConfig.cmake old mode 100755 new mode 100644 diff --git a/dpnp/backend/kernels/dpnp_krnl_linalg.cpp b/dpnp/backend/kernels/dpnp_krnl_linalg.cpp index dff1320d5c2..71390dedeb6 100644 --- a/dpnp/backend/kernels/dpnp_krnl_linalg.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_linalg.cpp @@ -1038,7 +1038,7 @@ void func_map_init_linalg_func(func_map_t& fmap) (void*)dpnp_svd_default_c}; fmap[DPNPFuncName::DPNP_FN_SVD][eft_C128][eft_C128] = { eft_C128, (void*)dpnp_svd_default_c, std::complex, double>}; - + fmap[DPNPFuncName::DPNP_FN_SVD_EXT][eft_INT][eft_INT] = {eft_DBL, (void*)dpnp_svd_ext_c}; fmap[DPNPFuncName::DPNP_FN_SVD_EXT][eft_LNG][eft_LNG] = {eft_DBL, diff --git a/dpnp/backend/kernels/dpnp_krnl_random.cpp b/dpnp/backend/kernels/dpnp_krnl_random.cpp index 7a79b235a4e..68a4d6d3922 100644 --- a/dpnp/backend/kernels/dpnp_krnl_random.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_random.cpp @@ -2906,7 +2906,7 @@ void func_map_init_random(func_map_t& fmap) (void*)dpnp_rng_binomial_default_c}; fmap[DPNPFuncName::DPNP_FN_RNG_BINOMIAL_EXT][eft_INT][eft_INT] = {eft_INT, - (void*)dpnp_rng_binomial_ext_c}; + (void*)dpnp_rng_binomial_ext_c}; fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_DBL][eft_DBL] = {eft_DBL, (void*)dpnp_rng_chisquare_default_c}; diff --git a/dpnp/backend/src/dpnp_fptr.hpp b/dpnp/backend/src/dpnp_fptr.hpp index cb33e70185e..83fcb889ad7 100644 --- a/dpnp/backend/src/dpnp_fptr.hpp +++ b/dpnp/backend/src/dpnp_fptr.hpp @@ -129,7 +129,7 @@ static auto dpnp_vec_cast_impl(const Vec& v, std::index_sequence) /** * @brief A casting function for SYCL vector. - * + * * @tparam dstT A result type upon casting. * @tparam srcT An incoming type of the vector. * @tparam N A number of elements with the vector. diff --git a/dpnp/backend/src/dpnp_random_state.cpp b/dpnp/backend/src/dpnp_random_state.cpp index 12db01a1cd8..a016cf0414b 100644 --- a/dpnp/backend/src/dpnp_random_state.cpp +++ b/dpnp/backend/src/dpnp_random_state.cpp @@ -36,7 +36,7 @@ void MT19937_InitScalarSeed(mt19937_struct *mt19937, DPCTLSyclQueueRef q_ref, ui void MT19937_InitVectorSeed(mt19937_struct *mt19937, DPCTLSyclQueueRef q_ref, uint32_t *seed, unsigned int n) { sycl::queue *q = reinterpret_cast(q_ref); - + switch (n) { case 1: mt19937->engine = new mkl_rng::mt19937(*q, {seed[0]}); break; case 2: mt19937->engine = new mkl_rng::mt19937(*q, {seed[0], seed[1]}); break; diff --git a/dpnp/dpnp_algo/dpnp_elementwise_common.py b/dpnp/dpnp_algo/dpnp_elementwise_common.py index 7a54a194795..6fbd88734fe 100644 --- a/dpnp/dpnp_algo/dpnp_elementwise_common.py +++ b/dpnp/dpnp_algo/dpnp_elementwise_common.py @@ -42,10 +42,10 @@ __all__ = [ - "dpnp_add", - "dpnp_divide", - "dpnp_multiply", - "dpnp_subtract" + 'dpnp_add', + 'dpnp_divide', + 'dpnp_multiply', + 'dpnp_subtract' ] @@ -85,7 +85,7 @@ def dpnp_add(x1, x2, out=None, order='K'): x2_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x2) out_usm = None if out is None else dpnp.get_usm_ndarray(out) - func = BinaryElementwiseFunc("add", ti._add_result_type, ti._add, + func = BinaryElementwiseFunc('add', ti._add_result_type, ti._add, _add_docstring_, ti._add_inplace) res_usm = func(x1_usm_or_scalar, x2_usm_or_scalar, out=out_usm, order=order) return dpnp_array._create_from_usm_ndarray(res_usm) @@ -148,7 +148,7 @@ def _call_divide_inplace(lhs, rhs, sycl_queue, depends=[]): x2_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x2) out_usm = None if out is None else dpnp.get_usm_ndarray(out) - func = BinaryElementwiseFunc("divide", ti._divide_result_type, _call_divide, + func = BinaryElementwiseFunc('divide', ti._divide_result_type, _call_divide, _divide_docstring_, _call_divide_inplace) res_usm = func(x1_usm_or_scalar, x2_usm_or_scalar, out=out_usm, order=order) return dpnp_array._create_from_usm_ndarray(res_usm) @@ -190,7 +190,7 @@ def dpnp_multiply(x1, x2, out=None, order='K'): x2_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x2) out_usm = None if out is None else dpnp.get_usm_ndarray(out) - func = BinaryElementwiseFunc("multiply", ti._multiply_result_type, ti._multiply, + func = BinaryElementwiseFunc('multiply', ti._multiply_result_type, ti._multiply, _multiply_docstring_, ti._multiply_inplace) res_usm = func(x1_usm_or_scalar, x2_usm_or_scalar, out=out_usm, order=order) return dpnp_array._create_from_usm_ndarray(res_usm) @@ -229,15 +229,15 @@ def dpnp_subtract(x1, x2, out=None, order='K'): # TODO: discuss with dpctl if the check is needed to be moved there if not dpnp.isscalar(x1) and not dpnp.isscalar(x2) and x1.dtype == x2.dtype == dpnp.bool: - raise TypeError("DPNP boolean subtract, the `-` operator, is not supported, " - "use the bitwise_xor, the `^` operator, or the logical_xor function instead.") + raise TypeError('DPNP boolean subtract, the `-` operator, is not supported, ' + 'use the bitwise_xor, the `^` operator, or the logical_xor function instead.') # dpctl.tensor only works with usm_ndarray or scalar x1_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x1) x2_usm_or_scalar = dpnp.get_usm_ndarray_or_scalar(x2) out_usm = None if out is None else dpnp.get_usm_ndarray(out) - func = BinaryElementwiseFunc("subtract", ti._subtract_result_type, ti._subtract, + func = BinaryElementwiseFunc('subtract', ti._subtract_result_type, ti._subtract, _subtract_docstring_, ti._subtract_inplace) res_usm = func(x1_usm_or_scalar, x2_usm_or_scalar, out=out_usm, order=order) return dpnp_array._create_from_usm_ndarray(res_usm) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 158dfd03ba4..c1691479881 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -57,24 +57,24 @@ class dpnp_array: def __init__(self, shape, - dtype="f8", + dtype='f8', buffer=None, offset=0, strides=None, - order="C", + order='C', device=None, - usm_type="device", + usm_type='device', sycl_queue=None): if buffer is not None: if not isinstance(buffer, dpt.usm_ndarray): raise TypeError( - "Expected dpctl.tensor.usm_ndarray, got {}" - "".format(type(buffer)) + 'Expected dpctl.tensor.usm_ndarray, got {}' + ''.format(type(buffer)) ) if buffer.shape != shape: raise ValueError( - "Expected buffer.shape={}, got {}" - "".format(shape, buffer.shape) + 'Expected buffer.shape={}, got {}' + ''.format(shape, buffer.shape) ) self._array_obj = dpt.asarray(buffer, copy=False, @@ -87,7 +87,7 @@ def __init__(self, buffer=usm_type, offset=offset, order=order, - buffer_ctor_kwargs={"queue": sycl_queue_normalized}) + buffer_ctor_kwargs={'queue': sycl_queue_normalized}) @property def __sycl_usm_array_interface__(self): @@ -191,8 +191,8 @@ def __getitem__(self, key): item = self._array_obj.__getitem__(key) if not isinstance(item, dpt.usm_ndarray): raise RuntimeError( - "Expected dpctl.tensor.usm_ndarray, got {}" - "".format(type(item))) + 'Expected dpctl.tensor.usm_ndarray, got {}' + ''.format(type(item))) res = self.__new__(dpnp_array) res._array_obj = item @@ -315,7 +315,7 @@ def __rand__(self, other): # '__reduce_ex__', def __repr__(self): - return dpt.usm_ndarray_repr(self._array_obj, prefix="array") + return dpt.usm_ndarray_repr(self._array_obj, prefix='array') # '__rfloordiv__', @@ -396,7 +396,7 @@ def __xor__(self, other): def _create_from_usm_ndarray(usm_ary : dpt.usm_ndarray): if not isinstance(usm_ary, dpt.usm_ndarray): raise TypeError( - f"Expected dpctl.tensor.usm_ndarray, got {type(usm_ary)}" + f'Expected dpctl.tensor.usm_ndarray, got {type(usm_ary)}' ) res = dpnp_array.__new__(dpnp_array) res._array_obj = usm_ary @@ -770,7 +770,7 @@ def item(self, id=None): if id is None: if self.size != 1: - raise ValueError("DPNP dparray::item(): can only convert an array of size 1 to a Python scalar") + raise ValueError('DPNP dparray::item(): can only convert an array of size 1 to a Python scalar') else: id = 0 diff --git a/dpnp/dpnp_container.py b/dpnp/dpnp_container.py index 5bd6f460496..c47c9f85009 100644 --- a/dpnp/dpnp_container.py +++ b/dpnp/dpnp_container.py @@ -42,16 +42,16 @@ __all__ = [ - "arange", - "asarray", - "empty", - "eye", - "full", - "linspace", - "ones" - "tril", - "triu", - "zeros", + 'arange', + 'asarray', + 'empty', + 'eye', + 'full', + 'linspace', + 'ones' + 'tril', + 'triu', + 'zeros', ] @@ -62,7 +62,7 @@ def arange(start, *, dtype=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """Validate input parameters before passing them into `dpctl.tensor` module""" dpu.validate_usm_type(usm_type, allow_none=False) @@ -81,7 +81,7 @@ def arange(start, def asarray(x1, dtype=None, copy=False, - order="C", + order='C', device=None, usm_type=None, sycl_queue=None): @@ -120,9 +120,9 @@ def asarray(x1, def empty(shape, *, dtype=None, - order="C", + order='C', device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """Validate input parameters before passing them into `dpctl.tensor` module""" dpu.validate_usm_type(usm_type, allow_none=False) @@ -145,9 +145,9 @@ def eye(N, *, k=0, dtype=None, - order="C", + order='C', device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """Validate input parameters before passing them into `dpctl.tensor` module""" dpu.validate_usm_type(usm_type, allow_none=False) @@ -170,7 +170,7 @@ def full(shape, fill_value, *, dtype=None, - order="C", + order='C', device=None, usm_type=None, sycl_queue=None): @@ -200,7 +200,7 @@ def linspace(start, *, dtype=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None, endpoint=True): """Validate input parameters before passing them into `dpctl.tensor` module""" @@ -218,7 +218,7 @@ def linspace(start, return dpnp_array(array_obj.shape, buffer=array_obj) -def meshgrid(*xi, indexing="xy"): +def meshgrid(*xi, indexing='xy'): """Creates list of `dpnp_array` coordinate matrices from vectors.""" if len(xi) == 0: return [] @@ -230,9 +230,9 @@ def meshgrid(*xi, indexing="xy"): def ones(shape, *, dtype=None, - order="C", + order='C', device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """Validate input parameters before passing them into `dpctl.tensor` module""" dpu.validate_usm_type(usm_type, allow_none=False) @@ -252,21 +252,21 @@ def ones(shape, def tril(x1, /, *, k=0): """"Creates `dpnp_array` as lower triangular part of an input array.""" array_obj = dpt.tril(x1.get_array() if isinstance(x1, dpnp_array) else x1, k) - return dpnp_array(array_obj.shape, buffer=array_obj, order="K") + return dpnp_array(array_obj.shape, buffer=array_obj, order='K') def triu(x1, /, *, k=0): """"Creates `dpnp_array` as upper triangular part of an input array.""" array_obj = dpt.triu(x1.get_array() if isinstance(x1, dpnp_array) else x1, k) - return dpnp_array(array_obj.shape, buffer=array_obj, order="K") + return dpnp_array(array_obj.shape, buffer=array_obj, order='K') def zeros(shape, *, dtype=None, - order="C", + order='C', device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """Validate input parameters before passing them into `dpctl.tensor` module""" dpu.validate_usm_type(usm_type, allow_none=False) diff --git a/dpnp/dpnp_flatiter.py b/dpnp/dpnp_flatiter.py index e45f5289324..93545d119dd 100644 --- a/dpnp/dpnp_flatiter.py +++ b/dpnp/dpnp_flatiter.py @@ -36,7 +36,7 @@ class flatiter: def __init__(self, X): if type(X) is not dpnp.ndarray: raise TypeError( - "Argument must be of type dpnp.ndarray, got {}".format( + 'Argument must be of type dpnp.ndarray, got {}'.format( type(X) ) ) @@ -48,7 +48,7 @@ def _multiindex(self, i): nd = self.arr_.ndim if nd == 0: if i == 0: - return tuple() + return () raise KeyError elif nd == 1: return (i,) @@ -64,7 +64,7 @@ def _multiindex(self, i): return tuple(multi_index) def __getitem__(self, key): - idx = getattr(key, "__index__", None) + idx = getattr(key, '__index__', None) if not callable(idx): raise TypeError(key) i = idx() @@ -72,7 +72,7 @@ def __getitem__(self, key): return self.arr_.__getitem__(mi) def __setitem__(self, key, val): - idx = getattr(key, "__index__", None) + idx = getattr(key, '__index__', None) if not callable(idx): raise TypeError(key) i = idx() diff --git a/dpnp/dpnp_iface.py b/dpnp/dpnp_iface.py index 93629440e7d..fcaffec6131 100644 --- a/dpnp/dpnp_iface.py +++ b/dpnp/dpnp_iface.py @@ -57,20 +57,20 @@ from dpnp.random import * __all__ = [ - "array_equal", - "asnumpy", - "astype", - "convert_single_elem_array_to_scalar", - "default_float_type", - "dpnp_queue_initialize", - "dpnp_queue_is_cpu", - "from_dlpack", - "get_dpnp_descriptor", - "get_include", - "get_normalized_queue_device", - "get_usm_ndarray", - "get_usm_ndarray_or_scalar", - "is_supported_array_type" + 'array_equal', + 'asnumpy', + 'astype', + 'convert_single_elem_array_to_scalar', + 'default_float_type', + 'dpnp_queue_initialize', + 'dpnp_queue_is_cpu', + 'from_dlpack', + 'get_dpnp_descriptor', + 'get_include', + 'get_normalized_queue_device', + 'get_usm_ndarray', + 'get_usm_ndarray_or_scalar', + 'is_supported_array_type' ] from dpnp import ( @@ -288,12 +288,12 @@ def get_dpnp_descriptor(ext_obj, # we need to create a non-strided copy # if function get implementation for strides case # then this behavior can be disabled with setting "copy_when_strides" - if copy_when_strides and getattr(ext_obj, "strides", None) is not None: + if copy_when_strides and getattr(ext_obj, 'strides', None) is not None: # TODO: replace this workaround when usm_ndarray will provide such functionality shape_offsets = tuple(numpy.prod(ext_obj.shape[i + 1:], dtype=numpy.int64) for i in range(ext_obj.ndim)) - if hasattr(ext_obj, "__sycl_usm_array_interface__"): - ext_obj_offset = ext_obj.__sycl_usm_array_interface__.get("offset", 0) + if hasattr(ext_obj, '__sycl_usm_array_interface__'): + ext_obj_offset = ext_obj.__sycl_usm_array_interface__.get('offset', 0) else: ext_obj_offset = 0 @@ -305,7 +305,7 @@ def get_dpnp_descriptor(ext_obj, # we need to create a copy on device associated with DPNP_QUEUE # if function get implementation for different queue # then this behavior can be disabled with setting "copy_when_nondefault_queue" - queue = getattr(ext_obj, "sycl_queue", None) + queue = getattr(ext_obj, 'sycl_queue', None) if queue is not None and copy_when_nondefault_queue: default_queue = dpctl.SyclQueue() queue_is_default = dpctl.utils.get_execution_queue([queue, default_queue]) is not None @@ -324,7 +324,7 @@ def get_include(): Return the directory that contains the DPNP C++ backend \\*.h header files. """ - dpnp_path = os.path.join(os.path.dirname(__file__), "backend", "include") + dpnp_path = os.path.join(os.path.dirname(__file__), 'backend', 'include') return dpnp_path @@ -402,7 +402,7 @@ def get_usm_ndarray(a): return a.get_array() if isinstance(a, dpt.usm_ndarray): return a - raise TypeError("An array must be any of supported type, but got {}".format(type(a))) + raise TypeError('An array must be any of supported type, but got {}'.format(type(a))) def get_usm_ndarray_or_scalar(a): diff --git a/dpnp/dpnp_iface_arraycreation.py b/dpnp/dpnp_iface_arraycreation.py index 257fd660fbb..2dd36a24462 100644 --- a/dpnp/dpnp_iface_arraycreation.py +++ b/dpnp/dpnp_iface_arraycreation.py @@ -54,42 +54,42 @@ __all__ = [ - "arange", - "array", - "asanyarray", - "asarray", - "ascontiguousarray", - "copy", - "diag", - "diagflat", - "empty", - "empty_like", - "eye", - "frombuffer", - "fromfile", - "fromfunction", - "fromiter", - "fromstring", - "full", - "full_like", - "geomspace", - "identity", - "linspace", - "loadtxt", - "logspace", - "meshgrid", - "mgrid", - "ogrid", - "ones", - "ones_like", - "ptp", - "trace", - "tri", - "tril", - "triu", - "vander", - "zeros", - "zeros_like" + 'arange', + 'array', + 'asanyarray', + 'asarray', + 'ascontiguousarray', + 'copy', + 'diag', + 'diagflat', + 'empty', + 'empty_like', + 'eye', + 'frombuffer', + 'fromfile', + 'fromfunction', + 'fromiter', + 'fromstring', + 'full', + 'full_like', + 'geomspace', + 'identity', + 'linspace', + 'loadtxt', + 'logspace', + 'meshgrid', + 'mgrid', + 'ogrid', + 'ones', + 'ones_like', + 'ptp', + 'trace', + 'tri', + 'tril', + 'triu', + 'vander', + 'zeros', + 'zeros_like' ] @@ -101,7 +101,7 @@ def arange(start, dtype=None, like=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Returns an array with evenly spaced values within a given interval. @@ -149,7 +149,7 @@ def arange(start, def array(x1, dtype=None, copy=True, - order="C", + order='C', subok=False, ndmin=0, like=None, @@ -270,7 +270,7 @@ def asanyarray(a, dtype=None, order='C'): def asarray(x1, dtype=None, - order="C", + order='C', like=None, device=None, usm_type=None, @@ -469,10 +469,10 @@ def diagflat(x1, k=0): def empty(shape, *, dtype=None, - order="C", + order='C', like=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return a new array of given shape and type, without initializing entries. @@ -520,7 +520,7 @@ def empty_like(x1, /, *, dtype=None, - order="C", + order='C', subok=False, shape=None, device=None, @@ -581,10 +581,10 @@ def eye(N, *, k=0, dtype=None, - order="C", + order='C', like=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return a 2-D array with ones on the diagonal and zeros elsewhere. @@ -700,7 +700,7 @@ def full(shape, fill_value, *, dtype=None, - order="C", + order='C', like=None, device=None, usm_type=None, @@ -1008,7 +1008,7 @@ def logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, axis=0): if not use_origin_backend(): if axis != 0: - checker_throw_value_error("linspace", "axis", axis, 0) + checker_throw_value_error('linspace', 'axis', axis, 0) return dpnp_logspace(start, stop, num, endpoint, base, dtype, axis).get_pyobj() @@ -1066,7 +1066,7 @@ def meshgrid(*xi, copy=True, sparse=False, indexing='xy'): if not all((isinstance(x, (dpnp.ndarray, dpt.usm_ndarray)) for x in xi)): pass - elif indexing not in ["ij", "xy"]: + elif indexing not in ['ij', 'xy']: pass elif copy is not True: pass @@ -1141,10 +1141,10 @@ def __getitem__(self, key): def ones(shape, *, dtype=None, - order="C", + order='C', like=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return a new array of given shape and type, filled with ones. @@ -1196,7 +1196,7 @@ def ones_like(x1, /, *, dtype=None, - order="C", + order='C', subok=False, shape=None, device=None, @@ -1483,10 +1483,10 @@ def vander(x1, N=None, increasing=False): def zeros(shape, *, dtype=None, - order="C", + order='C', like=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return a new array of given shape and type, filled with zeros. @@ -1537,7 +1537,7 @@ def zeros_like(x1, /, *, dtype=None, - order="C", + order='C', subok=False, shape=None, device=None, diff --git a/dpnp/dpnp_iface_bitwise.py b/dpnp/dpnp_iface_bitwise.py index 92f33bc6310..1a16788fc18 100644 --- a/dpnp/dpnp_iface_bitwise.py +++ b/dpnp/dpnp_iface_bitwise.py @@ -86,7 +86,7 @@ def _check_nd_call(origin_func, dpnp_func, x1, x2, dtype=None, out=None, where=T if x1_desc and x2_desc: if out is not None: if not isinstance(out, (dpnp.ndarray, dpt.usm_ndarray)): - raise TypeError("return array must be of supported array type") + raise TypeError('return array must be of supported array type') out_desc = dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False) or None else: out_desc = None @@ -106,7 +106,7 @@ def bitwise_and(x1, x2, dtype=None, out=None, where=True, **kwargs): ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray` @@ -146,7 +146,7 @@ def bitwise_or(x1, x2, dtype=None, out=None, where=True, **kwargs): ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray` @@ -186,7 +186,7 @@ def bitwise_xor(x1, x2, dtype=None, out=None, where=True, **kwargs): ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray` @@ -233,7 +233,7 @@ def invert(x, ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameter `x` is supported as either :class:`dpnp.ndarray` @@ -274,7 +274,7 @@ def invert(x, if x1_desc: if out is not None: if not isinstance(out, (dpnp.ndarray, dpt.usm_ndarray)): - raise TypeError("return array must be of supported array type") + raise TypeError('return array must be of supported array type') out_desc = dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False) or None else: out_desc = None @@ -296,7 +296,7 @@ def left_shift(x1, x2, dtype=None, out=None, where=True, **kwargs): ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray` @@ -333,7 +333,7 @@ def right_shift(x1, x2, dtype=None, out=None, where=True, **kwargs): ------- y : dpnp.ndarray An array containing the element-wise results. - + Limitations ----------- Parameters `x1` and `x2` are supported as either scalar, :class:`dpnp.ndarray` diff --git a/dpnp/dpnp_iface_indexing.py b/dpnp/dpnp_iface_indexing.py index aa9989e5f7d..127aad143c7 100644 --- a/dpnp/dpnp_iface_indexing.py +++ b/dpnp/dpnp_iface_indexing.py @@ -50,25 +50,25 @@ __all__ = [ - "choose", - "diag_indices", - "diag_indices_from", - "diagonal", - "extract", - "fill_diagonal", - "indices", - "nonzero", - "place", - "put", - "put_along_axis", - "putmask", - "select", - "take", - "take_along_axis", - "tril_indices", - "tril_indices_from", - "triu_indices", - "triu_indices_from" + 'choose', + 'diag_indices', + 'diag_indices_from', + 'diagonal', + 'extract', + 'fill_diagonal', + 'indices', + 'nonzero', + 'place', + 'put', + 'put_along_axis', + 'putmask', + 'select', + 'take', + 'take_along_axis', + 'tril_indices', + 'tril_indices_from', + 'triu_indices', + 'triu_indices_from' ] diff --git a/dpnp/dpnp_iface_libmath.py b/dpnp/dpnp_iface_libmath.py index 6ef787487af..15e7dab5c1b 100644 --- a/dpnp/dpnp_iface_libmath.py +++ b/dpnp/dpnp_iface_libmath.py @@ -46,7 +46,7 @@ import dpnp __all__ = [ - "erf" + 'erf' ] diff --git a/dpnp/dpnp_iface_linearalgebra.py b/dpnp/dpnp_iface_linearalgebra.py index f26f9648b24..b2a322fd92c 100644 --- a/dpnp/dpnp_iface_linearalgebra.py +++ b/dpnp/dpnp_iface_linearalgebra.py @@ -50,15 +50,15 @@ __all__ = [ - "dot", - "einsum", - "einsum_path", - "inner", - "kron", - "matmul", - "outer", - "tensordot", - "vdot" + 'dot', + 'einsum', + 'einsum_path', + 'inner', + 'kron', + 'matmul', + 'outer', + 'tensordot', + 'vdot' ] @@ -114,7 +114,7 @@ def dot(x1, x2, out=None, **kwargs): if x1_desc and x2_desc: if out is not None: if not isinstance(out, (dpnp.ndarray, dpt.usm_ndarray)): - raise TypeError("return array must be of supported array type") + raise TypeError('return array must be of supported array type') out_desc = dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False) or None else: out_desc = None diff --git a/dpnp/dpnp_iface_logic.py b/dpnp/dpnp_iface_logic.py index e36c44d3f98..917e9addf5f 100644 --- a/dpnp/dpnp_iface_logic.py +++ b/dpnp/dpnp_iface_logic.py @@ -49,23 +49,23 @@ __all__ = [ - "all", - "allclose", - "any", - "equal", - "greater", - "greater_equal", - "isclose", - "isfinite", - "isinf", - "isnan", - "less", - "less_equal", - "logical_and", - "logical_not", - "logical_or", - "logical_xor", - "not_equal" + 'all', + 'allclose', + 'any', + 'equal', + 'greater', + 'greater_equal', + 'isclose', + 'isfinite', + 'isinf', + 'isnan', + 'less', + 'less_equal', + 'logical_and', + 'logical_not', + 'logical_or', + 'logical_xor', + 'not_equal' ] @@ -278,7 +278,7 @@ def equal(x1, [True, True, False] """ - + if out is not None: pass elif where is not True: diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 1ca879abe1a..374141152ce 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -54,28 +54,28 @@ __all__ = [ - "asfarray", - "atleast_1d", - "atleast_2d", - "atleast_3d", - "broadcast_to", - "concatenate", - "copyto", - "expand_dims", - "hstack", - "moveaxis", - "ravel", - "repeat", - "reshape", - "result_type", - "rollaxis", - "shape", - "squeeze", - "stack", - "swapaxes", - "transpose", - "unique", - "vstack" + 'asfarray', + 'atleast_1d', + 'atleast_2d', + 'atleast_3d', + 'broadcast_to', + 'concatenate', + 'copyto', + 'expand_dims', + 'hstack', + 'moveaxis', + 'ravel', + 'repeat', + 'reshape', + 'result_type', + 'rollaxis', + 'shape', + 'squeeze', + 'stack', + 'swapaxes', + 'transpose', + 'unique', + 'vstack' ] @@ -236,7 +236,7 @@ def broadcast_to(x, /, shape, subok=False): return call_origin(numpy.broadcast_to, x, shape=shape, subok=subok) -def concatenate(arrs, axis=0, out=None, dtype=None, casting="same_kind"): +def concatenate(arrs, axis=0, out=None, dtype=None, casting='same_kind'): """ Join a sequence of arrays along an existing axis. @@ -542,7 +542,7 @@ def reshape(x, /, newshape, order='C', copy=None): This will be a new view object if possible; otherwise, it will be a copy. Note there is no guarantee of the *memory layout* (C- or Fortran- contiguous) of the returned array. - + Limitations ----------- Parameter `order` is supported only with values ``"C"`` and ``"F"``. @@ -572,7 +572,7 @@ def reshape(x, /, newshape, order='C', copy=None): if order is None: order = 'C' - elif not order in "cfCF": + elif not order in 'cfCF': raise ValueError(f"order must be one of 'C' or 'F' (got {order})") usm_arr = dpnp.get_usm_ndarray(x) @@ -676,7 +676,7 @@ def shape(a): Return the shape of an array. For full documentation refer to :obj:`numpy.shape`. - + Parameters ---------- a : array_like @@ -870,7 +870,7 @@ def transpose(a, axes=None): elif isinstance(a, dpt.usm_ndarray): array = dpnp_array._create_from_usm_ndarray(a.get_array()) else: - raise TypeError("An array must be any of supported type, but got {}".format(type(a))) + raise TypeError('An array must be any of supported type, but got {}'.format(type(a))) if axes is None: return array.transpose() diff --git a/dpnp/dpnp_iface_mathematical.py b/dpnp/dpnp_iface_mathematical.py index 49f839493f2..49fb1382a2e 100644 --- a/dpnp/dpnp_iface_mathematical.py +++ b/dpnp/dpnp_iface_mathematical.py @@ -57,48 +57,48 @@ __all__ = [ - "abs", - "absolute", - "add", - "around", - "ceil", - "conj", - "conjugate", - "convolve", - "copysign", - "cross", - "cumprod", - "cumsum", - "diff", - "divide", - "ediff1d", - "fabs", - "floor", - "floor_divide", - "fmax", - "fmin", - "fmod", - "gradient", - "maximum", - "minimum", - "mod", - "modf", - "multiply", - "nancumprod", - "nancumsum", - "nanprod", - "nansum", - "negative", - "power", - "prod", - "remainder", - "round_", - "sign", - "subtract", - "sum", - "trapz", - "true_divide", - "trunc" + 'abs', + 'absolute', + 'add', + 'around', + 'ceil', + 'conj', + 'conjugate', + 'convolve', + 'copysign', + 'cross', + 'cumprod', + 'cumsum', + 'diff', + 'divide', + 'ediff1d', + 'fabs', + 'floor', + 'floor_divide', + 'fmax', + 'fmin', + 'fmod', + 'gradient', + 'maximum', + 'minimum', + 'mod', + 'modf', + 'multiply', + 'nancumprod', + 'nancumsum', + 'nanprod', + 'nansum', + 'negative', + 'power', + 'prod', + 'remainder', + 'round_', + 'sign', + 'subtract', + 'sum', + 'trapz', + 'true_divide', + 'trunc' ] @@ -121,7 +121,7 @@ def _check_nd_call(origin_func, dpnp_func, x1, x2, out=None, where=True, order=' # at least either x1 or x2 has to be an array pass else: - if order in "afkcAFKC": + if order in 'afkcAFKC': order = order.upper() elif order is None: order = 'K' @@ -1393,7 +1393,7 @@ def power(x1, if x1_desc and x2_desc: if out is not None: if not isinstance(out, (dpnp.ndarray, dpt.usm_ndarray)): - raise TypeError("return array must be of supported array type") + raise TypeError('return array must be of supported array type') out_desc = dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False) or None else: out_desc = None diff --git a/dpnp/dpnp_iface_statistics.py b/dpnp/dpnp_iface_statistics.py index 45a3757d1a3..55b54e8cf8b 100644 --- a/dpnp/dpnp_iface_statistics.py +++ b/dpnp/dpnp_iface_statistics.py @@ -460,7 +460,7 @@ def mean(x, /, *, axis=None, dtype=None, keepdims=False, out=None, where=True): if not isinstance(axis,(tuple,list)): axis = (axis,) - axis = normalize_axis_tuple(axis, x.ndim, "axis") + axis = normalize_axis_tuple(axis, x.ndim, 'axis') res_sum = dpnp.sum(x, axis=axis, dtype=dtype) del_ = 1.0 diff --git a/dpnp/dpnp_iface_trigonometric.py b/dpnp/dpnp_iface_trigonometric.py index 47340107164..95a0669b596 100644 --- a/dpnp/dpnp_iface_trigonometric.py +++ b/dpnp/dpnp_iface_trigonometric.py @@ -942,7 +942,7 @@ def sqrt(x1, /, out = None, **kwargs): if x1_desc: if out is not None: if not isinstance(out, (dpnp.ndarray, dpt.usm_ndarray)): - raise TypeError("return array must be of supported array type") + raise TypeError('return array must be of supported array type') out_desc = dpnp.get_dpnp_descriptor(out, copy_when_nondefault_queue=False) or None else: out_desc = None diff --git a/dpnp/dpnp_iface_types.py b/dpnp/dpnp_iface_types.py index 0109f5bdd21..5141fbbf440 100644 --- a/dpnp/dpnp_iface_types.py +++ b/dpnp/dpnp_iface_types.py @@ -38,53 +38,53 @@ __all__ = [ - "bool", - "bool_", - "cdouble", - "complex_", - "complex128", - "complex64", - "complexfloating", - "cfloat", - "csingle", - "double", - "dtype", - "e", - "euler_gamma", - "float", - "float_", - "float16", - "float32", - "float64", - "floating", - "inexact", - "Inf", - "inf", - "Infinity", - "infty", - "int", - "int_", - "int32", - "int64", - "integer", - "intc", - "isscalar", - "issubdtype", - "issubsctype", - "is_type_supported", - "NAN", - "NaN", - "nan", - "newaxis", - "NINF", - "NZERO", - "number", - "pi", - "PINF", - "PZERO", - "signedinteger", - "single", - "singlecomplex" + 'bool', + 'bool_', + 'cdouble', + 'complex_', + 'complex128', + 'complex64', + 'complexfloating', + 'cfloat', + 'csingle', + 'double', + 'dtype', + 'e', + 'euler_gamma', + 'float', + 'float_', + 'float16', + 'float32', + 'float64', + 'floating', + 'inexact', + 'Inf', + 'inf', + 'Infinity', + 'infty', + 'int', + 'int_', + 'int32', + 'int64', + 'integer', + 'intc', + 'isscalar', + 'issubdtype', + 'issubsctype', + 'is_type_supported', + 'NAN', + 'NaN', + 'nan', + 'newaxis', + 'NINF', + 'NZERO', + 'number', + 'pi', + 'PINF', + 'PZERO', + 'signedinteger', + 'single', + 'singlecomplex' ] diff --git a/dpnp/dpnp_utils/dpnp_utils_statistics.py b/dpnp/dpnp_utils/dpnp_utils_statistics.py index 9e49655e9ee..52a9a3edef9 100644 --- a/dpnp/dpnp_utils/dpnp_utils_statistics.py +++ b/dpnp/dpnp_utils/dpnp_utils_statistics.py @@ -39,7 +39,7 @@ __all__ = [ - "dpnp_cov" + 'dpnp_cov' ] def dpnp_cov(m, y=None, rowvar=True, dtype=None): @@ -91,10 +91,10 @@ def _get_2dmin_array(x, dtype): # TODO: replace with dpnp.concatenate((X, y), axis=0) once dpctl implementation is ready if X.ndim != y.ndim: - raise ValueError("all the input arrays must have same number of dimensions") + raise ValueError('all the input arrays must have same number of dimensions') if X.shape[1:] != y.shape[1:]: - raise ValueError("all the input array dimensions for the concatenation axis must match exactly") + raise ValueError('all the input array dimensions for the concatenation axis must match exactly') res_shape = tuple(X.shape[i] if i > 0 else (X.shape[i] + y.shape[i]) for i in range(X.ndim)) res_usm = dpt.empty(res_shape, dtype=dtype, usm_type=usm_type, sycl_queue=queue) diff --git a/dpnp/fft/dpnp_iface_fft.py b/dpnp/fft/dpnp_iface_fft.py index 986dfaa8c61..606cd103035 100644 --- a/dpnp/fft/dpnp_iface_fft.py +++ b/dpnp/fft/dpnp_iface_fft.py @@ -49,24 +49,24 @@ __all__ = [ - "fft", - "fft2", - "fftfreq", - "fftn", - "fftshift", - "hfft", - "ifft", - "ifft2", - "ifftn", - "ifftshift", - "ihfft", - "irfft", - "irfft2", - "irfftn", - "rfft", - "rfft2", - "rfftfreq", - "rfftn" + 'fft', + 'fft2', + 'fftfreq', + 'fftn', + 'fftshift', + 'hfft', + 'ifft', + 'ifft2', + 'ifftn', + 'ifftshift', + 'ihfft', + 'irfft', + 'irfft2', + 'irfftn', + 'rfft', + 'rfft2', + 'rfftfreq', + 'rfftn' ] @@ -76,13 +76,13 @@ class Norm(Enum): ortho = 2 def get_validated_norm(norm): - if norm is None or norm == "backward": + if norm is None or norm == 'backward': return Norm.backward - if norm == "forward": + if norm == 'forward': return Norm.forward - if norm == "ortho": + if norm == 'ortho': return Norm.ortho - raise ValueError("Unknown norm value.") + raise ValueError('Unknown norm value.') def fft(x1, n=None, axis=-1, norm=None): @@ -208,7 +208,7 @@ def fftn(x1, s=None, axes=None, norm=None): try: param_n = boundaries[param_axis] except IndexError: - checker_throw_axis_error("fft.fftn", "is out of bounds", param_axis, f"< {len(boundaries)}") + checker_throw_axis_error('fft.fftn', 'is out of bounds', param_axis, f'< {len(boundaries)}') x1_iter = fft(x1_iter, n=param_n, axis=param_axis, norm=norm) @@ -429,7 +429,7 @@ def ifftn(x1, s=None, axes=None, norm=None): try: param_n = boundaries[param_axis] except IndexError: - checker_throw_axis_error("fft.ifftn", "is out of bounds", param_axis, f"< {len(boundaries)}") + checker_throw_axis_error('fft.ifftn', 'is out of bounds', param_axis, f'< {len(boundaries)}') x1_iter_desc = dpnp.get_dpnp_descriptor(x1_iter) x1_iter = ifft(x1_iter_desc.get_pyobj(), n=param_n, axis=param_axis, norm=norm) @@ -597,7 +597,7 @@ def irfftn(x1, s=None, axes=None, norm=None): try: param_n = boundaries[param_axis] except IndexError: - checker_throw_axis_error("fft.irfftn", "is out of bounds", param_axis, f"< {len(boundaries)}") + checker_throw_axis_error('fft.irfftn', 'is out of bounds', param_axis, f'< {len(boundaries)}') x1_iter_desc = dpnp.get_dpnp_descriptor(x1_iter) x1_iter = irfft(x1_iter_desc.get_pyobj(), n=param_n, axis=param_axis, norm=norm) @@ -736,7 +736,7 @@ def rfftn(x1, s=None, axes=None, norm=None): try: param_n = boundaries[param_axis] except IndexError: - checker_throw_axis_error("fft.rfftn", "is out of bounds", param_axis, f"< {len(boundaries)}") + checker_throw_axis_error('fft.rfftn', 'is out of bounds', param_axis, f'< {len(boundaries)}') x1_iter_desc = dpnp.get_dpnp_descriptor(x1_iter, copy_when_nondefault_queue=False) x1_iter = rfft(x1_iter_desc.get_pyobj(), n=param_n, axis=param_axis, norm=norm) diff --git a/dpnp/linalg/dpnp_iface_linalg.py b/dpnp/linalg/dpnp_iface_linalg.py index e2e96258578..b15ec34a993 100644 --- a/dpnp/linalg/dpnp_iface_linalg.py +++ b/dpnp/linalg/dpnp_iface_linalg.py @@ -53,19 +53,19 @@ __all__ = [ - "cholesky", - "cond", - "det", - "eig", - "eigh", - "eigvals", - "inv", - "matrix_power", - "matrix_rank", - "multi_dot", - "norm", - "qr", - "svd", + 'cholesky', + 'cond', + 'det', + 'eig', + 'eigh', + 'eigvals', + 'inv', + 'matrix_power', + 'matrix_rank', + 'multi_dot', + 'norm', + 'qr', + 'svd', ] @@ -219,22 +219,22 @@ def eigh(a, UPLO='L'): array([0.17157288, 5.82842712]), array([[-0.92387953-0.j , -0.38268343+0.j ], # may vary [ 0. +0.38268343j, 0. -0.92387953j]])) - + """ if UPLO not in ('L', 'U'): raise ValueError("UPLO argument must be 'L' or 'U'") if not dpnp.is_supported_array_type(a): - raise TypeError("An array must be any of supported type, but got {}".format(type(a))) + raise TypeError('An array must be any of supported type, but got {}'.format(type(a))) if a.ndim < 2: - raise ValueError("%d-dimensional array given. Array must be " - "at least two-dimensional" % a.ndim) + raise ValueError('%d-dimensional array given. Array must be ' + 'at least two-dimensional' % a.ndim) m, n = a.shape[-2:] if m != n: - raise ValueError("Last 2 dimensions of the array must be square") + raise ValueError('Last 2 dimensions of the array must be square') return dpnp_eigh(a, UPLO=UPLO) @@ -386,7 +386,7 @@ def multi_dot(arrays, out=None): n = len(arrays) if n < 2: - checker_throw_value_error("multi_dot", "arrays", n, ">1") + checker_throw_value_error('multi_dot', 'arrays', n, '>1') result = arrays[0] for id in range(1, n): diff --git a/dpnp/linalg/dpnp_utils_linalg.py b/dpnp/linalg/dpnp_utils_linalg.py index b7218b75d81..508698d3544 100644 --- a/dpnp/linalg/dpnp_utils_linalg.py +++ b/dpnp/linalg/dpnp_utils_linalg.py @@ -33,7 +33,7 @@ import dpctl.tensor._tensor_impl as ti __all__ = [ - "dpnp_eigh" + 'dpnp_eigh' ] _jobz = {'N': 0, 'V': 1} @@ -62,9 +62,9 @@ def dpnp_eigh(a, UPLO): # get resulting type of arrays with eigenvalues and eigenvectors a_dtype = a.dtype - lapack_func = "_syevd" + lapack_func = '_syevd' if dpnp.issubdtype(a_dtype, dpnp.complexfloating): - lapack_func = "_heevd" + lapack_func = '_heevd' v_type = a_dtype w_type = dpnp.float64 if a_dtype == dpnp.complex128 else dpnp.float32 elif dpnp.issubdtype(a_dtype, dpnp.floating): diff --git a/dpnp/random/dpnp_iface_random.py b/dpnp/random/dpnp_iface_random.py index a2e6f164dde..46678353801 100644 --- a/dpnp/random/dpnp_iface_random.py +++ b/dpnp/random/dpnp_iface_random.py @@ -102,14 +102,14 @@ def _get_random_state(device=None, sycl_queue=None): global _dpnp_random_states if not isinstance(_dpnp_random_states, dict): - _dpnp_random_states = dict() + _dpnp_random_states = {} sycl_queue = dpnp.get_normalized_queue_device(device=device, sycl_queue=sycl_queue) if sycl_queue not in _dpnp_random_states: rs = RandomState(device=device, sycl_queue=sycl_queue) if sycl_queue == rs.get_sycl_queue(): _dpnp_random_states[sycl_queue] = rs else: - raise RuntimeError("Normalized SYCL queue {} mismatched with one returned by RandmoState {}" + raise RuntimeError('Normalized SYCL queue {} mismatched with one returned by RandmoState {}' .format(sycl_queue, rs.get_sycl_queue())) return _dpnp_random_states[sycl_queue] @@ -787,7 +787,7 @@ def normal(loc=0.0, scale=1.0, size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Draw random samples from a normal (Gaussian) distribution. @@ -1018,7 +1018,7 @@ def power(a, size=None): def rand(d0, *dn, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Random values in a given shape. @@ -1068,7 +1068,7 @@ def randint(low, size=None, dtype=int, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return random integers from `low` (inclusive) to `high` (exclusive). @@ -1123,7 +1123,7 @@ def randint(low, def randn(d0, *dn, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return a sample (or samples) from the "standard normal" distribution. @@ -1172,7 +1172,7 @@ def randn(d0, def random(size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return random floats in the half-open interval [0.0, 1.0). @@ -1218,7 +1218,7 @@ def random_integers(low, high=None, size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Random integers between `low` and `high`, inclusive. @@ -1273,7 +1273,7 @@ def random_integers(low, def random_sample(size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return random floats in the half-open interval [0.0, 1.0). @@ -1319,7 +1319,7 @@ def random_sample(size=None, def ranf(size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return random floats in the half-open interval [0.0, 1.0). @@ -1398,7 +1398,7 @@ def rayleigh(scale=1.0, size=None): def sample(size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Return random floats in the half-open interval [0.0, 1.0). @@ -1603,7 +1603,7 @@ def standard_gamma(shape, size=None): def standard_normal(size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Draw samples from a standard Normal distribution (mean=0, stdev=1). @@ -1725,7 +1725,7 @@ def uniform(low=0.0, high=1.0, size=None, device=None, - usm_type="device", + usm_type='device', sycl_queue=None): """ Draw samples from a uniform distribution. diff --git a/dpnp/random/dpnp_random_state.py b/dpnp/random/dpnp_random_state.py index 462f4538dbd..fb584d4c765 100644 --- a/dpnp/random/dpnp_random_state.py +++ b/dpnp/random/dpnp_random_state.py @@ -154,7 +154,7 @@ def _validate_float_dtype(self, dtype, supported_types): dtype = self._def_float_type if not dtype in supported_types: - raise TypeError(f"dtype={dtype} is unsupported.") + raise TypeError(f'dtype={dtype} is unsupported.') elif dtype != map_dtype_to_device(dtype, self._sycl_device): raise RuntimeError(f"dtype={dtype} is not supported by SYCL device '{self._sycl_device}'") return dtype @@ -198,7 +198,7 @@ def get_sycl_device(self): return self._sycl_device - def normal(self, loc=0.0, scale=1.0, size=None, dtype=None, usm_type="device"): + def normal(self, loc=0.0, scale=1.0, size=None, dtype=None, usm_type='device'): """ Draw random samples from a normal (Gaussian) distribution. @@ -247,13 +247,13 @@ def normal(self, loc=0.0, scale=1.0, size=None, dtype=None, usm_type="device"): max_floating = numpy.finfo(dtype).max if (loc >= max_floating or loc <= min_floating) and self._is_finite_scalar(loc): - raise OverflowError(f"Range of loc={loc} exceeds valid bounds") + raise OverflowError(f'Range of loc={loc} exceeds valid bounds') if (scale >= max_floating) and self._is_finite_scalar(scale): - raise OverflowError(f"Range of scale={scale} exceeds valid bounds") + raise OverflowError(f'Range of scale={scale} exceeds valid bounds') # scale = -0.0 is cosidered as negative elif scale < 0 or scale == 0 and self._is_signbit_scalar(scale): - raise ValueError(f"scale={scale}, but must be non-negative.") + raise ValueError(f'scale={scale}, but must be non-negative.') dpu.validate_usm_type(usm_type=usm_type, allow_none=False) return self._random_state.normal(loc=loc, @@ -266,7 +266,7 @@ def normal(self, loc=0.0, scale=1.0, size=None, dtype=None, usm_type="device"): loc=loc, scale=scale, size=size, sycl_queue=self._sycl_queue) - def rand(self, *args, usm_type="device"): + def rand(self, *args, usm_type='device'): """ Draw random values in a given shape. @@ -309,7 +309,7 @@ def rand(self, *args, usm_type="device"): return self.random_sample(size=args, usm_type=usm_type) - def randint(self, low, high=None, size=None, dtype=int, usm_type="device"): + def randint(self, low, high=None, size=None, dtype=int, usm_type='device'): """ Draw random integers from `low` (inclusive) to `high` (exclusive). @@ -368,14 +368,14 @@ def randint(self, low, high=None, size=None, dtype=int, usm_type="device"): max_int = numpy.iinfo('int32').max if not self._is_finite_scalar(low) or low > max_int or low < min_int: - raise OverflowError(f"Range of low={low} exceeds valid bounds") + raise OverflowError(f'Range of low={low} exceeds valid bounds') elif not self._is_finite_scalar(high) or high > max_int or high < min_int: - raise OverflowError(f"Range of high={high} exceeds valid bounds") + raise OverflowError(f'Range of high={high} exceeds valid bounds') low = int(low) high = int(high) if low >= high: - raise ValueError(f"low={low} >= high={high}") + raise ValueError(f'low={low} >= high={high}') return self.uniform(low=low, high=high, @@ -387,7 +387,7 @@ def randint(self, low, high=None, size=None, dtype=int, usm_type="device"): low=low, high=high, size=size, dtype=dtype, sycl_queue=self._sycl_queue) - def randn(self, *args, usm_type="device"): + def randn(self, *args, usm_type='device'): """ Return a sample (or samples) from the "standard normal" distribution. @@ -434,7 +434,7 @@ def randn(self, *args, usm_type="device"): usm_type=usm_type) - def random_sample(self, size=None, usm_type="device"): + def random_sample(self, size=None, usm_type='device'): """ Draw random floats in the half-open interval [0.0, 1.0). @@ -475,7 +475,7 @@ def random_sample(self, size=None, usm_type="device"): usm_type=usm_type) - def standard_normal(self, size=None, usm_type="device"): + def standard_normal(self, size=None, usm_type='device'): """ Draw samples from a standard Normal distribution (mean=0, stdev=1). @@ -516,7 +516,7 @@ def standard_normal(self, size=None, usm_type="device"): usm_type=usm_type) - def uniform(self, low=0.0, high=1.0, size=None, dtype=None, usm_type="device"): + def uniform(self, low=0.0, high=1.0, size=None, dtype=None, usm_type='device'): """ Draw samples from a uniform distribution. @@ -571,9 +571,9 @@ def uniform(self, low=0.0, high=1.0, size=None, dtype=None, usm_type="device"): max_double = numpy.finfo('double').max if not self._is_finite_scalar(low) or low >= max_double or low <= min_double: - raise OverflowError(f"Range of low={low} exceeds valid bounds") + raise OverflowError(f'Range of low={low} exceeds valid bounds') elif not self._is_finite_scalar(high) or high >= max_double or high <= min_double: - raise OverflowError(f"Range of high={high} exceeds valid bounds") + raise OverflowError(f'Range of high={high} exceeds valid bounds') if low > high: low, high = high, low diff --git a/dpnp/to_numba/dpnp_iface_to_numba.py b/dpnp/to_numba/dpnp_iface_to_numba.py index 77b9a957ffa..421b7f11637 100644 --- a/dpnp/to_numba/dpnp_iface_to_numba.py +++ b/dpnp/to_numba/dpnp_iface_to_numba.py @@ -42,11 +42,11 @@ name_to_numba_signatures = { - "cos": [(numba.types.float64)] + 'cos': [(numba.types.float64)] } name_and_types_to_pointer = { - ("cos", numba.types.float64): ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double)(nba_addr("dpnp.dpnp_algo", "dpnp_cos")) + ('cos', numba.types.float64): ctypes.CFUNCTYPE(ctypes.c_double, ctypes.c_double)(nba_addr('dpnp.dpnp_algo', 'dpnp_cos')) } @@ -64,5 +64,5 @@ def choice_function(*args): def add_overloads(): for name, all_signatures in name_to_numba_signatures.items(): sc_function = getattr(sc, name) - print(f"sc_function={sc_function}") + print(f'sc_function={sc_function}') numba.extending.overload(sc_function)(choose_kernel(name, all_signatures)) diff --git a/dpnp/version.py b/dpnp/version.py old mode 100644 new mode 100755 diff --git a/examples/example1.py b/examples/example1.py old mode 100755 new mode 100644 index d9c9369a6b2..7c4351998d4 --- a/examples/example1.py +++ b/examples/example1.py @@ -74,18 +74,18 @@ def run_dgemm(executor, name, size, test_type, repetition): test_repetition = 5 for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32]: type_name = numpy.dtype(test_type).name - print(f"...Test data type is {test_type}, each test repetitions {test_repetition}") + print(f'...Test data type is {test_type}, each test repetitions {test_repetition}') for size in [16, 32, 64, 128]: # , 256, 512, 1024, 2048, 4096]: - times_python, result_python = run_dgemm(numpy, "", size, test_type, test_repetition) - times_sycl, result_mkl = run_dgemm(dpnp, " ", size, test_type, test_repetition) + times_python, result_python = run_dgemm(numpy, '', size, test_type, test_repetition) + times_sycl, result_mkl = run_dgemm(dpnp, ' ', size, test_type, test_repetition) verification = False if result_mkl == result_python: verification = True - msg = f"type:{type_name}:N:{size:4}" - msg += f":__NumPy__:{times_python[1]:.3e}:(min:{times_python[0]:.3e}:max:{times_python[2]:.3e})" - msg += f":__SYCL__:{times_sycl[1]:.3e}:(min:{times_sycl[0]:.3e}:max:{times_sycl[2]:.3e})" - msg += f":ratio:{times_python[1]/times_sycl[1]:6.2f}:verification:{verification}" + msg = f'type:{type_name}:N:{size:4}' + msg += f':__NumPy__:{times_python[1]:.3e}:(min:{times_python[0]:.3e}:max:{times_python[2]:.3e})' + msg += f':__SYCL__:{times_sycl[1]:.3e}:(min:{times_sycl[0]:.3e}:max:{times_sycl[2]:.3e})' + msg += f':ratio:{times_python[1]/times_sycl[1]:6.2f}:verification:{verification}' print(msg) diff --git a/examples/example10.py b/examples/example10.py index cdf8aa1e0e0..5e5e367a7e1 100644 --- a/examples/example10.py +++ b/examples/example10.py @@ -63,7 +63,7 @@ def example(): test_repetition = 5 for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32]: type_name = numpy.dtype(test_type).name - print(f"...Test data type is {type_name}, each test repetitions {test_repetition}") + print(f'...Test data type is {type_name}, each test repetitions {test_repetition}') for size in [64, 128, 256, 512, 1024, 2048, 4096]: time_numpy, result_numpy = run(numpy, size, test_type, test_repetition) @@ -72,18 +72,18 @@ def example(): if result_dpnp == result_numpy: verification = True else: - verification = f"({result_dpnp} != {result_numpy})" + verification = f'({result_dpnp} != {result_numpy})' - msg = f"type:{type_name}:N:{size:4}:NumPy:{time_numpy:.3e}:SYCL:{time_dpnp:.3e}" - msg += f":ratio:{time_numpy/time_dpnp:6.2f}:verification:{verification}" + msg = f'type:{type_name}:N:{size:4}:NumPy:{time_numpy:.3e}:SYCL:{time_dpnp:.3e}' + msg += f':ratio:{time_numpy/time_dpnp:6.2f}:verification:{verification}' print(msg) -if __name__ == "__main__": +if __name__ == '__main__': try: import dpctl - with dpctl.device_context("opencl:gpu") as gpu_queue: + with dpctl.device_context('opencl:gpu') as gpu_queue: gpu_queue.get_sycl_device().dump_device_info() example() diff --git a/examples/example2.py b/examples/example2.py old mode 100755 new mode 100644 index 92476599a56..bf3d6ad4b9a --- a/examples/example2.py +++ b/examples/example2.py @@ -76,10 +76,10 @@ def run_third_party_function(input, repetition): test_repetition = 5 for input_type in [numpy, dpnp]: type_name = input_type.__name__ - print(f"...Test data type is {type_name}, each test repetitions {test_repetition}") + print(f'...Test data type is {type_name}, each test repetitions {test_repetition}') for size in [2048, 4096, 8192, 16384, 32768, 65536]: input_data = get_package_specific_input_data_type(input_type, size) result_time, result = run_third_party_function(input_data, test_repetition) - print(f"type:{type_name}:N:{size:6}:Time:{result_time:.3e}:result:{result:.3e}") + print(f'type:{type_name}:N:{size:6}:Time:{result_time:.3e}:result:{result:.3e}') diff --git a/examples/example4.py b/examples/example4.py old mode 100755 new mode 100644 index 6705149d52b..c063d2e08b7 --- a/examples/example4.py +++ b/examples/example4.py @@ -43,7 +43,7 @@ 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__}") + print(f'input:{data.dtype.name:10}: outout:{result.dtype.name:10}: name:{function.__name__}') """ Two arguments functions @@ -56,6 +56,6 @@ data2 = numpy.array([11, 21, 31, 41], dtype=input2_type) result = function(data1, data2) - msg = f"input1:{data1.dtype.name:10}: input2:{data2.dtype.name:10}" - msg += f": output:{result.dtype.name:10}: name:{function}" + msg = f'input1:{data1.dtype.name:10}: input2:{data2.dtype.name:10}' + msg += f': output:{result.dtype.name:10}: name:{function}' print(msg) diff --git a/examples/example7.py b/examples/example7.py old mode 100755 new mode 100644 index fbf73f3aff7..99a33cad8d8 --- a/examples/example7.py +++ b/examples/example7.py @@ -70,17 +70,17 @@ def run_function(executor, name, size, test_type, repetition): test_repetition = 5 for test_type in [numpy.float64, numpy.float32, numpy.int64, numpy.int32]: type_name = numpy.dtype(test_type).name - print(f"...Test data type is {test_type}, each test repetitions {test_repetition}") + print(f'...Test data type is {test_type}, each test repetitions {test_repetition}') for size in [16, 32, 64, 128, 256, 512, 1024, 2048, 4096]: - time_python, result_python = run_function(numpy, "", size, test_type, test_repetition) - time_mkl, result_mkl = run_function(dpnp, " ", size, test_type, test_repetition) + time_python, result_python = run_function(numpy, '', size, test_type, test_repetition) + time_mkl, result_mkl = run_function(dpnp, ' ', size, test_type, test_repetition) if result_mkl == result_python: verification = True else: - verification = f"({result_mkl} != {result_python})" + verification = f'({result_mkl} != {result_python})' - msg = f"type:{type_name}:N:{size:4}:NumPy:{time_python:.3e}:SYCL:{time_mkl:.3e}" - msg += f":ratio:{time_python/time_mkl:6.2f}:verification:{verification}" + msg = f'type:{type_name}:N:{size:4}:NumPy:{time_python:.3e}:SYCL:{time_mkl:.3e}' + msg += f':ratio:{time_python/time_mkl:6.2f}:verification:{verification}' print(msg) diff --git a/scripts/azure-pipelines.yml b/scripts/azure-pipelines.yml index 206a6fe4d53..ea9e6ca9d0c 100644 --- a/scripts/azure-pipelines.yml +++ b/scripts/azure-pipelines.yml @@ -155,7 +155,7 @@ jobs: # - bash: | # echo ========================= install OneAPI ================================= # ./scripts/install_system_deps.sh -# +# # echo ========================= Conda ENV ====================================== # conda create -q -y -n dpnp$(python.version) python=$(python.version) numpy=1.19 conda-build cython pytest hypothesis # . /usr/share/miniconda/etc/profile.d/conda.sh diff --git a/scripts/build_deps_dpctl.sh b/scripts/build_deps_dpctl.sh index 990a6162752..3d5331bbdfb 100755 --- a/scripts/build_deps_dpctl.sh +++ b/scripts/build_deps_dpctl.sh @@ -4,7 +4,7 @@ THEDIR=$(dirname $(readlink -e ${BASH_SOURCE[0]})) DPCTL_TARGET_VERSION=0.5.0rc2 echo ++++++++++++++++++ Build DPCTL ${DPCTL_TARGET_VERSION} +++++++++++++++++++ -git clone --branch ${DPCTL_TARGET_VERSION} https://github.com/IntelPython/dpctl.git +git clone --branch ${DPCTL_TARGET_VERSION} https://github.com/IntelPython/dpctl.git cd dpctl diff --git a/scripts/build_deps_dpctl_win.bat b/scripts/build_deps_dpctl_win.bat old mode 100755 new mode 100644 index 464bb74c2ae..25f59290829 --- a/scripts/build_deps_dpctl_win.bat +++ b/scripts/build_deps_dpctl_win.bat @@ -1,4 +1,4 @@ -rem git clone --branch 0.5.0rc2 https://github.com/IntelPython/dpctl.git +rem git clone --branch 0.5.0rc2 https://github.com/IntelPython/dpctl.git rem for /f "tokens=* delims=" %%a in ('git tag -l') do git tag -d %%a rem git tag 0.5.0rc2 @@ -11,7 +11,7 @@ set DPCTL_DIST=%CD%\dist_dpctl call conda uninstall -y dpctl echo +++++++++++++++++++++++++ Downlowd DPCTL +++++++++++++++++++++++++++ -call git clone https://github.com/IntelPython/dpctl.git +call git clone https://github.com/IntelPython/dpctl.git cd dpctl set "ONEAPI_ROOT=C:\Program Files (x86)\Intel\oneAPI\" diff --git a/scripts/build_locally.py b/scripts/build_locally.py index 6d008851e7e..73dae4c26ae 100644 --- a/scripts/build_locally.py +++ b/scripts/build_locally.py @@ -32,111 +32,111 @@ def run( use_oneapi=True, - build_type="Release", + build_type='Release', c_compiler=None, cxx_compiler=None, compiler_root=None, cmake_executable=None, verbose=False, - cmake_opts="", + cmake_opts='', ): build_system = None - if "linux" in sys.platform: - build_system = "Ninja" - elif sys.platform in ["win32", "cygwin"]: - build_system = "Ninja" + if 'linux' in sys.platform: + build_system = 'Ninja' + elif sys.platform in ['win32', 'cygwin']: + build_system = 'Ninja' else: - assert False, sys.platform + " not supported" + assert False, sys.platform + ' not supported' setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) cmake_args = [ sys.executable, - "setup.py", - "develop", + 'setup.py', + 'develop', ] if cmake_executable: cmake_args += [ - "--cmake-executable=" + cmake_executable, + '--cmake-executable=' + cmake_executable, ] - dpctl_module_path = os.path.join(dpctl.get_include(), "..", "resources", "cmake") + dpctl_module_path = os.path.join(dpctl.get_include(), '..', 'resources', 'cmake') cmake_args += [ - "--build-type=" + build_type, - "--generator=" + build_system, - "--", - "-DCMAKE_C_COMPILER:PATH=" + c_compiler, - "-DCMAKE_CXX_COMPILER:PATH=" + cxx_compiler, - "-DDPCTL_MODULE_PATH:PATH=" + dpctl_module_path, + '--build-type=' + build_type, + '--generator=' + build_system, + '--', + '-DCMAKE_C_COMPILER:PATH=' + c_compiler, + '-DCMAKE_CXX_COMPILER:PATH=' + cxx_compiler, + '-DDPCTL_MODULE_PATH:PATH=' + dpctl_module_path, ] if verbose: cmake_args += [ - "-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON", + '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON', ] if cmake_opts: cmake_args += cmake_opts.split() if use_oneapi: - if "DPL_ROOT" in os.environ: - os.environ["DPL_ROOT_HINT"] = os.environ["DPL_ROOT"] + if 'DPL_ROOT' in os.environ: + os.environ['DPL_ROOT_HINT'] = os.environ['DPL_ROOT'] subprocess.check_call( cmake_args, shell=False, cwd=setup_dir, env=os.environ ) -if __name__ == "__main__": +if __name__ == '__main__': import argparse parser = argparse.ArgumentParser( - description="Driver to build dpnp for in-place installation" + description='Driver to build dpnp for in-place installation' ) - driver = parser.add_argument_group(title="Coverage driver arguments") - driver.add_argument("--c-compiler", help="Name of C compiler", default=None) + driver = parser.add_argument_group(title='Coverage driver arguments') + driver.add_argument('--c-compiler', help='Name of C compiler', default=None) driver.add_argument( - "--cxx-compiler", help="Name of C++ compiler", default=None + '--cxx-compiler', help='Name of C++ compiler', default=None ) driver.add_argument( - "--oneapi", - help="Set if using one-API installation", - dest="oneapi", - action="store_true", + '--oneapi', + help='Set if using one-API installation', + dest='oneapi', + action='store_true', ) driver.add_argument( - "--debug", - default="Release", - const="Debug", - action="store_const", - help="Set the compilation mode to debugging", + '--debug', + default='Release', + const='Debug', + action='store_const', + help='Set the compilation mode to debugging', ) driver.add_argument( - "--compiler-root", + '--compiler-root', type=str, - help="Path to compiler home directory", + help='Path to compiler home directory', default=None, ) driver.add_argument( - "--cmake-executable", + '--cmake-executable', type=str, - help="Path to cmake executable", + help='Path to cmake executable', default=None, ) driver.add_argument( - "--verbose", - help="Build using vebose makefile mode", - dest="verbose", - action="store_true", + '--verbose', + help='Build using vebose makefile mode', + dest='verbose', + action='store_true', ) driver.add_argument( - "--cmake-opts", - help="Channels through additional cmake options", - dest="cmake_opts", - default="", + '--cmake-opts', + help='Channels through additional cmake options', + dest='cmake_opts', + default='', type=str, ) args = parser.parse_args() args_to_validate = [ - "c_compiler", - "cxx_compiler", - "compiler_root", + 'c_compiler', + 'cxx_compiler', + 'compiler_root', ] if args.oneapi or ( @@ -144,24 +144,24 @@ def run( and args.cxx_compiler is None and args.compiler_root is None ): - args.c_compiler = "icx" - args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx" + args.c_compiler = 'icx' + args.cxx_compiler = 'icpx' if 'linux' in sys.platform else 'icx' args.compiler_root = None else: cr = args.compiler_root if isinstance(cr, str) and os.path.exists(cr): if args.c_compiler is None: - args.c_compiler = "icx" + args.c_compiler = 'icx' if args.cxx_compiler is None: - args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx" + args.cxx_compiler = 'icpx' if 'linux' in sys.platform else 'icx' else: raise RuntimeError( "Option 'compiler-root' must be provided when " - "using non-default DPC++ layout." + 'using non-default DPC++ layout.' ) args_to_validate = [ - "c_compiler", - "cxx_compiler", + 'c_compiler', + 'cxx_compiler', ] for p in args_to_validate: arg = getattr(args, p) @@ -172,8 +172,8 @@ def run( arg = arg2 setattr(args, p, arg) if not os.path.exists(arg): - opt_name = p.replace("_", "-") - raise RuntimeError(f"Option {opt_name} value {arg} must exist.") + opt_name = p.replace('_', '-') + raise RuntimeError(f'Option {opt_name} value {arg} must exist.') run( use_oneapi=args.oneapi, diff --git a/scripts/gen_coverage.py b/scripts/gen_coverage.py index 9fb2d86d0df..2b69b8773eb 100644 --- a/scripts/gen_coverage.py +++ b/scripts/gen_coverage.py @@ -6,66 +6,66 @@ def run( c_compiler=None, cxx_compiler=None, bin_llvm=None, - pytest_opts = "", + pytest_opts = '', ): IS_LIN = False - if "linux" in sys.platform: + if 'linux' in sys.platform: IS_LIN = True - elif sys.platform in ["win32", "cygwin"]: + elif sys.platform in ['win32', 'cygwin']: pass else: - assert False, sys.platform + " not supported" + assert False, sys.platform + ' not supported' if not IS_LIN: raise RuntimeError( - "This scripts only supports coverage collection on Linux" + 'This scripts only supports coverage collection on Linux' ) setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - dpctl_cmake_dir = subprocess.check_output([sys.executable, "-m", "dpctl", "--cmakedir"]) + dpctl_cmake_dir = subprocess.check_output([sys.executable, '-m', 'dpctl', '--cmakedir']) cmake_args = [ sys.executable, - "setup.py", - "develop", - "-G=Ninja", - "--", - "-DCMAKE_C_COMPILER:PATH=" + c_compiler, - "-DCMAKE_CXX_COMPILER:PATH=" + cxx_compiler, - "-DDPCTL_MODULE_PATH=" + dpctl_cmake_dir.decode().rstrip(), - "-DCMAKE_VERBOSE_MAKEFILE=ON", - "-DDPNP_GENERATE_COVERAGE=ON", + 'setup.py', + 'develop', + '-G=Ninja', + '--', + '-DCMAKE_C_COMPILER:PATH=' + c_compiler, + '-DCMAKE_CXX_COMPILER:PATH=' + cxx_compiler, + '-DDPCTL_MODULE_PATH=' + dpctl_cmake_dir.decode().rstrip(), + '-DCMAKE_VERBOSE_MAKEFILE=ON', + '-DDPNP_GENERATE_COVERAGE=ON', ] env = None if bin_llvm: env = { - "PATH": ":".join((os.environ.get("PATH", ""), bin_llvm)), - "LLVM_TOOLS_HOME": bin_llvm, + 'PATH': ':'.join((os.environ.get('PATH', ''), bin_llvm)), + 'LLVM_TOOLS_HOME': bin_llvm, } - env.update({k: v for k, v in os.environ.items() if k != "PATH"}) + env.update({k: v for k, v in os.environ.items() if k != 'PATH'}) subprocess.check_call(cmake_args, shell=False, cwd=setup_dir, env=env) - env["LLVM_PROFILE_FILE"] = "dpnp_pytest.profraw" + env['LLVM_PROFILE_FILE'] = 'dpnp_pytest.profraw' subprocess.check_call( [ - "pytest", - "-q", - "-ra", - "--disable-warnings", - "--cov-config", - "pyproject.toml", - "--cov", - "dpnp", - "--cov-report", - "term-missing", - "--pyargs", - "tests", - "-vv", + 'pytest', + '-q', + '-ra', + '--disable-warnings', + '--cov-config', + 'pyproject.toml', + '--cov', + 'dpnp', + '--cov-report', + 'term-missing', + '--pyargs', + 'tests', + '-vv', *pytest_opts.split(), ], cwd=setup_dir, @@ -78,63 +78,63 @@ def find_objects(): objects = [] dpnp_path = os.getcwd() - search_path = os.path.join(dpnp_path, "dpnp") + search_path = os.path.join(dpnp_path, 'dpnp') files = os.listdir(search_path) for file in files: - if file.endswith("_c.so"): - objects.extend(["-object", os.path.join(search_path, file)]) + if file.endswith('_c.so'): + objects.extend(['-object', os.path.join(search_path, file)]) return objects objects = find_objects() - instr_profile_fn = "dpnp_pytest.profdata" + instr_profile_fn = 'dpnp_pytest.profdata' # generate instrumentation profile data subprocess.check_call( [ - os.path.join(bin_llvm, "llvm-profdata"), - "merge", - "-sparse", - env["LLVM_PROFILE_FILE"], - "-o", + os.path.join(bin_llvm, 'llvm-profdata'), + 'merge', + '-sparse', + env['LLVM_PROFILE_FILE'], + '-o', instr_profile_fn, ] ) # export lcov - with open("dpnp_pytest.lcov", "w") as fh: + with open('dpnp_pytest.lcov', 'w') as fh: subprocess.check_call( [ - os.path.join(bin_llvm, "llvm-cov"), - "export", - "-format=lcov", - "-ignore-filename-regex=/tmp/icpx*", - "-instr-profile=" + instr_profile_fn, + os.path.join(bin_llvm, 'llvm-cov'), + 'export', + '-format=lcov', + '-ignore-filename-regex=/tmp/icpx*', + '-instr-profile=' + instr_profile_fn, ] + objects, stdout=fh, ) -if __name__ == "__main__": +if __name__ == '__main__': import argparse parser = argparse.ArgumentParser( - description="Driver to build dpnp and generate coverage" + description='Driver to build dpnp and generate coverage' ) - driver = parser.add_argument_group(title="Coverage driver arguments") + driver = parser.add_argument_group(title='Coverage driver arguments') driver.add_argument( - "--pytest-opts", - help="Channels through additional pytest options", - dest="pytest_opts", - default="", + '--pytest-opts', + help='Channels through additional pytest options', + dest='pytest_opts', + default='', type=str, ) args = parser.parse_args() - c_compiler = "icx" - cxx_compiler = "icpx" - icx_path = subprocess.check_output(["which", "icx"]) + c_compiler = 'icx' + cxx_compiler = 'icpx' + icx_path = subprocess.check_output(['which', 'icx']) bin_dir = os.path.dirname(os.path.dirname(icx_path)) - bin_llvm = os.path.join(bin_dir.decode("utf-8"), "bin-llvm") + bin_llvm = os.path.join(bin_dir.decode('utf-8'), 'bin-llvm') run( diff --git a/scripts/install_cmake_win.bat b/scripts/install_cmake_win.bat old mode 100755 new mode 100644 diff --git a/scripts/install_system_deps.sh b/scripts/install_system_deps.sh index 14ac03bb5a3..a0bd07a040c 100755 --- a/scripts/install_system_deps.sh +++ b/scripts/install_system_deps.sh @@ -5,7 +5,7 @@ THEDIR=$(dirname $(readlink -e ${BASH_SOURCE[0]})) # echo +++++++++++++++++++++++++ System prerequisites +++++++++++++++++++++++++++ # sudo apt-get install -f # sudo dpkg --configure -a -# sudo apt-get install -f +# sudo apt-get install -f # sudo apt-get clean # sudo apt-get autoclean @@ -77,7 +77,7 @@ sudo aptitude install -y cmake valgrind libgtest-dev #echo ========================= install/delete libstdc++-dev =================== #sudo apt remove -y gcc-7 g++-7 gcc-8 g++-8 gcc-10 g++-10 -# oneapi beta 10 can not work with libstdc++-10-dev +# oneapi beta 10 can not work with libstdc++-10-dev #sudo apt remove -y libstdc++-10-dev #sudo apt autoremove #sudo apt install --reinstall -y gcc-9 g++-9 libstdc++-9-dev diff --git a/scripts/install_system_deps_win.bat b/scripts/install_system_deps_win.bat old mode 100755 new mode 100644 diff --git a/setup.py b/setup.py index 608dd8dd1c7..9b0273e2f9b 100644 --- a/setup.py +++ b/setup.py @@ -11,14 +11,14 @@ __version__ = version_mod.__version__ setup( - name="dpnp", + name='dpnp', version=__version__, - description="", - long_description="", - long_description_content_type="text/markdown", - license="Apache 2.0", - author="Intel Corporation", - url="https://github.com/IntelPython/dpnp", + description='', + long_description='', + long_description_content_type='text/markdown', + license='Apache 2.0', + author='Intel Corporation', + url='https://github.com/IntelPython/dpnp', packages=['dpnp', 'dpnp.dpnp_algo', 'dpnp.dpnp_utils', diff --git a/tests/conftest.py b/tests/conftest.py old mode 100755 new mode 100644 index 22276f125f2..da77c603490 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -52,12 +52,12 @@ def pytest_collection_modifyitems(config, items): test_exclude_file_gpu = os.path.join(test_path, 'skipped_tests_gpu.tbl') current_queue_is_cpu = dpnp.dpnp_queue_is_cpu() - print("") - print(f"DPNP current queue is CPU: {current_queue_is_cpu}") - print(f"DPNP version: {dpnp.__version__}, location: {dpnp}") - print(f"NumPy version: {numpy.__version__}, location: {numpy}") - print(f"Python version: {sys.version}") - print("") + print('') + print(f'DPNP current queue is CPU: {current_queue_is_cpu}') + print(f'DPNP version: {dpnp.__version__}, location: {dpnp}') + print(f'NumPy version: {numpy.__version__}, location: {numpy}') + print(f'Python version: {sys.version}') + print('') if not current_queue_is_cpu or os.getenv('DPNP_QUEUE_GPU') == '1': excluded_tests.extend(get_excluded_tests(test_exclude_file_gpu)) else: diff --git a/tests/test_absolute.py b/tests/test_absolute.py index 81929ca3aa1..4b4bdcf55b9 100644 --- a/tests/test_absolute.py +++ b/tests/test_absolute.py @@ -14,8 +14,8 @@ ) -@pytest.mark.parametrize("func", ["abs", "absolute"]) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('func', ['abs', 'absolute']) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_abs(func, dtype): a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9], dtype=dtype) ia = dpnp.array(a) @@ -26,8 +26,8 @@ def test_abs(func, dtype): assert_equal(result.dtype, expected.dtype) -@pytest.mark.parametrize("stride", [-4, -2, -1, 1, 2, 4]) -@pytest.mark.parametrize("dtype", get_complex_dtypes()) +@pytest.mark.parametrize('stride', [-4, -2, -1, 1, 2, 4]) +@pytest.mark.parametrize('dtype', get_complex_dtypes()) def test_abs_complex(stride, dtype): np_arr = numpy.array([complex(numpy.nan , numpy.nan), complex(numpy.nan , numpy.inf), @@ -42,16 +42,16 @@ def test_abs_complex(stride, dtype): assert_equal(numpy.abs(np_arr[::stride]), dpnp.abs(dpnp_arr[::stride])) -@pytest.mark.parametrize("arraysize", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 18, 19]) -@pytest.mark.parametrize("stride", [-4, -3, -2, -1, 1, 2, 3, 4]) -@pytest.mark.parametrize("astype", get_complex_dtypes()) +@pytest.mark.parametrize('arraysize', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 18, 19]) +@pytest.mark.parametrize('stride', [-4, -3, -2, -1, 1, 2, 3, 4]) +@pytest.mark.parametrize('astype', get_complex_dtypes()) def test_abs_complex_avx(arraysize, stride, astype): np_arr = numpy.ones(arraysize, dtype=astype) dpnp_arr = dpnp.array(np_arr) assert_equal(numpy.abs(np_arr[::stride]), dpnp.abs(dpnp_arr[::stride])) -@pytest.mark.parametrize("dtype", get_float_complex_dtypes()) +@pytest.mark.parametrize('dtype', get_float_complex_dtypes()) def test_abs_values(dtype): np_arr = numpy.array([numpy.nan, -numpy.nan, numpy.inf, -numpy.inf, 0., -0., -1.0, 1.0], dtype=dtype) dpnp_arr = dpnp.array(np_arr) diff --git a/tests/test_amin_amax.py b/tests/test_amin_amax.py index 442690cc15d..dd5bf628cc0 100644 --- a/tests/test_amin_amax.py +++ b/tests/test_amin_amax.py @@ -5,7 +5,7 @@ import numpy -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.float64], ids=['float64']) def test_amax_float64(type): @@ -18,7 +18,7 @@ def test_amax_float64(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.int64], ids=['int64']) def test_amax_int(type): @@ -30,7 +30,7 @@ def test_amax_int(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.float64], ids=['float64']) def test_amin_float64(type): @@ -43,7 +43,7 @@ def test_amin_float64(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.int64], ids=['int64']) def test_amin_int(type): @@ -67,11 +67,11 @@ def _get_min_max_input(type, shape): return a.reshape(shape) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('type', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(4,), (2, 3), (4, 5, 6)], ids=['(4,)', '(2,3)', '(4,5,6)']) def test_amax(type, shape): @@ -88,11 +88,11 @@ def test_amax(type, shape): numpy.testing.assert_array_equal(dpnp_res, np_res) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('type', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(4,), (2, 3), (4, 5, 6)], ids=['(4,)', '(2,3)', '(4,5,6)']) def test_amin(type, shape): diff --git a/tests/test_arithmetic.py b/tests/test_arithmetic.py index aacb749ccc8..113b1ebf6de 100644 --- a/tests/test_arithmetic.py +++ b/tests/test_arithmetic.py @@ -22,14 +22,14 @@ def test_modf_part2(self, xp, dtype): return c - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_float_dtypes() @testing.numpy_cupy_allclose() def test_nanprod(self, xp, dtype): a = xp.array([-2.5, -1.5, xp.nan, 10.5, 1.5, xp.nan], dtype=dtype) return xp.nanprod(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_float_dtypes() @testing.numpy_cupy_allclose() def test_nansum(self, xp, dtype): diff --git a/tests/test_arraycreation.py b/tests/test_arraycreation.py index f8167b7d926..e9d11f13fbf 100644 --- a/tests/test_arraycreation.py +++ b/tests/test_arraycreation.py @@ -18,16 +18,16 @@ import operator -@pytest.mark.parametrize("start", +@pytest.mark.parametrize('start', [0, -5, 10, -2.5, 9.7], ids=['0', '-5', '10', '-2.5', '9.7']) -@pytest.mark.parametrize("stop", +@pytest.mark.parametrize('stop', [None, 10, -2, 20.5, 1000], ids=['None', '10', '-2', '20.5', '10**5']) -@pytest.mark.parametrize("step", +@pytest.mark.parametrize('step', [None, 1, 2.7, -1.6, 100], ids=['None', '1', '2.7', '-1.6', '100']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_float16=False)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_float16=False)) def test_arange(start, stop, step, dtype): rtol_mult = 2 if dpnp.issubdtype(dtype, dpnp.float16): @@ -57,10 +57,10 @@ def test_arange(start, stop, step, dtype): assert_array_equal(exp_array, res_array) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6], ids=['-6', '-5', '-4', '-3', '-2', '-1', '0', '1', '2', '3', '4', '5', '6']) -@pytest.mark.parametrize("v", +@pytest.mark.parametrize('v', [[0, 1, 2, 3, 4], [1, 1, 1, 1, 1], [[0, 0], [0, 0]], @@ -83,37 +83,37 @@ def test_diag(v, k): assert_array_equal(expected, result) -@pytest.mark.parametrize("N", +@pytest.mark.parametrize('N', [0, 1, 2, 3], ids=['0', '1', '2', '3']) -@pytest.mark.parametrize("M", +@pytest.mark.parametrize('M', [None, 0, 1, 2, 3], ids=['None', '0', '1', '2', '3']) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-4, -3, -2, -1, 0, 1, 2, 3, 4], ids=['-4', '-3', '-2', '-1', '0', '1', '2', '3', '4']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_eye(N, M, k, dtype, order): func = lambda xp: xp.eye(N, M, k=k, dtype=dtype, order=order) assert_array_equal(func(numpy), func(dpnp)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_frombuffer(dtype): buffer = b'12345678ABCDEF00' func = lambda xp: xp.frombuffer(buffer, dtype=dtype) assert_allclose(func(dpnp), func(numpy)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_fromfile(dtype): with tempfile.TemporaryFile() as fh: - fh.write(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08") + fh.write(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08') fh.flush() func = lambda xp: xp.fromfile(fh, dtype=dtype) @@ -127,8 +127,8 @@ def test_fromfile(dtype): assert_almost_equal(dpnp_res, np_res) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_float16=False)) def test_fromfunction(dtype): def func(x, y): return x * y @@ -138,27 +138,27 @@ def func(x, y): assert_array_equal(call_func(dpnp), call_func(numpy)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_fromiter(dtype): _iter = [1, 2, 3, 4] func = lambda xp: xp.fromiter(_iter, dtype=dtype) assert_array_equal(func(dpnp), func(numpy)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_fromstring(dtype): - string = "1 2 3 4" + string = '1 2 3 4' func = lambda xp: xp.fromstring(string, dtype=dtype, sep=' ') assert_array_equal(func(dpnp), func(numpy)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes()) -@pytest.mark.parametrize("num", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes()) +@pytest.mark.parametrize('num', [2, 4, 8, 3, 9, 27]) -@pytest.mark.parametrize("endpoint", +@pytest.mark.parametrize('endpoint', [True, False]) def test_geomspace(dtype, num, endpoint): start = 2 @@ -177,22 +177,22 @@ def test_geomspace(dtype, num, endpoint): assert_allclose(dpnp_res, np_res) -@pytest.mark.parametrize("n", +@pytest.mark.parametrize('n', [0, 1, 4], ids=['0', '1', '4']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_identity(n, dtype): func = lambda xp: xp.identity(n, dtype=dtype) assert_array_equal(func(numpy), func(dpnp)) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_loadtxt(dtype): func = lambda xp: xp.loadtxt(fh, dtype=dtype) with tempfile.TemporaryFile() as fh: - fh.write(b"1 2 3 4") + fh.write(b'1 2 3 4') fh.flush() fh.seek(0) @@ -203,12 +203,12 @@ def test_loadtxt(dtype): assert_array_equal(dpnp_res, np_res) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("offset", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('offset', [0, 1], ids=['0', '1']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -237,16 +237,16 @@ def test_trace(array, offset, type, dtype): assert_array_equal(trace_func(dpnp, ia), trace_func(numpy, a)) -@pytest.mark.parametrize("N", +@pytest.mark.parametrize('N', [0, 1, 2, 3, 4], ids=['0', '1', '2', '3', '4']) -@pytest.mark.parametrize("M", +@pytest.mark.parametrize('M', [0, 1, 2, 3, 4], ids=['0', '1', '2', '3', '4']) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-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", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_tri(N, M, k, dtype): func = lambda xp: xp.tri(N, M, k, dtype=dtype) assert_array_equal(func(dpnp), func(numpy)) @@ -258,12 +258,12 @@ def test_tri_default_dtype(): assert_array_equal(result, expected) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-3, -2, -1, 0, 1, 2, 3, 4, 5, numpy.array(1), dpnp.array(2), dpt.asarray(3)], ids=['-3', '-2', '-1', '0', '1', '2', '3', '4', '5', 'np.array(1)', 'dpnp.array(2)', 'dpt.asarray(3)']) -@pytest.mark.parametrize("m", +@pytest.mark.parametrize('m', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -274,8 +274,8 @@ def test_tri_default_dtype(): '[[1, 2], [3, 4]]', '[[0, 1, 2], [3, 4, 5], [6, 7, 8]]', '[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]']) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_tril(m, k, dtype): a = numpy.array(m, dtype=dtype) ia = dpnp.array(a) @@ -284,20 +284,20 @@ def test_tril(m, k, dtype): assert_array_equal(expected, result) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-3, -2, -1, 0, 1, 2, 3, 4, 5, numpy.array(1), dpnp.array(2), dpt.asarray(3)], ids=['-3', '-2', '-1', '0', '1', '2', '3', '4', '5', 'np.array(1)', 'dpnp.array(2)', 'dpt.asarray(3)']) -@pytest.mark.parametrize("m", +@pytest.mark.parametrize('m', [[[1, 2], [3, 4]], [[0, 1, 2], [3, 4, 5], [6, 7, 8]], [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]], ids=['[[1, 2], [3, 4]]', '[[0, 1, 2], [3, 4, 5], [6, 7, 8]]', '[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]']) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) def test_triu(m, k, dtype): a = numpy.array(m, dtype=dtype) ia = dpnp.array(a) @@ -306,7 +306,7 @@ def test_triu(m, k, dtype): assert_array_equal(expected, result) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [-4, -3, -2, -1, 0, 1, 2, 3, 4], ids=['-4', '-3', '-2', '-1', '0', '1', '2', '3', '4']) def test_triu_size_null(k): @@ -317,18 +317,18 @@ def test_triu_size_null(k): assert_array_equal(expected, result) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[1, 2, 3, 4], [], [0, 3, 5]], ids=['[1, 2, 3, 4]', '[]', '[0, 3, 5]']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) -@pytest.mark.parametrize("n", +@pytest.mark.parametrize('dtype', get_all_dtypes()) +@pytest.mark.parametrize('n', [0, 1, 4, None], ids=['0', '1', '4', 'None']) -@pytest.mark.parametrize("increase", +@pytest.mark.parametrize('increase', [True, False], ids=['True', 'False']) def test_vander(array, dtype, n, increase): @@ -340,30 +340,30 @@ def test_vander(array, dtype, n, increase): assert_array_equal(vander_func(numpy, a_np), vander_func(dpnp, a_dpnp)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), 0, (0,), (2, 0, 3), (3, 2)], ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) -@pytest.mark.parametrize("fill_value", +@pytest.mark.parametrize('fill_value', [1.5, 2, 1.5+0.j], ids=['1.5', '2', '1.5+0.j']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_full(shape, fill_value, dtype, order): func = lambda xp: xp.full(shape, fill_value, dtype=dtype, order=order) assert_array_equal(func(numpy), func(dpnp)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[], 0, [1, 2, 3], [[1, 2], [3, 4]]], ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("fill_value", +@pytest.mark.parametrize('fill_value', [1.5, 2, 1.5+0.j], ids=['1.5', '2', '1.5+0.j']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_full_like(array, fill_value, dtype, order): func = lambda xp, x: xp.full_like(x, fill_value, dtype=dtype, order=order) @@ -373,11 +373,11 @@ def test_full_like(array, fill_value, dtype, order): assert_array_equal(func(numpy, a), func(dpnp, ia)) -@pytest.mark.parametrize("order1", - ["F", "C"], +@pytest.mark.parametrize('order1', + ['F', 'C'], ids=['F', 'C']) -@pytest.mark.parametrize("order2", - ["F", "C"], +@pytest.mark.parametrize('order2', + ['F', 'C'], ids=['F', 'C']) def test_full_order(order1, order2): array = numpy.array([1, 2, 3], order=order1) @@ -390,18 +390,18 @@ def test_full_order(order1, order2): def test_full_strides(): - a = numpy.full((3, 3), numpy.arange(3, dtype="i4")) - ia = dpnp.full((3, 3), dpnp.arange(3, dtype="i4")) + a = numpy.full((3, 3), numpy.arange(3, dtype='i4')) + ia = dpnp.full((3, 3), dpnp.arange(3, dtype='i4')) assert ia.strides == tuple(el // a.itemsize for el in a.strides) assert_array_equal(dpnp.asnumpy(ia), a) - a = numpy.full((3, 3), numpy.arange(6, dtype="i4")[::2]) - ia = dpnp.full((3, 3), dpnp.arange(6, dtype="i4")[::2]) + a = numpy.full((3, 3), numpy.arange(6, dtype='i4')[::2]) + ia = dpnp.full((3, 3), dpnp.arange(6, dtype='i4')[::2]) assert ia.strides == tuple(el // a.itemsize for el in a.strides) assert_array_equal(dpnp.asnumpy(ia), a) -@pytest.mark.parametrize("fill_value", +@pytest.mark.parametrize('fill_value', [[], (), dpnp.full(0, 0)], ids=['[]', '()', 'dpnp.full(0, 0)']) def test_full_invalid_fill_value(fill_value): @@ -409,24 +409,24 @@ def test_full_invalid_fill_value(fill_value): dpnp.full(10, fill_value=fill_value) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), 0, (0,), (2, 0, 3), (3, 2)], ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_zeros(shape, dtype, order): func = lambda xp: xp.zeros(shape, dtype=dtype, order=order) assert_array_equal(func(numpy), func(dpnp)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[], 0, [1, 2, 3], [[1, 2], [3, 4]]], ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_zeros_like(array, dtype, order): func = lambda xp, x: xp.zeros_like(x, dtype=dtype, order=order) @@ -436,24 +436,24 @@ def test_zeros_like(array, dtype, order): assert_array_equal(func(numpy, a), func(dpnp, ia)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), 0, (0,), (2, 0, 3), (3, 2)], ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_empty(shape, dtype, order): func = lambda xp: xp.empty(shape, dtype=dtype, order=order) assert func(numpy).shape == func(dpnp).shape -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[], 0, [1, 2, 3], [[1, 2], [3, 4]]], ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_empty_like(array, dtype, order): func = lambda xp, x: xp.empty_like(x, dtype=dtype, order=order) @@ -463,24 +463,24 @@ def test_empty_like(array, dtype, order): assert func(numpy, a).shape == func(dpnp, ia).shape -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), 0, (0,), (2, 0, 3), (3, 2)], ids=['()', '0', '(0,)', '(2, 0, 3)', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_ones(shape, dtype, order): func = lambda xp: xp.ones(shape, dtype=dtype, order=order) assert_array_equal(func(numpy), func(dpnp)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[], 0, [1, 2, 3], [[1, 2], [3, 4]]], ids=['[]', '0', '[1, 2, 3]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("order", - [None, "C", "F"], +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('order', + [None, 'C', 'F'], ids=['None', 'C', 'F']) def test_ones_like(array, dtype, order): func = lambda xp, x: xp.ones_like(x, dtype=dtype, order=order) @@ -491,15 +491,15 @@ def test_ones_like(array, dtype, order): @pytest.mark.parametrize( - "func, args", + 'func, args', [ - pytest.param("full_like", + pytest.param('full_like', ['x0', '4']), - pytest.param("zeros_like", + pytest.param('zeros_like', ['x0']), - pytest.param("ones_like", + pytest.param('ones_like', ['x0']), - pytest.param("empty_like", + pytest.param('empty_like', ['x0']), ]) def test_dpctl_tensor_input(func, args): @@ -513,16 +513,16 @@ def test_dpctl_tensor_input(func, args): assert_array_equal(X, Y) -@pytest.mark.parametrize("start", +@pytest.mark.parametrize('start', [0, -5, 10, -2.5, 9.7], ids=['0', '-5', '10', '-2.5', '9.7']) -@pytest.mark.parametrize("stop", +@pytest.mark.parametrize('stop', [0, 10, -2, 20.5, 1000], ids=['0', '10', '-2', '20.5', '1000']) -@pytest.mark.parametrize("num", +@pytest.mark.parametrize('num', [5, numpy.array(10), dpnp.array(17), dpt.asarray(100)], ids=['5', 'numpy.array(10)', 'dpnp.array(17)', 'dpt.asarray(100)']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_float16=False)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_float16=False)) def test_linspace(start, stop, num, dtype): func = lambda xp: xp.linspace(start, stop, num, dtype=dtype) @@ -532,10 +532,10 @@ def test_linspace(start, stop, num, dtype): assert_allclose(func(numpy), func(dpnp), atol=numpy.finfo(dtype).eps) -@pytest.mark.parametrize("start_dtype", +@pytest.mark.parametrize('start_dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("stop_dtype", +@pytest.mark.parametrize('stop_dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) def test_linspace_dtype(start_dtype, stop_dtype): @@ -544,9 +544,9 @@ def test_linspace_dtype(start_dtype, stop_dtype): dpnp.linspace(start, stop, 10) -@pytest.mark.parametrize("start", +@pytest.mark.parametrize('start', [dpnp.array(1), dpnp.array([2.6]), numpy.array([[-6.7, 3]]), [1, -4], (3, 5)]) -@pytest.mark.parametrize("stop", +@pytest.mark.parametrize('stop', [dpnp.array([-4]), dpnp.array([[2.6], [- 4]]), numpy.array(2), [[-4.6]], (3,)]) def test_linspace_arrays(start, stop): func = lambda xp: xp.linspace(start, stop, 10) @@ -558,13 +558,13 @@ def test_linspace_complex(): assert_allclose(func(numpy), func(dpnp)) -@pytest.mark.parametrize("arrays", +@pytest.mark.parametrize('arrays', [[], [[1]], [[1, 2, 3], [4, 5, 6]], [[1, 2], [3, 4], [5, 6]]], ids=['[]', '[[1]]', '[[1, 2, 3], [4, 5, 6]]', '[[1, 2], [3, 4], [5, 6]]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False)) -@pytest.mark.parametrize("indexing", - ["ij", "xy"], - ids=["ij", "xy"]) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False)) +@pytest.mark.parametrize('indexing', + ['ij', 'xy'], + ids=['ij', 'xy']) def test_meshgrid(arrays, dtype, indexing): func = lambda xp, xi: xp.meshgrid(*xi, indexing=indexing) a = tuple(numpy.array(array, dtype=dtype) for array in arrays) diff --git a/tests/test_arraymanipulation.py b/tests/test_arraymanipulation.py index 6a2b452917b..4da695bd3fc 100644 --- a/tests/test_arraymanipulation.py +++ b/tests/test_arraymanipulation.py @@ -14,10 +14,10 @@ ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes()) @pytest.mark.parametrize( - "data", [[1, 2, 3], [1.0, 2.0, 3.0]], ids=["[1, 2, 3]", "[1., 2., 3.]"] + 'data', [[1, 2, 3], [1.0, 2.0, 3.0]], ids=['[1, 2, 3]', '[1., 2., 3.]'] ) def test_asfarray(dtype, data): expected = numpy.asfarray(data, dtype) @@ -26,9 +26,9 @@ def test_asfarray(dtype, data): assert_array_equal(result, expected) -@pytest.mark.parametrize("dtype", get_all_dtypes()) -@pytest.mark.parametrize("data", [[1.0, 2.0, 3.0]], ids=["[1., 2., 3.]"]) -@pytest.mark.parametrize("data_dtype", get_all_dtypes(no_none=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes()) +@pytest.mark.parametrize('data', [[1.0, 2.0, 3.0]], ids=['[1., 2., 3.]']) +@pytest.mark.parametrize('data_dtype', get_all_dtypes(no_none=True)) def test_asfarray2(dtype, data, data_dtype): expected = numpy.asfarray(numpy.array(data, dtype=data_dtype), dtype) result = dpnp.asfarray(dpnp.array(data, dtype=data_dtype), dtype) @@ -37,8 +37,8 @@ def test_asfarray2(dtype, data, data_dtype): class TestDims: - @pytest.mark.parametrize("dt", get_all_dtypes()) - @pytest.mark.parametrize("sh", + @pytest.mark.parametrize('dt', get_all_dtypes()) + @pytest.mark.parametrize('sh', [(0,), (1,), (3,)], ids=['(0,)', '(1,)', '(3,)']) def test_broadcast_array(self, sh, dt): @@ -48,8 +48,8 @@ def test_broadcast_array(self, sh, dt): assert_allclose(func(numpy, np_a), func(dpnp, dp_a)) - @pytest.mark.parametrize("dt", get_all_dtypes()) - @pytest.mark.parametrize("sh", + @pytest.mark.parametrize('dt', get_all_dtypes()) + @pytest.mark.parametrize('sh', [(1,), (2,), (1, 2, 3)], ids=['(1,)', '(2,)', '(1, 2, 3)']) def test_broadcast_ones(self, sh, dt): @@ -59,8 +59,8 @@ def test_broadcast_ones(self, sh, dt): assert_allclose(func(numpy, np_a), func(dpnp, dp_a)) - @pytest.mark.parametrize("dt", get_all_dtypes(no_bool=True)) - @pytest.mark.parametrize("sh", + @pytest.mark.parametrize('dt', get_all_dtypes(no_bool=True)) + @pytest.mark.parametrize('sh', [(3,), (1, 3), (2, 3)], ids=['(3,)', '(1, 3)', '(2, 3)']) def test_broadcast_arange(self, sh, dt): @@ -70,13 +70,13 @@ def test_broadcast_arange(self, sh, dt): assert_allclose(func(numpy, np_a), func(dpnp, dp_a)) - @pytest.mark.parametrize("dt", get_all_dtypes()) + @pytest.mark.parametrize('dt', get_all_dtypes()) @pytest.mark.parametrize( - "sh1, sh2", + 'sh1, sh2', [ - pytest.param([0], [0], id="(0)"), - pytest.param([1], [1], id="(1)"), - pytest.param([1], [2], id="(2)"), + pytest.param([0], [0], id='(0)'), + pytest.param([1], [1], id='(1)'), + pytest.param([1], [2], id='(2)'), ], ) def test_broadcast_not_tuple(self, sh1, sh2, dt): @@ -86,13 +86,13 @@ def test_broadcast_not_tuple(self, sh1, sh2, dt): assert_allclose(func(numpy, np_a), func(dpnp, dp_a)) - @pytest.mark.parametrize("dt", get_all_dtypes()) + @pytest.mark.parametrize('dt', get_all_dtypes()) @pytest.mark.parametrize( - "sh1, sh2", + 'sh1, sh2', [ - pytest.param([1], (0,), id="(0,)"), - pytest.param((1, 2), (0, 2), id="(0, 2)"), - pytest.param((2, 1), (2, 0), id="(2, 0)"), + pytest.param([1], (0,), id='(0,)'), + pytest.param((1, 2), (0, 2), id='(0, 2)'), + pytest.param((2, 1), (2, 0), id='(2, 0)'), ], ) def test_broadcast_zero_shape(self, sh1, sh2, dt): @@ -103,19 +103,19 @@ def test_broadcast_zero_shape(self, sh1, sh2, dt): assert_allclose(func(numpy, np_a), func(dpnp, dp_a)) @pytest.mark.parametrize( - "sh1, sh2", + 'sh1, sh2', [ - pytest.param((0,), (), id="(0,)-()"), - pytest.param((1,), (), id="(1,)-()"), - pytest.param((3,), (), id="(3,)-()"), - pytest.param((3,), (1,), id="(3,)-(1,)"), - pytest.param((3,), (2,), id="(3,)-(2,)"), - pytest.param((3,), (4,), id="(3,)-(4,)"), - pytest.param((1, 2), (2, 1), id="(1, 2)-(2, 1)"), - pytest.param((1, 2), (1,), id="(1, 2)-(1,)"), - pytest.param((1,), -1, id="(1,)--1"), - pytest.param((1,), (-1,), id="(1,)-(-1,)"), - pytest.param((1, 2), (-1, 2), id="(1, 2)-(-1, 2)"), + pytest.param((0,), (), id='(0,)-()'), + pytest.param((1,), (), id='(1,)-()'), + pytest.param((3,), (), id='(3,)-()'), + pytest.param((3,), (1,), id='(3,)-(1,)'), + pytest.param((3,), (2,), id='(3,)-(2,)'), + pytest.param((3,), (4,), id='(3,)-(4,)'), + pytest.param((1, 2), (2, 1), id='(1, 2)-(2, 1)'), + pytest.param((1, 2), (1,), id='(1, 2)-(1,)'), + pytest.param((1,), -1, id='(1,)--1'), + pytest.param((1,), (-1,), id='(1,)-(-1,)'), + pytest.param((1, 2), (-1, 2), id='(1, 2)-(-1, 2)'), ], ) def test_broadcast_raise(self, sh1, sh2): @@ -128,7 +128,7 @@ def test_broadcast_raise(self, sh1, sh2): func(dpnp, dp_a) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestConcatenate: def test_returns_copy(self): a = dpnp.array(numpy.eye(3)) @@ -192,11 +192,11 @@ class TestHstack: def test_non_iterable(self): assert_raises(TypeError, dpnp.hstack, 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_empty_input(self): assert_raises(ValueError, dpnp.hstack, ()) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_0D_array(self): b = dpnp.array(2) a = dpnp.array(1) @@ -204,7 +204,7 @@ def test_0D_array(self): desired = dpnp.array([1, 2]) assert_array_equal(res, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_1D_array(self): a = dpnp.array([1]) b = dpnp.array([2]) @@ -212,7 +212,7 @@ def test_1D_array(self): desired = dpnp.array([1, 2]) assert_array_equal(res, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_2D_array(self): a = dpnp.array([[1], [2]]) b = dpnp.array([[1], [2]]) @@ -231,11 +231,11 @@ class TestVstack: def test_non_iterable(self): assert_raises(TypeError, dpnp.vstack, 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_empty_input(self): assert_raises(ValueError, dpnp.vstack, ()) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_0D_array(self): a = dpnp.array(1) b = dpnp.array(2) @@ -243,7 +243,7 @@ def test_0D_array(self): desired = dpnp.array([[1], [2]]) assert_array_equal(res, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_1D_array(self): a = dpnp.array([1]) b = dpnp.array([2]) @@ -251,7 +251,7 @@ def test_1D_array(self): desired = dpnp.array([[1], [2]]) assert_array_equal(res, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_2D_array(self): a = dpnp.array([[1], [2]]) b = dpnp.array([[1], [2]]) @@ -259,7 +259,7 @@ def test_2D_array(self): desired = dpnp.array([[1], [2], [1], [2]]) assert_array_equal(res, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_2D_array2(self): a = dpnp.array([1, 2]) b = dpnp.array([1, 2]) diff --git a/tests/test_bitwise.py b/tests/test_bitwise.py index 34f7f971c86..d7fa310a33d 100644 --- a/tests/test_bitwise.py +++ b/tests/test_bitwise.py @@ -8,9 +8,9 @@ ) -@pytest.mark.parametrize("lhs", [[[-7, -6, -5, -4, -3, -2, -1], [0, 1, 2, 3, 4, 5, 6]], [-3, -2, -1, 0, 1, 2, 3], 0]) -@pytest.mark.parametrize("rhs", [[[0, 1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12, 13]], [0, 1, 2, 3, 4, 5, 6], 3]) -@pytest.mark.parametrize("dtype", [inp.bool, inp.int32, inp.int64]) +@pytest.mark.parametrize('lhs', [[[-7, -6, -5, -4, -3, -2, -1], [0, 1, 2, 3, 4, 5, 6]], [-3, -2, -1, 0, 1, 2, 3], 0]) +@pytest.mark.parametrize('rhs', [[[0, 1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12, 13]], [0, 1, 2, 3, 4, 5, 6], 3]) +@pytest.mark.parametrize('dtype', [inp.bool, inp.int32, inp.int64]) class TestBitwise: @staticmethod diff --git a/tests/test_counting.py b/tests/test_counting.py index 919702a4cc1..61dd793ec04 100644 --- a/tests/test_counting.py +++ b/tests/test_counting.py @@ -5,10 +5,10 @@ import numpy -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("size", +@pytest.mark.parametrize('size', [2, 4, 8, 16, 3, 9, 27, 81]) def test_count_nonzero(type, size): a = numpy.arange(size, dtype=type) diff --git a/tests/test_dot.py b/tests/test_dot.py index b9cb5659973..15d9f3d2ba8 100644 --- a/tests/test_dot.py +++ b/tests/test_dot.py @@ -10,7 +10,7 @@ ) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) def test_dot_ones(type): n = 10**5 a = numpy.ones(n, dtype=type) @@ -23,7 +23,7 @@ def test_dot_ones(type): assert_array_equal(expected, result) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) def test_dot_arange(type): n = 10**2 m = 10**3 @@ -37,7 +37,7 @@ def test_dot_arange(type): assert_allclose(expected, result) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) def test_multi_dot(type): n = 16 a = inp.reshape(inp.arange(n, dtype=type), (4, 4)) diff --git a/tests/test_dparray.py b/tests/test_dparray.py index 028d1201c0b..16ca0432b67 100644 --- a/tests/test_dparray.py +++ b/tests/test_dparray.py @@ -10,9 +10,9 @@ ) -@pytest.mark.parametrize("res_dtype", get_all_dtypes()) -@pytest.mark.parametrize("arr_dtype", get_all_dtypes()) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('res_dtype', get_all_dtypes()) +@pytest.mark.parametrize('arr_dtype', get_all_dtypes()) +@pytest.mark.parametrize('arr', [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], ids=['[-2, -1, 0, 1, 2]', '[[-2, -1], [1, 2]]', '[]']) def test_astype(arr, arr_dtype, res_dtype): @@ -23,8 +23,8 @@ def test_astype(arr, arr_dtype, res_dtype): assert_array_equal(expected, result) -@pytest.mark.parametrize("arr_dtype", get_all_dtypes()) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr_dtype', get_all_dtypes()) +@pytest.mark.parametrize('arr', [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], ids=['[-2, -1, 0, 1, 2]', '[[-2, -1], [1, 2]]', '[]']) def test_flatten(arr, arr_dtype): @@ -35,11 +35,11 @@ def test_flatten(arr, arr_dtype): assert_array_equal(expected, result) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), 0, (0,), (2), (5, 2), (5, 0, 2), (5, 3, 2)], ids=['()', '0', '(0,)', '(2)', '(5, 2)', '(5, 0, 2)', '(5, 3, 2)']) -@pytest.mark.parametrize("order", - ["C", "F"], +@pytest.mark.parametrize('order', + ['C', 'F'], ids=['C', 'F']) def test_flags(shape, order): usm_array = dpt.usm_ndarray(shape, order=order) @@ -50,14 +50,14 @@ def test_flags(shape, order): assert numpy_array.flags.f_contiguous == dpnp_array.flags.f_contiguous -@pytest.mark.parametrize("dtype", +@pytest.mark.parametrize('dtype', [numpy.complex64, numpy.float32, numpy.int64, numpy.int32, numpy.bool_], ids=['complex64', 'float32', 'int64', 'int32', 'bool']) -@pytest.mark.parametrize("strides", +@pytest.mark.parametrize('strides', [(1, 4) , (4, 1)], ids=['(1, 4)', '(4, 1)']) -@pytest.mark.parametrize("order", - ["C", "F"], +@pytest.mark.parametrize('order', + ['C', 'F'], ids=['C', 'F']) def test_flags_strides(dtype, order, strides): itemsize = numpy.dtype(dtype).itemsize @@ -71,130 +71,130 @@ def test_flags_strides(dtype, order, strides): def test_print_dpnp_int(): result = repr(dpnp.array([1, 0, 2, -3, -1, 2, 21, -9], dtype='i4')) - expected = "array([ 1, 0, 2, -3, -1, 2, 21, -9], dtype=int32)" + expected = 'array([ 1, 0, 2, -3, -1, 2, 21, -9], dtype=int32)' assert(result==expected) result = str(dpnp.array([1, 0, 2, -3, -1, 2, 21, -9], dtype='i4')) - expected = "[ 1 0 2 -3 -1 2 21 -9]" + expected = '[ 1 0 2 -3 -1 2 21 -9]' assert(result==expected) # int32 result = repr(dpnp.array([1, -1, 21], dtype=dpnp.int32)) - expected = "array([ 1, -1, 21], dtype=int32)" + expected = 'array([ 1, -1, 21], dtype=int32)' assert(result==expected) result = str(dpnp.array([1, -1, 21], dtype=dpnp.int32)) - expected = "[ 1 -1 21]" + expected = '[ 1 -1 21]' assert(result==expected) # uint8 result = repr(dpnp.array([1, 0, 3], dtype=numpy.uint8)) - expected = "array([1, 0, 3], dtype=uint8)" + expected = 'array([1, 0, 3], dtype=uint8)' assert(result==expected) result = str(dpnp.array([1, 0, 3], dtype=numpy.uint8)) - expected = "[1 0 3]" + expected = '[1 0 3]' assert(result==expected) def test_print_dpnp_float(): result = repr(dpnp.array([1, -1, 21], dtype=float)) - expected = "array([ 1., -1., 21.])" + expected = 'array([ 1., -1., 21.])' assert(result==expected) result = str(dpnp.array([1, -1, 21], dtype=float)) - expected = "[ 1. -1. 21.]" + expected = '[ 1. -1. 21.]' assert(result==expected) # float32 result = repr(dpnp.array([1, -1, 21], dtype=dpnp.float32)) - expected = "array([ 1., -1., 21.], dtype=float32)" + expected = 'array([ 1., -1., 21.], dtype=float32)' assert(result==expected) result = str(dpnp.array([1, -1, 21], dtype=dpnp.float32)) - expected = "[ 1. -1. 21.]" + expected = '[ 1. -1. 21.]' assert(result==expected) def test_print_dpnp_complex(): result = repr(dpnp.array([1, -1, 21], dtype=complex)) - expected = "array([ 1.+0.j, -1.+0.j, 21.+0.j])" + expected = 'array([ 1.+0.j, -1.+0.j, 21.+0.j])' assert(result==expected) result = str(dpnp.array([1, -1, 21], dtype=complex)) - expected = "[ 1.+0.j -1.+0.j 21.+0.j]" + expected = '[ 1.+0.j -1.+0.j 21.+0.j]' assert(result==expected) def test_print_dpnp_boolean(): result = repr(dpnp.array([1, 0, 3], dtype=bool)) - expected = "array([ True, False, True])" + expected = 'array([ True, False, True])' assert(result==expected) result = str(dpnp.array([1, 0, 3], dtype=bool)) - expected = "[ True False True]" + expected = '[ True False True]' assert(result==expected) def test_print_dpnp_special_character(): # NaN result = repr(dpnp.array([1., 0., dpnp.nan, 3.])) - expected = "array([ 1., 0., nan, 3.])" + expected = 'array([ 1., 0., nan, 3.])' assert(result==expected) result = str(dpnp.array([1., 0., dpnp.nan, 3.])) - expected = "[ 1. 0. nan 3.]" + expected = '[ 1. 0. nan 3.]' assert(result==expected) # inf result = repr(dpnp.array([1., 0., dpnp.inf, 3.])) - expected = "array([ 1., 0., inf, 3.])" + expected = 'array([ 1., 0., inf, 3.])' assert(result==expected) result = str(dpnp.array([1., 0., dpnp.inf, 3.])) - expected = "[ 1. 0. inf 3.]" + expected = '[ 1. 0. inf 3.]' assert(result==expected) def test_print_dpnp_nd(): # 1D result = repr(dpnp.arange(10000, dtype='float32')) - expected = "array([0.000e+00, 1.000e+00, 2.000e+00, ..., 9.997e+03, 9.998e+03,\n 9.999e+03], dtype=float32)" + expected = 'array([0.000e+00, 1.000e+00, 2.000e+00, ..., 9.997e+03, 9.998e+03,\n 9.999e+03], dtype=float32)' assert(result==expected) result = str(dpnp.arange(10000, dtype='float32')) - expected = "[0.000e+00 1.000e+00 2.000e+00 ... 9.997e+03 9.998e+03 9.999e+03]" + expected = '[0.000e+00 1.000e+00 2.000e+00 ... 9.997e+03 9.998e+03 9.999e+03]' assert(result==expected) # 2D result = repr(dpnp.array([[1, 2], [3, 4]], dtype=float)) - expected = "array([[1., 2.],\n [3., 4.]])" + expected = 'array([[1., 2.],\n [3., 4.]])' assert(result==expected) result = str(dpnp.array([[1, 2], [3, 4]])) - expected = "[[1 2]\n [3 4]]" + expected = '[[1 2]\n [3 4]]' assert(result==expected) # 0 shape result = repr(dpnp.empty( shape=(0, 0) )) - expected = "array([])" + expected = 'array([])' assert(result==expected) result = str(dpnp.empty( shape=(0, 0) )) - expected = "[]" + expected = '[]' assert(result==expected) -@pytest.mark.parametrize("func", [bool, float, int, complex]) -@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False, no_complex=True)) +@pytest.mark.parametrize('func', [bool, float, int, complex]) +@pytest.mark.parametrize('shape', [tuple(), (1,), (1, 1), (1, 1, 1)]) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False, no_complex=True)) def test_scalar_type_casting(func, shape, dtype): numpy_array = numpy.full(shape, 5, dtype=dtype) dpnp_array = dpnp.full(shape, 5, dtype=dtype) assert func(numpy_array) == func(dpnp_array) -@pytest.mark.parametrize("method", ["__bool__", "__float__", "__int__", "__complex__"]) -@pytest.mark.parametrize("shape", [tuple(), (1,), (1, 1), (1, 1, 1)]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False, no_complex=True, no_none=True)) +@pytest.mark.parametrize('method', ['__bool__', '__float__', '__int__', '__complex__']) +@pytest.mark.parametrize('shape', [tuple(), (1,), (1, 1), (1, 1, 1)]) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_float16=False, no_complex=True, no_none=True)) def test_scalar_type_casting_by_method(method, shape, dtype): numpy_array = numpy.full(shape, 4.7, dtype=dtype) dpnp_array = dpnp.full(shape, 4.7, dtype=dtype) assert getattr(numpy_array, method)() == getattr(dpnp_array, method)() -@pytest.mark.parametrize("shape", [(1,), (1, 1), (1, 1, 1)]) -@pytest.mark.parametrize("index_dtype", [dpnp.int32, dpnp.int64]) +@pytest.mark.parametrize('shape', [(1,), (1, 1), (1, 1, 1)]) +@pytest.mark.parametrize('index_dtype', [dpnp.int32, dpnp.int64]) def test_array_as_index(shape, index_dtype): ind_arr = dpnp.ones(shape, dtype=index_dtype) a = numpy.arange(ind_arr.size + 1) diff --git a/tests/test_fft.py b/tests/test_fft.py index f1065cc70fc..67a91245095 100644 --- a/tests/test_fft.py +++ b/tests/test_fft.py @@ -5,8 +5,8 @@ import numpy -@pytest.mark.parametrize("type", ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) -@pytest.mark.parametrize("norm", [None, 'forward', 'ortho']) +@pytest.mark.parametrize('type', ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) +@pytest.mark.parametrize('norm', [None, 'forward', 'ortho']) def test_fft(type, norm): # 1 dim array data = numpy.arange(100, dtype=numpy.dtype(type)) @@ -19,9 +19,9 @@ def test_fft(type, norm): assert dpnp_res.dtype == np_res.dtype -@pytest.mark.parametrize("type", ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) -@pytest.mark.parametrize("shape", [(8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) -@pytest.mark.parametrize("norm", [None, 'forward', 'ortho']) +@pytest.mark.parametrize('type', ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) +@pytest.mark.parametrize('shape', [(8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) +@pytest.mark.parametrize('norm', [None, 'forward', 'ortho']) def test_fft_ndim(type, shape, norm): np_data = numpy.arange(64, dtype=numpy.dtype(type)).reshape(shape) dpnp_data = dpnp.arange(64, dtype=numpy.dtype(type)).reshape(shape) @@ -33,9 +33,9 @@ def test_fft_ndim(type, shape, norm): assert dpnp_res.dtype == np_res.dtype -@pytest.mark.parametrize("type", ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) -@pytest.mark.parametrize("shape", [(64,), (8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) -@pytest.mark.parametrize("norm", [None, 'forward', 'ortho']) +@pytest.mark.parametrize('type', ['complex128', 'complex64', 'float32', 'float64', 'int32', 'int64']) +@pytest.mark.parametrize('shape', [(64,), (8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) +@pytest.mark.parametrize('norm', [None, 'forward', 'ortho']) def test_fft_ifft(type, shape, norm): np_data = numpy.arange(64, dtype=numpy.dtype(type)).reshape(shape) dpnp_data = dpnp.arange(64, dtype=numpy.dtype(type)).reshape(shape) @@ -47,8 +47,8 @@ def test_fft_ifft(type, shape, norm): assert dpnp_res.dtype == np_res.dtype -@pytest.mark.parametrize("type", ['float32', 'float64', 'int32', 'int64']) -@pytest.mark.parametrize("shape", [(64, ), (8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) +@pytest.mark.parametrize('type', ['float32', 'float64', 'int32', 'int64']) +@pytest.mark.parametrize('shape', [(64, ), (8, 8), (4, 16), (4, 4, 4), (2, 4, 4, 2)]) def test_fft_rfft(type, shape): np_data = numpy.arange(64, dtype=numpy.dtype(type)).reshape(shape) dpnp_data = dpnp.arange(64, dtype=numpy.dtype(type)).reshape(shape) diff --git a/tests/test_flat.py b/tests/test_flat.py index c5152559e40..12a28842308 100644 --- a/tests/test_flat.py +++ b/tests/test_flat.py @@ -5,7 +5,7 @@ import numpy -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.int64], ids=['int64']) def test_flat(type): @@ -17,7 +17,7 @@ def test_flat(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.int64], ids=['int64']) def test_flat2(type): @@ -29,7 +29,7 @@ def test_flat2(type): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.int64], ids=['int64']) def test_flat3(type): diff --git a/tests/test_histograms.py b/tests/test_histograms.py index b95b1712408..a2259a053a7 100644 --- a/tests/test_histograms.py +++ b/tests/test_histograms.py @@ -13,7 +13,7 @@ def setup(self): def teardown(self): pass - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_simple(self): n = 100 v = dpnp.random.rand(n) @@ -25,7 +25,7 @@ def test_simple(self): (a, b) = dpnp.histogram(numpy.linspace(0, 10, 100)) numpy.testing.assert_array_equal(a, 10) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_one_bin(self): # Ticket 632 hist, edges = dpnp.histogram([1, 2, 3, 4], [1, 2]) @@ -69,9 +69,9 @@ def test_density(self): numpy.testing.assert_equal(counts, [.25, 0]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_arr_weights_mismatch(self): a = dpnp.arange(10) + .5 w = dpnp.arange(11) + .5 - with numpy.testing.assert_raises_regex(ValueError, "same shape as"): + with numpy.testing.assert_raises_regex(ValueError, 'same shape as'): h, b = dpnp.histogram(a, range=[1, 9], weights=w, density=True) diff --git a/tests/test_indexing.py b/tests/test_indexing.py index 022d42ca1b0..0bc958463bb 100644 --- a/tests/test_indexing.py +++ b/tests/test_indexing.py @@ -70,7 +70,7 @@ def test_indexing_array_negative_strides(self): assert_array_equal(arr, 10.) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_choose(): a = numpy.r_[:4] ia = dpnp.array(a) @@ -84,10 +84,10 @@ def test_choose(): assert_array_equal(expected, result) -@pytest.mark.parametrize("offset", +@pytest.mark.parametrize('offset', [0, 1], ids=['0', '1']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -115,8 +115,8 @@ def test_diagonal(array, offset): assert_array_equal(expected, result) -@pytest.mark.parametrize("arr_dtype", get_all_dtypes()) -@pytest.mark.parametrize("cond_dtype", get_all_dtypes()) +@pytest.mark.parametrize('arr_dtype', get_all_dtypes()) +@pytest.mark.parametrize('cond_dtype', get_all_dtypes()) def test_extract_1d(arr_dtype, cond_dtype): a = numpy.array([-2, -1, 0, 1, 2, 3], dtype=arr_dtype) ia = dpnp.array(a) @@ -127,10 +127,10 @@ def test_extract_1d(arr_dtype, cond_dtype): assert_array_equal(expected, result) -@pytest.mark.parametrize("val", +@pytest.mark.parametrize('val', [-1, 0, 1], ids=['-1', '0', '1']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -151,7 +151,7 @@ def test_fill_diagonal(array, val): assert_array_equal(expected, result) -@pytest.mark.parametrize("dimension", +@pytest.mark.parametrize('dimension', [(1, ), (2, ), (1, 2), (2, 3), (3, 2), [1], [2], [1, 2], [2, 3], [3, 2]], ids=['(1, )', '(2, )', '(1, 2)', '(2, 3)', '(3, 2)', '[1]', '[2]', '[1, 2]', '[2, 3]', '[3, 2]']) @@ -161,7 +161,7 @@ def test_indices(dimension): assert_array_equal(expected, result) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[], [[0, 0], [0, 0]], [[1, 0], [1, 0]], @@ -187,19 +187,19 @@ def test_nonzero(array): assert_array_equal(expected, result) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200], (100, 200)], ids=['[100, 200]', '(100, 200)']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]], ids=['[[True, False], [False, True]]', '[[False, True], [True, False]]', '[[False, False], [True, True]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]]], @@ -217,17 +217,17 @@ def test_place1(arr, mask, vals): assert_array_equal(a, ia) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200], [100, 200, 300, 400, 500, 600], [100, 200, 300, 400, 500, 600, 800, 900]], ids=['[100, 200]', '[100, 200, 300, 400, 500, 600]', '[100, 200, 300, 400, 500, 600, 800, 900]']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]]], ids=['[[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]]], ids=['[[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]]']) def test_place2(arr, mask, vals): @@ -241,18 +241,18 @@ def test_place2(arr, mask, vals): assert_array_equal(a, ia) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200], [100, 200, 300, 400, 500, 600], [100, 200, 300, 400, 500, 600, 800, 900]], ids=['[100, 200]', '[100, 200, 300, 400, 500, 600]', '[100, 200, 300, 400, 500, 600, 800, 900]']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[[[False, False], [True, True]], [[True, True], [True, True]]], [ [[False, False], [True, True]], [[False, False], [False, False]]]]], ids=['[[[[False, False], [True, True]], [[True, True], [True, True]]], [[[False, False], [True, True]], [[False, False], [False, False]]]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[[[1, 2], [3, 4]], [[1, 2], [2, 1]]], [[[1, 3], [3, 1]], [[0, 1], [1, 3]]]]], ids=['[[[[1, 2], [3, 4]], [[1, 2], [2, 1]]], [[[1, 3], [3, 1]], [[0, 1], [1, 3]]]]']) def test_place3(arr, mask, vals): @@ -266,13 +266,13 @@ def test_place3(arr, mask, vals): assert_array_equal(a, ia) -@pytest.mark.parametrize("v", +@pytest.mark.parametrize('v', [0, 1, 2, 3, 4], ids=['0', '1', '2', '3', '4']) -@pytest.mark.parametrize("ind", +@pytest.mark.parametrize('ind', [0, 1, 2, 3], ids=['0', '1', '2', '3']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -291,13 +291,13 @@ def test_put(array, ind, v): assert_array_equal(a, ia) -@pytest.mark.parametrize("v", +@pytest.mark.parametrize('v', [[10, 20], [30, 40]], ids=['[10, 20]', '[30, 40]']) -@pytest.mark.parametrize("ind", +@pytest.mark.parametrize('ind', [[0, 1], [2, 3]], ids=['[0, 1]', '[2, 3]']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -324,7 +324,7 @@ def test_put3(): assert_array_equal(a, ia) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_put_along_axis_val_int(): a = numpy.arange(16).reshape(4, 4) ai = dpnp.array(a) @@ -336,7 +336,7 @@ def test_put_along_axis_val_int(): assert_array_equal(a, ai) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_put_along_axis1(): a = numpy.arange(64).reshape(4, 4, 4) ai = dpnp.array(a) @@ -348,7 +348,7 @@ def test_put_along_axis1(): assert_array_equal(a, ai) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_put_along_axis2(): a = numpy.arange(64).reshape(4, 4, 4) ai = dpnp.array(a) @@ -360,17 +360,17 @@ def test_put_along_axis2(): assert_array_equal(a, ai) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200]], ids=['[100, 200]']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]], ids=['[[True, False], [False, True]]', '[[False, True], [True, False]]', '[[False, False], [True, True]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]]], @@ -389,17 +389,17 @@ def test_putmask1(arr, mask, vals): assert_array_equal(a, ia) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200], [100, 200, 300, 400, 500, 600], [100, 200, 300, 400, 500, 600, 800, 900]], ids=['[100, 200]', '[100, 200, 300, 400, 500, 600]', '[100, 200, 300, 400, 500, 600, 800, 900]']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]]], ids=['[[[True, False], [False, True]], [[False, True], [True, False]], [[False, False], [True, True]]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]]], ids=['[[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]]']) def test_putmask2(arr, mask, vals): @@ -414,18 +414,18 @@ def test_putmask2(arr, mask, vals): assert_array_equal(a, ia) -@pytest.mark.parametrize("vals", +@pytest.mark.parametrize('vals', [[100, 200], [100, 200, 300, 400, 500, 600], [100, 200, 300, 400, 500, 600, 800, 900]], ids=['[100, 200]', '[100, 200, 300, 400, 500, 600]', '[100, 200, 300, 400, 500, 600, 800, 900]']) -@pytest.mark.parametrize("mask", +@pytest.mark.parametrize('mask', [[[[[False, False], [True, True]], [[True, True], [True, True]]], [ [[False, False], [True, True]], [[False, False], [False, False]]]]], ids=['[[[[False, False], [True, True]], [[True, True], [True, True]]], [[[False, False], [True, True]], [[False, False], [False, False]]]]']) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[[[1, 2], [3, 4]], [[1, 2], [2, 1]]], [[[1, 3], [3, 1]], [[0, 1], [1, 3]]]]], ids=['[[[[1, 2], [3, 4]], [[1, 2], [2, 1]]], [[[1, 3], [3, 1]], [[0, 1], [1, 3]]]]']) def test_putmask3(arr, mask, vals): @@ -458,20 +458,20 @@ def test_select(): assert_array_equal(expected, result) -@pytest.mark.parametrize("array_type", +@pytest.mark.parametrize('array_type', [numpy.bool8, numpy.int32, numpy.int64, numpy.float32, numpy.float64, numpy.complex128], ids=['bool8', 'int32', 'int64', 'float32', 'float64', 'complex128']) -@pytest.mark.parametrize("indices_type", +@pytest.mark.parametrize('indices_type', [numpy.int32, numpy.int64], ids=['int32', 'int64']) -@pytest.mark.parametrize("indices", +@pytest.mark.parametrize('indices', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]]], ids=['[[0, 0], [0, 0]]', '[[1, 2], [1, 2]]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 1, 2], [3, 4, 5], [6, 7, 8]], [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]], [[[1, 2], [3, 4]], [[1, 2], [2, 1]], [[1, 3], [3, 1]]], @@ -517,13 +517,13 @@ def test_take_along_axis1(): assert_array_equal(expected, result) -@pytest.mark.parametrize("m", +@pytest.mark.parametrize('m', [None, 0, 1, 2, 3, 4], ids=['None', '0', '1', '2', '3', '4']) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [0, 1, 2, 3, 4, 5], ids=['0', '1', '2', '3', '4', '5']) -@pytest.mark.parametrize("n", +@pytest.mark.parametrize('n', [1, 2, 3, 4, 5, 6], ids=['1', '2', '3', '4', '5', '6']) def test_tril_indices(n, k, m): @@ -532,10 +532,10 @@ def test_tril_indices(n, k, m): assert_array_equal(expected, result) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [0, 1, 2, 3, 4, 5], ids=['0', '1', '2', '3', '4', '5']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], ], @@ -550,13 +550,13 @@ def test_tril_indices_from(array, k): assert_array_equal(expected, result) -@pytest.mark.parametrize("m", +@pytest.mark.parametrize('m', [None, 0, 1, 2, 3, 4], ids=['None', '0', '1', '2', '3', '4']) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [0, 1, 2, 3, 4, 5], ids=['0', '1', '2', '3', '4', '5']) -@pytest.mark.parametrize("n", +@pytest.mark.parametrize('n', [1, 2, 3, 4, 5, 6], ids=['1', '2', '3', '4', '5', '6']) def test_triu_indices(n, k, m): @@ -565,10 +565,10 @@ def test_triu_indices(n, k, m): assert_array_equal(expected, result) -@pytest.mark.parametrize("k", +@pytest.mark.parametrize('k', [0, 1, 2, 3, 4, 5], ids=['0', '1', '2', '3', '4', '5']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], ], @@ -583,8 +583,8 @@ def test_triu_indices_from(array, k): assert_array_equal(expected, result) -@pytest.mark.parametrize("cond_dtype", get_all_dtypes()) -@pytest.mark.parametrize("scalar_dtype", get_all_dtypes(no_none=True)) +@pytest.mark.parametrize('cond_dtype', get_all_dtypes()) +@pytest.mark.parametrize('scalar_dtype', get_all_dtypes(no_none=True)) def test_where_with_scalars(cond_dtype, scalar_dtype): a = numpy.array([-1, 0, 1, 0], dtype=cond_dtype) ia = dpnp.array(a) diff --git a/tests/test_linalg.py b/tests/test_linalg.py index d90ac8bf9c6..43662920e00 100644 --- a/tests/test_linalg.py +++ b/tests/test_linalg.py @@ -16,13 +16,13 @@ def vvsort(val, vec, size, xp): - val_kwargs = dict() + val_kwargs = {} if hasattr(val, 'sycl_queue'): - val_kwargs['sycl_queue'] = getattr(val, "sycl_queue", None) + val_kwargs['sycl_queue'] = getattr(val, 'sycl_queue', None) - vec_kwargs = dict() + vec_kwargs = {} if hasattr(vec, 'sycl_queue'): - vec_kwargs['sycl_queue'] = getattr(vec, "sycl_queue", None) + vec_kwargs['sycl_queue'] = getattr(vec, 'sycl_queue', None) for i in range(size): imax = i @@ -46,7 +46,7 @@ def vvsort(val, vec, size, xp): vec[:, imax] = temp -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[[1, -2], [2, 5]]], [[[1., -2.], [2., 5.]]], [[[1., -2.], [2., 5.]], [[1., -2.], [2., 5.]]]], @@ -61,10 +61,10 @@ def test_cholesky(array): assert_array_equal(expected, result) -@pytest.mark.parametrize("arr", +@pytest.mark.parametrize('arr', [[[1, 0, -1], [0, 1, 0], [1, 0, 1]], [[1, 2, 3], [4, 5, 6], [7, 8, 9]]], ids=['[[1, 0, -1], [0, 1, 0], [1, 0, 1]]', '[[1, 2, 3], [4, 5, 6], [7, 8, 9]]']) -@pytest.mark.parametrize("p", +@pytest.mark.parametrize('p', [None, 1, -1, 2, -2, numpy.inf, -numpy.inf, 'fro'], ids=['None', '1', '-1', '2', '-2', 'numpy.inf', '-numpy.inf', '"fro"']) def test_cond(arr, p): @@ -75,7 +75,7 @@ def test_cond(arr, p): assert_array_equal(expected, result) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -94,9 +94,9 @@ def test_det(array): assert_allclose(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("size", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('size', [2, 4, 8, 16, 300]) def test_eig_arange(type, size): if dpctl.get_current_device_type() != dpctl.device_type.gpu: @@ -136,9 +136,9 @@ def test_eig_arange(type, size): assert_allclose(dpnp_vec, np_vec, rtol=1e-05, atol=1e-05) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_none=True)) -@pytest.mark.parametrize("size", [2, 4, 8]) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_none=True)) +@pytest.mark.parametrize('size', [2, 4, 8]) def test_eigh_arange(type, size): a = numpy.arange(size * size, dtype=type).reshape((size, size)) symm_orig = numpy.tril(a) + numpy.tril(a, -1).T + numpy.diag(numpy.full((size,), size * size, dtype=type)) @@ -172,7 +172,7 @@ def test_eigh_arange(type, size): assert_allclose(dpnp_vec, np_vec, rtol=1e-05, atol=1e-04) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) def test_eigvals(type): if dpctl.get_current_device_type() != dpctl.device_type.gpu: pytest.skip("eigvals function doesn\'t work on CPU: https://github.com/IntelPython/dpnp/issues/1005") @@ -190,8 +190,8 @@ def test_eigvals(type): assert_allclose(expected, result, atol=0.5) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('array', [[[1., 2.], [3., 4.]], [[0, 1, 2], [3, 2, -1], [4, -2, 3]]], ids=['[[1., 2.], [3., 4.]]', '[[0, 1, 2], [3, 2, -1], [4, -2, 3]]']) def test_inv(type, array): @@ -202,11 +202,11 @@ def test_inv(type, array): assert_allclose(expected, result) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) +@pytest.mark.parametrize('array', [[0, 0], [0, 1], [1, 2], [[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]]], ids=['[0, 0]', '[0, 1]', '[1, 2]', '[[0, 0], [0, 0]]', '[[1, 2], [1, 2]]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("tol", +@pytest.mark.parametrize('tol', [None], ids=['None']) def test_matrix_rank(type, tol, array): @@ -219,15 +219,15 @@ def test_matrix_rank(type, tol, array): assert_allclose(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.usefixtures("suppress_divide_numpy_warnings") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.usefixtures('suppress_divide_numpy_warnings') +@pytest.mark.parametrize('array', [[7], [1, 2], [1, 0]], ids=['[7]', '[1, 2]', '[1, 0]']) -@pytest.mark.parametrize("ord", +@pytest.mark.parametrize('ord', [None, -numpy.Inf, -2, -1, 0, 1, 2, 3, numpy.Inf], ids=['None', '-numpy.Inf', '-2', '-1', '0', '1', '2', '3', 'numpy.Inf']) -@pytest.mark.parametrize("axis", +@pytest.mark.parametrize('axis', [0, None], ids=['0', 'None']) def test_norm1(array, ord, axis): @@ -238,14 +238,14 @@ def test_norm1(array, ord, axis): assert_allclose(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[[1, 0]], [[1, 2]], [[1, 0], [3, 0]], [[1, 2], [3, 4]]], ids=['[[1, 0]]', '[[1, 2]]', '[[1, 0], [3, 0]]', '[[1, 2], [3, 4]]']) -@pytest.mark.parametrize("ord", +@pytest.mark.parametrize('ord', [None, -numpy.Inf, -2, -1, 1, 2, numpy.Inf, 'fro', 'nuc'], ids=['None', '-numpy.Inf', '-2', '-1', '1', '2', 'numpy.Inf', '"fro"', '"nuc"']) -@pytest.mark.parametrize("axis", +@pytest.mark.parametrize('axis', [(0, 1), None], ids=['(0, 1)', 'None']) def test_norm2(array, ord, axis): @@ -256,14 +256,14 @@ def test_norm2(array, ord, axis): assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[[[1, 2], [3, 4]], [[5, 6], [7, 8]]], [[[1, 0], [3, 0]], [[5, 0], [7, 0]]]], ids=['[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]', '[[[1, 0], [3, 0]], [[5, 0], [7, 0]]]']) -@pytest.mark.parametrize("ord", +@pytest.mark.parametrize('ord', [None, -numpy.Inf, -2, -1, 1, 2, numpy.Inf], ids=['None', '-numpy.Inf', '-2', '-1', '1', '2', 'numpy.Inf']) -@pytest.mark.parametrize("axis", +@pytest.mark.parametrize('axis', [0, 1, 2, (0, 1), (0, 2), (1, 2)], ids=['0', '1', '2', '(0, 1)', '(0, 2)', '(1, 2)']) def test_norm3(array, ord, axis): @@ -274,12 +274,12 @@ def test_norm3(array, ord, axis): assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(2, 2), (3, 4), (5, 3), (16, 16)], ids=['(2,2)', '(3,4)', '(5,3)', '(16,16)']) -@pytest.mark.parametrize("mode", +@pytest.mark.parametrize('mode', ['complete', 'reduced'], ids=['complete', 'reduced']) def test_qr(type, shape, mode): @@ -316,8 +316,8 @@ def test_qr(type, shape, mode): assert_allclose(dpnp_r, np_r, rtol=tol, atol=tol) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(2, 2), (3, 4), (5, 3), (16, 16)], ids=['(2,2)', '(3,4)', '(5,3)', '(16,16)']) def test_svd(type, shape): diff --git a/tests/test_logic.py b/tests/test_logic.py index b2a545a118f..0dd935523cc 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -10,8 +10,8 @@ ) -@pytest.mark.parametrize("type", get_all_dtypes()) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('type', get_all_dtypes()) +@pytest.mark.parametrize('shape', [(0,), (4,), (2, 3), (2, 2, 2)], ids=['(0,)', '(4,)', '(2,3)', '(2,2,2)']) def test_all(type, shape): @@ -41,7 +41,7 @@ def test_all(type, shape): assert_allclose(dpnp_res, np_res) -@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('type', get_all_dtypes(no_bool=True, no_complex=True)) def test_allclose(type): a = numpy.random.rand(10) @@ -63,8 +63,8 @@ def test_allclose(type): assert_allclose(dpnp_res, np_res) -@pytest.mark.parametrize("type", get_all_dtypes()) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('type', get_all_dtypes()) +@pytest.mark.parametrize('shape', [(0,), (4,), (2, 3), (2, 2, 2)], ids=['(0,)', '(4,)', '(2,3)', '(2,2,2)']) def test_any(type, shape): @@ -148,8 +148,8 @@ def test_not_equal(): assert_equal(dpnp_res, np_res) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True)) -@pytest.mark.parametrize("op", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True)) +@pytest.mark.parametrize('op', ['logical_and', 'logical_or', 'logical_xor'], ids=['logical_and', 'logical_or', 'logical_xor']) def test_logic_comparison(op, dtype): @@ -179,7 +179,7 @@ def test_logic_comparison(op, dtype): assert_equal(dpnp_res, np_res) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True)) def test_logical_not(dtype): a = dpnp.array([0, 4, 0, 2], dtype=dtype) @@ -188,18 +188,18 @@ def test_logical_not(dtype): assert_equal(dpnp_res, np_res) -@pytest.mark.parametrize("op", +@pytest.mark.parametrize('op', ['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal'], ids=['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal']) -@pytest.mark.parametrize("x1", +@pytest.mark.parametrize('x1', [[3, 4, 5, 6], [[1, 2, 3, 4], [5, 6, 7, 8]], [[1, 2, 5, 6], [3, 4, 7, 8], [1, 2, 7, 8]]], ids=['[3, 4, 5, 6]', '[[1, 2, 3, 4], [5, 6, 7, 8]]', '[[1, 2, 5, 6], [3, 4, 7, 8], [1, 2, 7, 8]]']) -@pytest.mark.parametrize("x2", +@pytest.mark.parametrize('x2', [5, [1, 2, 5, 6]], ids=['5', '[1, 2, 5, 6]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True)) def test_elemwise_comparison(op, x1, x2, dtype): create_func = lambda xp, a: xp.asarray(a, dtype=dtype) if not numpy.isscalar(a) else numpy.dtype(dtype=dtype).type(a) @@ -222,15 +222,15 @@ def test_elemwise_comparison(op, x1, x2, dtype): assert_equal(dpnp_res, np_res) -@pytest.mark.parametrize("op", +@pytest.mark.parametrize('op', ['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal'], ids=['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal']) -@pytest.mark.parametrize("sh1", +@pytest.mark.parametrize('sh1', [[10], [8, 4], [4, 1, 2]], ids=['(10,)', '(8, 4)', '(4, 1, 2)']) -@pytest.mark.parametrize("sh2", +@pytest.mark.parametrize('sh2', [[12], [4, 8], [1, 8, 6]], ids=['(12,)', '(4, 8)', '(1, 8, 6)']) def test_comparison_no_broadcast_with_shapes(op, sh1, sh2): diff --git a/tests/test_manipulation.py b/tests/test_manipulation.py index b8ee2cfaa97..237ad51834e 100644 --- a/tests/test_manipulation.py +++ b/tests/test_manipulation.py @@ -15,7 +15,7 @@ testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in ['complex128']] -@pytest.mark.parametrize("in_obj,out_dtype", testdata) +@pytest.mark.parametrize('in_obj,out_dtype', testdata) def test_copyto_dtype(in_obj, out_dtype): ndarr = numpy.array(in_obj) expected = numpy.empty(ndarr.size, dtype=out_dtype) @@ -28,8 +28,8 @@ def test_copyto_dtype(in_obj, out_dtype): assert_array_equal(result, expected) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("arr", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('arr', [[], [1, 2, 3, 4], [[1, 2], [3, 4]], [[[1], [2]], [[3], [4]]]], ids=['[]', '[1, 2, 3, 4]', '[[1, 2], [3, 4]]', '[[[1], [2]], [[3], [4]]]']) def test_repeat(arr): @@ -41,8 +41,8 @@ def test_repeat(arr): def test_result_type(): - X = [dpnp.ones((2), dtype=dpnp.int64), dpnp.int32, "float16"] - X_np = [numpy.ones((2), dtype=numpy.int64), numpy.int32, "float16"] + X = [dpnp.ones((2), dtype=dpnp.int64), dpnp.int32, 'float16'] + X_np = [numpy.ones((2), dtype=numpy.int64), numpy.int32, 'float16'] assert dpnp.result_type(*X) == numpy.result_type(*X_np) @@ -59,8 +59,8 @@ def test_result_type_only_arrays(): assert dpnp.result_type(*X) == numpy.result_type(*X_np) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[1, 2, 3], [1, 2, 2, 1, 2, 4], [2, 2, 2, 2], @@ -79,7 +79,7 @@ def test_unique(array): class TestTranspose: - @pytest.mark.parametrize("axes", [(0, 1), (1, 0)]) + @pytest.mark.parametrize('axes', [(0, 1), (1, 0)]) def test_2d_with_axes(self, axes): na = numpy.array([[1, 2], [3, 4]]) da = dpnp.array(na) @@ -88,7 +88,7 @@ def test_2d_with_axes(self, axes): result = dpnp.transpose(da, axes) assert_array_equal(expected, result) - @pytest.mark.parametrize("axes", [(1, 0, 2), ((1, 0, 2),)]) + @pytest.mark.parametrize('axes', [(1, 0, 2), ((1, 0, 2),)]) def test_3d_with_packed_axes(self, axes): na = numpy.ones((1, 2, 3)) da = dpnp.array(na) @@ -97,7 +97,7 @@ def test_3d_with_packed_axes(self, axes): result = da.transpose(*axes) assert_array_equal(expected, result) - @pytest.mark.parametrize("shape", [(10,), (2, 4), (5, 3, 7), (3, 8, 4, 1)]) + @pytest.mark.parametrize('shape', [(10,), (2, 4), (5, 3, 7), (3, 8, 4, 1)]) def test_none_axes(self, shape): na = numpy.ones(shape) da = dpnp.ones(shape) diff --git a/tests/test_mathematical.py b/tests/test_mathematical.py index bdd4257e646..cbe74ee3139 100644 --- a/tests/test_mathematical.py +++ b/tests/test_mathematical.py @@ -18,7 +18,7 @@ ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestConvolve: def test_object(self): d = [1.] * 100 @@ -47,8 +47,8 @@ def test_mode(self): dpnp.convolve(d, k, mode=None) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -69,11 +69,11 @@ def test_diff(array): assert_allclose(expected, result) -@pytest.mark.parametrize("dtype1", get_all_dtypes()) -@pytest.mark.parametrize("dtype2", get_all_dtypes()) -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('dtype1', get_all_dtypes()) +@pytest.mark.parametrize('dtype2', get_all_dtypes()) +@pytest.mark.parametrize('func', ['add', 'divide', 'multiply', 'power', 'subtract']) -@pytest.mark.parametrize("data", +@pytest.mark.parametrize('data', [[[1, 2], [3, 4]]], ids=['[[1, 2], [3, 4]]']) def test_op_multiple_dtypes(dtype1, func, dtype2, data): @@ -93,8 +93,8 @@ def test_op_multiple_dtypes(dtype1, func, dtype2, data): assert_allclose(result, expected) -@pytest.mark.parametrize("rhs", [[[1, 2, 3], [4, 5, 6]], [2.0, 1.5, 1.0], 3, 0.3]) -@pytest.mark.parametrize("lhs", [[[6, 5, 4], [3, 2, 1]], [1.3, 2.6, 3.9]]) +@pytest.mark.parametrize('rhs', [[[1, 2, 3], [4, 5, 6]], [2.0, 1.5, 1.0], 3, 0.3]) +@pytest.mark.parametrize('lhs', [[[6, 5, 4], [3, 2, 1]], [1.3, 2.6, 3.9]]) # TODO: achieve the same level of dtype support for all mathematical operations, like # @pytest.mark.parametrize("dtype", get_all_dtypes()) # and to get rid of fallbacks on numpy allowed by below fixture @@ -124,78 +124,78 @@ def _test_mathematical(self, name, dtype, lhs, rhs): expected = getattr(numpy, name)(a_np, b_np) assert_allclose(result, expected, rtol=1e-6) - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_add(self, dtype, lhs, rhs): self._test_mathematical('add', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_arctan2(self, dtype, lhs, rhs): self._test_mathematical('arctan2', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_copysign(self, dtype, lhs, rhs): self._test_mathematical('copysign', dtype, lhs, rhs) - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_divide(self, dtype, lhs, rhs): self._test_mathematical('divide', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_fmod(self, dtype, lhs, rhs): self._test_mathematical('fmod', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_floor_divide(self, dtype, lhs, rhs): self._test_mathematical('floor_divide', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_hypot(self, dtype, lhs, rhs): self._test_mathematical('hypot', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_maximum(self, dtype, lhs, rhs): self._test_mathematical('maximum', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_minimum(self, dtype, lhs, rhs): self._test_mathematical('minimum', dtype, lhs, rhs) - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_multiply(self, dtype, lhs, rhs): self._test_mathematical('multiply', dtype, lhs, rhs) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_remainder(self, dtype, lhs, rhs): self._test_mathematical('remainder', dtype, lhs, rhs) - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_power(self, dtype, lhs, rhs): self._test_mathematical('power', dtype, lhs, rhs) - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_subtract(self, dtype, lhs, rhs): self._test_mathematical('subtract', dtype, lhs, rhs) -@pytest.mark.usefixtures("suppress_divide_invalid_numpy_warnings") -@pytest.mark.parametrize("val_type", +@pytest.mark.usefixtures('suppress_divide_invalid_numpy_warnings') +@pytest.mark.parametrize('val_type', [bool, int, float], ids=['bool', 'int', 'float']) -@pytest.mark.parametrize("data_type", get_all_dtypes()) -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('data_type', get_all_dtypes()) +@pytest.mark.parametrize('func', ['add', 'divide', 'multiply', 'power', 'subtract']) -@pytest.mark.parametrize("val", +@pytest.mark.parametrize('val', [0, 1, 5], ids=['0', '1', '5']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -213,10 +213,10 @@ def test_op_with_scalar(array, val, func, data_type, val_type): if func == 'power': if val_ == 0 and numpy.issubdtype(data_type, numpy.complexfloating): - pytest.skip("(0j ** 0) is different: (NaN + NaNj) in dpnp and (1 + 0j) in numpy") + pytest.skip('(0j ** 0) is different: (NaN + NaNj) in dpnp and (1 + 0j) in numpy') elif is_cpu_device() and data_type == dpnp.complex128: # TODO: discuss the bahavior with OneMKL team - pytest.skip("(0j ** 5) is different: (NaN + NaNj) in dpnp and (0j) in numpy") + pytest.skip('(0j ** 5) is different: (NaN + NaNj) in dpnp and (0j) in numpy') if func == 'subtract' and val_type == bool and data_type == dpnp.bool: with pytest.raises(TypeError): @@ -235,10 +235,10 @@ def test_op_with_scalar(array, val, func, data_type, val_type): assert_allclose(result, expected, rtol=1e-6) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), (3, 2)], ids=['()', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_multiply_scalar(shape, dtype): np_a = numpy.ones(shape, dtype=dtype) dpnp_a = dpnp.ones(shape, dtype=dtype) @@ -248,10 +248,10 @@ def test_multiply_scalar(shape, dtype): assert_allclose(result, expected) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), (3, 2)], ids=['()', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_add_scalar(shape, dtype): np_a = numpy.ones(shape, dtype=dtype) dpnp_a = dpnp.ones(shape, dtype=dtype) @@ -261,10 +261,10 @@ def test_add_scalar(shape, dtype): assert_allclose(result, expected) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), (3, 2)], ids=['()', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_subtract_scalar(shape, dtype): np_a = numpy.ones(shape, dtype=dtype) dpnp_a = dpnp.ones(shape, dtype=dtype) @@ -274,10 +274,10 @@ def test_subtract_scalar(shape, dtype): assert_allclose(result, expected) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), (3, 2)], ids=['()', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_divide_scalar(shape, dtype): np_a = numpy.ones(shape, dtype=dtype) dpnp_a = dpnp.ones(shape, dtype=dtype) @@ -287,10 +287,10 @@ def test_divide_scalar(shape, dtype): assert_allclose(result, expected, rtol=1e-6) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('shape', [(), (3, 2)], ids=['()', '(3, 2)']) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_power_scalar(shape, dtype): np_a = numpy.ones(shape, dtype=dtype) dpnp_a = dpnp.ones(shape, dtype=dtype) @@ -304,8 +304,8 @@ def test_power_scalar(shape, dtype): assert_allclose(result, expected, rtol=1e-6) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", [[1, 2, 3, 4, 5], +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[1, 2, 3, 4, 5], [1, 2, numpy.nan, 4, 5], [[1, 2, numpy.nan], [3, -4, -5]]]) def test_nancumprod(array): @@ -317,8 +317,8 @@ def test_nancumprod(array): assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", [[1, 2, 3, 4, 5], +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[1, 2, 3, 4, 5], [1, 2, numpy.nan, 4, 5], [[1, 2, numpy.nan], [3, -4, -5]]]) def test_nancumsum(array): @@ -330,10 +330,10 @@ def test_nancumsum(array): assert_array_equal(expected, result) -@pytest.mark.parametrize("data", +@pytest.mark.parametrize('data', [[[1., -1.], [0.1, -0.1]], [-2, -1, 0, 1, 2]], ids=['[[1., -1.], [0.1, -0.1]]', '[-2, -1, 0, 1, 2]']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_negative(data, dtype): np_a = numpy.array(data, dtype=dtype) dpnp_a = dpnp.array(data, dtype=dtype) @@ -343,12 +343,12 @@ def test_negative(data, dtype): assert_array_equal(result, expected) -@pytest.mark.parametrize("val_type", get_all_dtypes(no_none=True)) -@pytest.mark.parametrize("data_type", get_all_dtypes()) -@pytest.mark.parametrize("val", +@pytest.mark.parametrize('val_type', get_all_dtypes(no_none=True)) +@pytest.mark.parametrize('data_type', get_all_dtypes()) +@pytest.mark.parametrize('val', [1.5, 1, 5], ids=['1.5', '1', '5']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [[[0, 0], [0, 0]], [[1, 2], [1, 2]], [[1, 2], [3, 4]], @@ -366,7 +366,7 @@ def test_power(array, val, data_type, val_type): if is_cpu_device() and dpnp.complex128 in (data_type, val_type): # TODO: discuss the behavior with OneMKL team - pytest.skip("(0j ** 5) is different: (NaN + NaNj) in dpnp and (0j) in numpy") + pytest.skip('(0j ** 5) is different: (NaN + NaNj) in dpnp and (0j) in numpy') result = dpnp.power(dpnp_a, val_) expected = numpy.power(np_a, val_) @@ -374,8 +374,8 @@ def test_power(array, val, data_type, val_type): class TestEdiff1d: - @pytest.mark.parametrize("data_type", get_all_dtypes(no_bool=True, no_complex=True)) - @pytest.mark.parametrize("array", [[1, 2, 4, 7, 0], + @pytest.mark.parametrize('data_type', get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.parametrize('array', [[1, 2, 4, 7, 0], [], [1], [[1, 2, 3], [5, 2, 8], [7, 3, 4]], ]) @@ -388,7 +388,7 @@ def test_ediff1d_int(self, array, data_type): assert_array_equal(expected, result) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_ediff1d_args(self): np_a = numpy.array([1, 2, 4, 7, 0]) @@ -400,10 +400,10 @@ def test_ediff1d_args(self): assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestTrapz: - @pytest.mark.parametrize("data_type", get_all_dtypes(no_bool=True, no_complex=True)) - @pytest.mark.parametrize("array", [[1, 2, 3], + @pytest.mark.parametrize('data_type', get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.parametrize('array', [[1, 2, 3], [[1, 2, 3], [4, 5, 6]], [1, 4, 6, 9, 10, 12], [], @@ -416,11 +416,11 @@ def test_trapz_default(self, array, data_type): expected = numpy.trapz(np_a) assert_array_equal(expected, result) - @pytest.mark.parametrize("data_type_y", get_all_dtypes(no_bool=True, no_complex=True)) - @pytest.mark.parametrize("data_type_x", get_all_dtypes(no_bool=True, no_complex=True)) - @pytest.mark.parametrize("y_array", [[1, 2, 4, 5], + @pytest.mark.parametrize('data_type_y', get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.parametrize('data_type_x', get_all_dtypes(no_bool=True, no_complex=True)) + @pytest.mark.parametrize('y_array', [[1, 2, 4, 5], [1., 2.5, 6., 7.]]) - @pytest.mark.parametrize("x_array", [[2, 5, 6, 9]]) + @pytest.mark.parametrize('x_array', [[2, 5, 6, 9]]) def test_trapz_with_x_params(self, y_array, x_array, data_type_y, data_type_x): np_y = numpy.array(y_array, dtype=data_type_y) dpnp_y = dpnp.array(y_array, dtype=data_type_y) @@ -432,7 +432,7 @@ def test_trapz_with_x_params(self, y_array, x_array, data_type_y, data_type_x): expected = numpy.trapz(np_y, np_x) assert_array_equal(expected, result) - @pytest.mark.parametrize("array", [[1, 2, 3], [4, 5, 6]]) + @pytest.mark.parametrize('array', [[1, 2, 3], [4, 5, 6]]) def test_trapz_with_x_param_2ndim(self, array): np_a = numpy.array(array) dpnp_a = dpnp.array(array) @@ -441,9 +441,9 @@ def test_trapz_with_x_param_2ndim(self, array): expected = numpy.trapz(np_a, np_a) assert_array_equal(expected, result) - @pytest.mark.parametrize("y_array", [[1, 2, 4, 5], + @pytest.mark.parametrize('y_array', [[1, 2, 4, 5], [1., 2.5, 6., 7., ]]) - @pytest.mark.parametrize("dx", [2, 3, 4]) + @pytest.mark.parametrize('dx', [2, 3, 4]) def test_trapz_with_dx_params(self, y_array, dx): np_y = numpy.array(y_array) dpnp_y = dpnp.array(y_array) @@ -453,24 +453,24 @@ def test_trapz_with_dx_params(self, y_array, dx): assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestCross: - @pytest.mark.parametrize("axis", [None, 0], + @pytest.mark.parametrize('axis', [None, 0], ids=['None', '0']) - @pytest.mark.parametrize("axisc", [-1, 0], + @pytest.mark.parametrize('axisc', [-1, 0], ids=['-1', '0']) - @pytest.mark.parametrize("axisb", [-1, 0], + @pytest.mark.parametrize('axisb', [-1, 0], ids=['-1', '0']) - @pytest.mark.parametrize("axisa", [-1, 0], + @pytest.mark.parametrize('axisa', [-1, 0], ids=['-1', '0']) - @pytest.mark.parametrize("x1", [[1, 2, 3], + @pytest.mark.parametrize('x1', [[1, 2, 3], [1., 2.5, 6.], [2, 4, 6]], ids=['[1, 2, 3]', '[1., 2.5, 6.]', '[2, 4, 6]']) - @pytest.mark.parametrize("x2", [[4, 5, 6], + @pytest.mark.parametrize('x2', [[4, 5, 6], [1., 5., 2.], [6, 4, 3]], ids=['[4, 5, 6]', @@ -490,7 +490,7 @@ def test_cross_3x3(self, x1, x2, axisa, axisb, axisc, axis): class TestGradient: - @pytest.mark.parametrize("array", [[2, 3, 6, 8, 4, 9], + @pytest.mark.parametrize('array', [[2, 3, 6, 8, 4, 9], [3., 4., 7.5, 9.], [2, 6, 8, 10]]) def test_gradient_y1(self, array): @@ -501,11 +501,11 @@ def test_gradient_y1(self, array): expected = numpy.gradient(np_y) assert_array_equal(expected, result) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("array", [[2, 3, 6, 8, 4, 9], + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('array', [[2, 3, 6, 8, 4, 9], [3., 4., 7.5, 9.], [2, 6, 8, 10]]) - @pytest.mark.parametrize("dx", [2, 3.5]) + @pytest.mark.parametrize('dx', [2, 3.5]) def test_gradient_y1_dx(self, array, dx): np_y = numpy.array(array) dpnp_y = dpnp.array(array) @@ -532,7 +532,7 @@ def test_ceil(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -543,7 +543,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.ceil(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -572,7 +572,7 @@ def test_floor(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -583,7 +583,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.floor(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -612,7 +612,7 @@ def test_trunc(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -623,7 +623,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.trunc(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -636,7 +636,7 @@ def test_invalid_shape(self, shape): class TestAdd: - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_add(self, dtype): array1_data = numpy.arange(10) array2_data = numpy.arange(5, 15) @@ -656,7 +656,7 @@ def test_add(self, dtype): assert_allclose(expected, result) assert_allclose(out, dp_out) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_out_dtypes(self, dtype): size = 2 if dtype == dpnp.bool else 10 @@ -680,15 +680,15 @@ def test_out_dtypes(self, dtype): result = dpnp.add(dp_array1, dp_array2, out=dp_out) assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_out_overlap(self, dtype): size = 1 if dtype == dpnp.bool else 15 dp_a = dpnp.arange(2 * size, dtype=dtype) with pytest.raises(TypeError): dpnp.add(dp_a[size::], dp_a[::2], out=dp_a[:size:]) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_none=True)) - @pytest.mark.skip("mute unttil in-place support in dpctl is done") + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_none=True)) + @pytest.mark.skip('mute unttil in-place support in dpctl is done') def test_inplace_strided_out(self, dtype): size = 21 @@ -700,7 +700,7 @@ def test_inplace_strided_out(self, dtype): assert_allclose(dp_a, np_a) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -711,7 +711,7 @@ def test_invalid_shape(self, shape): with pytest.raises(TypeError): dpnp.add(dp_array1, dp_array2, out=dp_out) - @pytest.mark.parametrize("out", + @pytest.mark.parametrize('out', [4, (), [], (3, 7), [2, 4]], ids=['4', '()', '[]', '(3, 7)', '[2, 4]']) def test_invalid_out(self, out): @@ -722,7 +722,7 @@ def test_invalid_out(self, out): class TestMultiply: - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_multiply(self, dtype): array1_data = numpy.arange(10) array2_data = numpy.arange(5, 15) @@ -742,7 +742,7 @@ def test_multiply(self, dtype): assert_allclose(expected, result) assert_allclose(out, dp_out) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_out_dtypes(self, dtype): size = 2 if dtype == dpnp.bool else 10 @@ -766,15 +766,15 @@ def test_out_dtypes(self, dtype): result = dpnp.multiply(dp_array1, dp_array2, out=dp_out) assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) def test_out_overlap(self, dtype): size = 1 if dtype == dpnp.bool else 15 dp_a = dpnp.arange(2 * size, dtype=dtype) with pytest.raises(TypeError): dpnp.multiply(dp_a[size::], dp_a[::2], out=dp_a[:size:]) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_none=True)) - @pytest.mark.skip("mute unttil in-place support in dpctl is done") + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_none=True)) + @pytest.mark.skip('mute unttil in-place support in dpctl is done') def test_inplace_strided_out(self, dtype): size = 21 @@ -786,7 +786,7 @@ def test_inplace_strided_out(self, dtype): assert_allclose(dp_a, np_a) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -797,7 +797,7 @@ def test_invalid_shape(self, shape): with pytest.raises(TypeError): dpnp.multiply(dp_array1, dp_array2, out=dp_out) - @pytest.mark.parametrize("out", + @pytest.mark.parametrize('out', [4, (), [], (3, 7), [2, 4]], ids=['4', '()', '[]', '(3, 7)', '[2, 4]']) def test_invalid_out(self, out): @@ -808,7 +808,7 @@ def test_invalid_out(self, out): class TestPower: - @pytest.mark.parametrize("dtype", get_float_complex_dtypes()) + @pytest.mark.parametrize('dtype', get_float_complex_dtypes()) def test_power(self, dtype): array1_data = numpy.arange(10) array2_data = numpy.arange(5, 15) @@ -827,7 +827,7 @@ def test_power(self, dtype): assert_allclose(expected, result) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True, no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True, no_none=True)) def test_out_dtypes(self, dtype): size = 2 if dtype == dpnp.bool else 5 @@ -843,7 +843,7 @@ def test_out_dtypes(self, dtype): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) def test_out_overlap(self, dtype): size = 5 @@ -856,7 +856,7 @@ def test_out_overlap(self, dtype): assert_allclose(expected, result) assert_allclose(dp_a, np_a) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) def test_inplace_strided_out(self, dtype): size = 5 @@ -868,7 +868,7 @@ def test_inplace_strided_out(self, dtype): assert_allclose(dp_a, np_a) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -879,7 +879,7 @@ def test_invalid_shape(self, shape): with pytest.raises(ValueError): dpnp.power(dp_array1, dp_array2, out=dp_out) - @pytest.mark.parametrize("out", + @pytest.mark.parametrize('out', [4, (), [], (3, 7), [2, 4]], ids=['4', '()', '[]', '(3, 7)', '[2, 4]']) def test_invalid_out(self, out): @@ -888,7 +888,7 @@ def test_invalid_out(self, out): assert_raises(TypeError, dpnp.power, a, 2, out) assert_raises(TypeError, numpy.power, a.asnumpy(), 2, out) - @pytest.mark.usefixtures("suppress_invalid_numpy_warnings") + @pytest.mark.usefixtures('suppress_invalid_numpy_warnings') def test_complex_values(self): np_arr = numpy.array([0j, 1+1j, 0+2j, 1+2j, numpy.nan, numpy.inf]) dp_arr = dpnp.array(np_arr) @@ -902,8 +902,8 @@ def test_complex_values(self): assert_equal(func(dp_arr)[5], (numpy.inf + 0j) * 1) assert_allclose(func(np_arr)[:5], func(dp_arr).asnumpy()[:5], rtol=1e-6) - @pytest.mark.parametrize("val", [0, 1], ids=['0', '1']) - @pytest.mark.parametrize("dtype", [dpnp.int32, dpnp.int64]) + @pytest.mark.parametrize('val', [0, 1], ids=['0', '1']) + @pytest.mark.parametrize('dtype', [dpnp.int32, dpnp.int64]) def test_integer_power_of_0_or_1(self, val, dtype): np_arr = numpy.arange(10, dtype=dtype) dp_arr = dpnp.array(np_arr) @@ -911,7 +911,7 @@ def test_integer_power_of_0_or_1(self, val, dtype): assert_equal(func(np_arr), func(dp_arr)) - @pytest.mark.parametrize("dtype", [dpnp.int32, dpnp.int64]) + @pytest.mark.parametrize('dtype', [dpnp.int32, dpnp.int64]) def test_integer_to_negative_power(self, dtype): ones = dpnp.ones(10, dtype=dtype) a = dpnp.arange(2, 10, dtype=dtype) @@ -931,8 +931,8 @@ def test_float_to_inf(self): assert_allclose(numpy_res, dpnp_res.asnumpy()) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True, no_bool=True)) -@pytest.mark.parametrize("axis", [None, 0, 1, 2, 3]) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True, no_bool=True)) +@pytest.mark.parametrize('axis', [None, 0, 1, 2, 3]) def test_sum_empty(dtype, axis): a = numpy.empty((1, 2, 0, 4), dtype=dtype) numpy_res = a.sum(axis=axis) @@ -940,8 +940,8 @@ def test_sum_empty(dtype, axis): assert_array_equal(numpy_res, dpnp_res.asnumpy()) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("dtype", get_all_dtypes(no_complex=True, no_bool=True)) +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('dtype', get_all_dtypes(no_complex=True, no_bool=True)) def test_sum_empty_out(dtype): a = dpnp.empty((1, 2, 0, 4), dtype=dtype) out = dpnp.ones(()) @@ -950,9 +950,9 @@ def test_sum_empty_out(dtype): assert_array_equal(out.asnumpy(), numpy.array(0, dtype=dtype)) -@pytest.mark.parametrize("shape", [(), (1, 2, 3), (1, 0, 2), (10), (3, 3, 3), (5, 5), (0, 6)]) -@pytest.mark.parametrize("dtype_in", get_all_dtypes(no_complex=True, no_bool=True)) -@pytest.mark.parametrize("dtype_out", get_all_dtypes(no_complex=True, no_bool=True)) +@pytest.mark.parametrize('shape', [(), (1, 2, 3), (1, 0, 2), (10), (3, 3, 3), (5, 5), (0, 6)]) +@pytest.mark.parametrize('dtype_in', get_all_dtypes(no_complex=True, no_bool=True)) +@pytest.mark.parametrize('dtype_out', get_all_dtypes(no_complex=True, no_bool=True)) def test_sum(shape, dtype_in, dtype_out): a_np = numpy.ones(shape, dtype=dtype_in) a = dpnp.ones(shape, dtype=dtype_in) @@ -965,7 +965,7 @@ def test_sum(shape, dtype_in, dtype_out): class TestMean: - @pytest.mark.parametrize("dtype", get_all_dtypes()) + @pytest.mark.parametrize('dtype', get_all_dtypes()) def test_mean_axis_tuple(self, dtype): dp_array = dpnp.array([[0,1,2],[3,4,0]], dtype=dtype) np_array = dpnp.asnumpy(dp_array) diff --git a/tests/test_outer.py b/tests/test_outer.py index 3ac751b2b28..7d909aa232d 100644 --- a/tests/test_outer.py +++ b/tests/test_outer.py @@ -55,7 +55,7 @@ def test_second_is_scalar(self, xp, dtype): a = xp.arange(5**3, dtype=dtype).reshape(5, 5, 5) return xp.outer(a, scalar) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_both_inputs_as_scalar(self, xp): a = xp.int64(4) diff --git a/tests/test_random.py b/tests/test_random.py index bc3501f4d20..ee18fbd40b9 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -41,7 +41,7 @@ def check_seed(self, dist_name, params): assert_allclose(a1, a2, rtol=1e-07, atol=0) -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('func', [dpnp.random.chisquare, dpnp.random.rand, dpnp.random.randn], @@ -57,7 +57,7 @@ def test_input_size(func): assert output_shape == res.shape -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('func', [dpnp.random.chisquare, dpnp.random.random, dpnp.random.random_sample, @@ -75,7 +75,7 @@ def test_input_shape(func): assert shape == res.shape -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('func', [dpnp.random.random, dpnp.random.random_sample, dpnp.random.ranf, @@ -95,7 +95,7 @@ def test_check_output(func): assert dpnp.all(res < 1) -@pytest.mark.parametrize("func", +@pytest.mark.parametrize('func', [dpnp.random.random, dpnp.random.random_sample, dpnp.random.ranf, @@ -139,7 +139,7 @@ def test_randn_normal_distribution(): assert math.isclose(mean, expected_mean, abs_tol=0.03) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsBeta(TestDistribution): def test_moments(self): @@ -163,7 +163,7 @@ def test_seed(self): self.check_seed('beta', {'a': a, 'b': b}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsBinomial(TestDistribution): def test_extreme_value(self): @@ -201,7 +201,7 @@ def test_seed(self): self.check_seed('binomial', {'n': n, 'p': p}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsChisquare(TestDistribution): def test_invalid_args(self): @@ -213,7 +213,7 @@ def test_seed(self): self.check_seed('chisquare', {'df': df}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsExponential(TestDistribution): def test_invalid_args(self): @@ -225,7 +225,7 @@ def test_seed(self): self.check_seed('exponential', {'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsF(TestDistribution): def test_moments(self): @@ -253,7 +253,7 @@ def test_seed(self): self.check_seed('f', {'dfnum': dfnum, 'dfden': dfden}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsGamma(TestDistribution): def test_moments(self): @@ -277,7 +277,7 @@ def test_seed(self): self.check_seed('gamma', {'shape': shape}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsGeometric(TestDistribution): def test_extreme_value(self): @@ -301,7 +301,7 @@ def test_seed(self): self.check_seed('geometric', {'p': p}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsGumbel(TestDistribution): def test_extreme_value(self): @@ -331,7 +331,7 @@ def test_seed(self): self.check_seed('gumbel', {'loc': loc, 'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsHypergeometric(TestDistribution): def test_extreme_value(self): @@ -398,7 +398,7 @@ def test_seed(self): {'ngood': ngood, 'nbad': nbad, 'nsample': nsample}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsLaplace(TestDistribution): def test_extreme_value(self): @@ -428,7 +428,7 @@ def test_seed(self): self.check_seed('laplace', {'loc': loc, 'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsLogistic(TestDistribution): def test_moments(self): @@ -451,7 +451,7 @@ def test_seed(self): self.check_seed('logistic', {'loc': loc, 'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsLognormal(TestDistribution): def test_extreme_value(self): @@ -480,7 +480,7 @@ def test_seed(self): self.check_seed('lognormal', {'mean': mean, 'sigma': sigma}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsMultinomial(TestDistribution): def test_extreme_value(self): @@ -527,7 +527,7 @@ def test_seed1(self): self.check_seed('multinomial', {'n': n, 'pvals': pvals}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsMultivariateNormal(TestDistribution): def test_moments(self): @@ -567,7 +567,7 @@ def test_seed(self): self.check_seed('multivariate_normal', {'mean': mean, 'cov': cov}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsNegativeBinomial(TestDistribution): def test_extreme_value(self): @@ -624,10 +624,10 @@ def test_seed(self): self.check_seed('normal', {'loc': loc, 'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsNoncentralChisquare: - @pytest.mark.parametrize("df", [5.0, 1.0, 0.5], ids=['df_grt_1', 'df_eq_1', 'df_less_1']) + @pytest.mark.parametrize('df', [5.0, 1.0, 0.5], ids=['df_grt_1', 'df_eq_1', 'df_less_1']) def test_moments(self, df): nonc = 20. expected_mean = df + nonc @@ -652,7 +652,7 @@ def test_invalid_args(self): with pytest.raises(ValueError): dpnp.random.noncentral_chisquare(df, nonc, size=size) - @pytest.mark.parametrize("df", [5.0, 1.0, 0.5], ids=['df_grt_1', 'df_eq_1', 'df_less_1']) + @pytest.mark.parametrize('df', [5.0, 1.0, 0.5], ids=['df_grt_1', 'df_eq_1', 'df_less_1']) def test_seed(self, df): seed = 28041990 size = 10 @@ -664,7 +664,7 @@ def test_seed(self, df): assert_allclose(a1, a2, rtol=1e-07, atol=0) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsPareto(TestDistribution): def test_moments(self): @@ -684,7 +684,7 @@ def test_seed(self): self.check_seed('pareto', {'a': a}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsPoisson(TestDistribution): def test_extreme_value(self): @@ -707,7 +707,7 @@ def test_seed(self): self.check_seed('poisson', {'lam': lam}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsPower(TestDistribution): def test_moments(self): @@ -728,7 +728,7 @@ def test_seed(self): self.check_seed('power', {'a': a}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsRayleigh(TestDistribution): def test_extreme_value(self): @@ -770,7 +770,7 @@ def test_seed(self): self.check_seed('standard_exponential', {}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsStandardGamma(TestDistribution): def test_extreme_value(self): @@ -803,7 +803,7 @@ def test_seed(self): self.check_seed('standard_normal', {}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsStandardT(TestDistribution): def test_moments(self): @@ -821,7 +821,7 @@ def test_seed(self): self.check_seed('standard_t', {'df': 10.0}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsTriangular(TestDistribution): def test_moments(self): @@ -874,10 +874,10 @@ def test_seed(self): self.check_seed('uniform', {'low': low, 'high': high}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsVonmises: - @pytest.mark.parametrize("kappa", [5.0, 0.5], ids=['large_kappa', 'small_kappa']) + @pytest.mark.parametrize('kappa', [5.0, 0.5], ids=['large_kappa', 'small_kappa']) def test_moments(self, kappa): size = 10**6 mu = 2. @@ -899,7 +899,7 @@ def test_invalid_args(self): with pytest.raises(ValueError): dpnp.random.vonmises(mu, kappa, size=size) - @pytest.mark.parametrize("kappa", [5.0, 0.5], ids=['large_kappa', 'small_kappa']) + @pytest.mark.parametrize('kappa', [5.0, 0.5], ids=['large_kappa', 'small_kappa']) def test_seed(self, kappa): seed = 28041990 size = 10 @@ -911,7 +911,7 @@ def test_seed(self, kappa): assert_allclose(a1, a2, rtol=1e-07, atol=0) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsWald(TestDistribution): def test_moments(self): @@ -938,7 +938,7 @@ def test_seed(self): self.check_seed('wald', {'mean': mean, 'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsWeibull(TestDistribution): def test_extreme_value(self): @@ -955,7 +955,7 @@ def test_seed(self): self.check_seed('weibull', {'a': a}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestDistributionsZipf(TestDistribution): def test_invalid_args(self): @@ -969,7 +969,7 @@ def test_seed(self): class TestPermutationsTestShuffle: - @pytest.mark.parametrize("dtype", [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64], + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64], ids=['float32', 'float64', 'int32', 'int64']) def test_shuffle(self, dtype): seed = 28041990 @@ -983,7 +983,7 @@ def test_shuffle(self, dtype): actual_x = input_x assert_array_equal(actual_x, desired_x) - @pytest.mark.parametrize("dtype", [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64], + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, dpnp.int32, dpnp.int64], ids=['float32', 'float64', 'int32', 'int64']) def test_no_miss_numbers(self, dtype): seed = 28041990 @@ -995,7 +995,7 @@ def test_no_miss_numbers(self, dtype): actual_x = dpnp.sort(output_x) assert_array_equal(actual_x, desired_x) - @pytest.mark.parametrize("conv", [lambda x: dpnp.array([]), + @pytest.mark.parametrize('conv', [lambda x: dpnp.array([]), # lambda x: dpnp.astype(dpnp.asarray(x), dpnp.int8), lambda x: dpnp.astype(dpnp.asarray(x), dpnp.float32), # lambda x: dpnp.asarray(x).astype(dpnp.complex64), @@ -1003,9 +1003,9 @@ def test_no_miss_numbers(self, dtype): lambda x: dpnp.asarray([[i, i] for i in x]), lambda x: dpnp.vstack([x, x]).T, lambda x: (dpnp.asarray([(i, i) for i in x], [ - ("a", int), ("b", int)]).view(dpnp.recarray)), + ('a', int), ('b', int)]).view(dpnp.recarray)), lambda x: dpnp.asarray([(i, i) for i in x], - [("a", object), ("b", dpnp.int32)])], + [('a', object), ('b', dpnp.int32)])], ids=['lambda x: dpnp.array([])', # 'lambda x: dpnp.astype(dpnp.asarray(x), dpnp.int8)', 'lambda x: dpnp.astype(dpnp.asarray(x), dpnp.float32)', @@ -1046,8 +1046,8 @@ def test_shuffle1(self, conv): assert_array_equal(actual, desired) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("conv", [lambda x: x, + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('conv', [lambda x: x, lambda x: [(i, i) for i in x]], ids=['lambda x: x', 'lambda x: [(i, i) for i in x]', diff --git a/tests/test_random_state.py b/tests/test_random_state.py index ad6483c0721..5986c09ebf3 100644 --- a/tests/test_random_state.py +++ b/tests/test_random_state.py @@ -36,11 +36,11 @@ def get_default_floating(): class TestNormal: - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, dpnp.float, None], ids=['float32', 'float64', 'float', 'None']) - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, dtype, usm_type): seed = 1234567 @@ -83,11 +83,11 @@ def test_distr(self, dtype, usm_type): assert_cfd(dpnp_data, sycl_queue, usm_type) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, None], ids=['float32', 'float64', 'None']) - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_scale(self, dtype, usm_type): mean = 7 @@ -107,7 +107,7 @@ def test_scale(self, dtype, usm_type): assert_raises(ValueError, func, scale=-3.71) - @pytest.mark.parametrize("loc", + @pytest.mark.parametrize('loc', [numpy.inf, -numpy.inf, numpy.nextafter(numpy.finfo(get_default_floating()).max, 0), numpy.nextafter(numpy.finfo(get_default_floating()).min, 0)], @@ -124,7 +124,7 @@ def test_inf_scale(self): assert_equal(a.min(), -numpy.inf) - @pytest.mark.parametrize("loc", + @pytest.mark.parametrize('loc', [numpy.inf, -numpy.inf], ids=['numpy.inf', '-numpy.inf']) def test_inf_loc_scale(self, loc): @@ -154,15 +154,15 @@ def test_extreme_bounds(self): func(loc=numpy.nextafter(fmin, 0), scale=numpy.nextafter(fmax, 0), size=size) func(loc=numpy.nextafter(fmax, 0), scale=numpy.nextafter(fmax, 0), size=size) except Exception as e: - raise AssertionError("No error should have been raised, but one was " - "with the following message:\n\n%s" % str(e)) + raise AssertionError('No error should have been raised, but one was ' + 'with the following message:\n\n%s' % str(e)) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("scale", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('scale', [dpnp.array([3]), numpy.array([3])], ids=['dpnp.array([3])', 'numpy.array([3])']) - @pytest.mark.parametrize("loc", + @pytest.mark.parametrize('loc', [[2], dpnp.array([2]), numpy.array([2])], ids=['[2]', 'dpnp.array([2])', 'numpy.array([2])']) def test_fallback(self, loc, scale): @@ -184,7 +184,7 @@ def test_fallback(self, loc, scale): assert_cfd(data, sycl_queue) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [dpnp.float16, float, dpnp.integer, dpnp.int64, dpnp.int32, dpnp.int, int, numpy.longcomplex, dpnp.complex128, dpnp.complex64, dpnp.bool, dpnp.bool_], ids=['dpnp.float16', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int32', 'dpnp.int', 'int', @@ -194,8 +194,8 @@ def test_invalid_dtype(self, dtype): assert_raises(TypeError, RandomState().normal, dtype=dtype) - @pytest.mark.parametrize("usm_type", - ["", "unknown"], + @pytest.mark.parametrize('usm_type', + ['', 'unknown'], ids=['Empty', 'Unknown']) def test_invalid_usm_type(self, usm_type): # dtype must be float32 or float64 @@ -203,8 +203,8 @@ def test_invalid_usm_type(self, usm_type): class TestRand: - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, usm_type): seed = 28042 @@ -242,7 +242,7 @@ def test_distr(self, usm_type): usm_type=usm_type) - @pytest.mark.parametrize("dims", + @pytest.mark.parametrize('dims', [(), (5,), (10, 2, 7), (0,)], ids=['()', '(5,)', '(10, 2, 7)', '(0,)']) def test_dims(self, dims): @@ -254,10 +254,10 @@ def test_dims(self, dims): high=1.0, size=size, dtype=None, - usm_type="device") + usm_type='device') - @pytest.mark.parametrize("zero_dims", + @pytest.mark.parametrize('zero_dims', [(0,), (3, 0), (3, 0, 10), ()], ids=['(0,)', '(3, 0)', '(3, 0, 10)', '()']) def test_zero_dims(self, zero_dims): @@ -273,11 +273,11 @@ def test_wrong_dims(self): class TestRandInt: - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [int, dpnp.int32, dpnp.int, dpnp.integer], ids=['int', 'dpnp.int32', 'dpnp.int', 'dpnp.integer']) - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, dtype, usm_type): seed = 9864 @@ -358,7 +358,7 @@ def test_negative_interval(self): x = rs.randint(-7, -1, 5) assert_equal(-7 <= x, True) - assert_equal(x < -1, True) + assert_equal(x < -1, True) def test_bounds_checking(self): @@ -393,7 +393,7 @@ def test_rng_zero_and_extremes(self): sycl_device = dpctl.SyclQueue().sycl_device if sycl_device.has_aspect_gpu and not sycl_device.has_aspect_fp64: # TODO: discuss with opneMKL - pytest.skip(f"Due to some reason, oneMKL wrongly returns high value instead of low") + pytest.skip(f'Due to some reason, oneMKL wrongly returns high value instead of low') tgt = high - 1 assert_equal(func(tgt, tgt + 1, size=1000), tgt) @@ -413,11 +413,11 @@ def test_full_range(self): try: RandomState().randint(low, high) except Exception as e: - raise AssertionError("No error should have been raised, but one was " - "with the following message:\n\n%s" % str(e)) + raise AssertionError('No error should have been raised, but one was ' + 'with the following message:\n\n%s' % str(e)) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_in_bounds_fuzz(self): for high in [4, 8, 16]: vals = RandomState().randint(2, high, size=2**16) @@ -425,7 +425,7 @@ def test_in_bounds_fuzz(self): assert_equal(vals.min() >= 2, True) - @pytest.mark.parametrize("zero_size", + @pytest.mark.parametrize('zero_size', [(3, 0, 4), 0, (0,), ()], ids=['(3, 0, 4)', '0', '(0,)', '()']) def test_zero_size(self, zero_size): @@ -433,11 +433,11 @@ def test_zero_size(self, zero_size): assert_equal(RandomState().randint(0, 10, size=zero_size).shape, exp_shape) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("high", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('high', [dpnp.array([3]), numpy.array([3])], ids=['dpnp.array([3])', 'numpy.array([3])']) - @pytest.mark.parametrize("low", + @pytest.mark.parametrize('low', [[2], dpnp.array([2]), numpy.array([2])], ids=['[2]', 'dpnp.array([2])', 'numpy.array([2])']) def test_bounds_fallback(self, low, high): @@ -450,8 +450,8 @@ def test_bounds_fallback(self, low, high): assert_equal(actual, expected) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("dtype", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('dtype', [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): @@ -461,7 +461,7 @@ def test_dtype_fallback(self, dtype): size = (3, 2, 5) 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") + 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() @@ -470,8 +470,8 @@ def test_dtype_fallback(self, dtype): assert_raises(TypeError, RandomState().randint, dtype=dtype) - @pytest.mark.parametrize("usm_type", - ["", "unknown"], + @pytest.mark.parametrize('usm_type', + ['', 'unknown'], ids=['Empty', 'Unknown']) def test_invalid_usm_type(self, usm_type): # dtype must be float32 or float64 @@ -479,8 +479,8 @@ def test_invalid_usm_type(self, usm_type): class TestRandN: - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, usm_type): seed = 3649 @@ -518,7 +518,7 @@ def test_distr(self, usm_type): usm_type=usm_type) - @pytest.mark.parametrize("dims", + @pytest.mark.parametrize('dims', [(), (5,), (10, 2, 7), (0,)], ids=['()', '(5,)', '(10, 2, 7)', '(0,)']) def test_dims(self, dims): @@ -530,10 +530,10 @@ def test_dims(self, dims): scale=1.0, size=size, dtype=None, - usm_type="device") + usm_type='device') - @pytest.mark.parametrize("zero_dims", + @pytest.mark.parametrize('zero_dims', [(0,), (3, 0), (3, 0, 10), ()], ids=['(0,)', '(3, 0)', '(3, 0, 10)', '()']) def test_zero_dims(self, zero_dims): @@ -549,7 +549,7 @@ def test_wrong_dims(self): class TestSeed: - @pytest.mark.parametrize("func", + @pytest.mark.parametrize('func', ['normal', 'standard_normal', 'random_sample', 'uniform'], ids=['normal', 'standard_normal', 'random_sample', 'uniform']) def test_scalar(self, func): @@ -566,8 +566,8 @@ def test_scalar(self, func): assert_array_almost_equal(a1, a2, decimal=precision) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("seed", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('seed', [range(3), numpy.arange(3, dtype=numpy.int32), dpnp.arange(3, dtype=numpy.int32), @@ -578,7 +578,7 @@ def test_scalar(self, func): '[0]', '[4294967295]', '[2, 7, 15]', '(1,)', '(85, 6, 17)']) def test_array_range(self, seed): if not is_cpu_device(): - pytest.skip("seed as a scalar is only supported on GPU") + pytest.skip('seed as a scalar is only supported on GPU') size = 15 a1 = RandomState(seed).uniform(size=size).asnumpy() @@ -586,7 +586,7 @@ def test_array_range(self, seed): assert_allclose(a1, a2, rtol=1e-07, atol=0) - @pytest.mark.parametrize("seed", + @pytest.mark.parametrize('seed', [0.5, -1.5, [-0.3], (1.7, 3), 'text', numpy.arange(0, 1, 0.5), @@ -602,8 +602,8 @@ def test_invalid_type(self, seed): assert_raises(TypeError, RandomState, seed) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("seed", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('seed', [-1, [-3, 7], (17, 3, -5), [4, 3, 2, 1], (7, 6, 5, 1), range(-1, -11, -1), numpy.arange(4, dtype=numpy.int32), @@ -628,7 +628,7 @@ def test_invalid_value(self, seed): # seed must be a scalar assert_raises(TypeError, RandomState, seed) - @pytest.mark.parametrize("seed", + @pytest.mark.parametrize('seed', [[], (), [[1, 2, 3]], [[1, 2, 3], [4, 5, 6]], @@ -653,8 +653,8 @@ def test_invalid_shape(self, seed): class TestStandardNormal: - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, usm_type): seed = 1234567 @@ -697,7 +697,7 @@ def test_distr(self, usm_type): usm_type=usm_type) - @pytest.mark.parametrize("size", + @pytest.mark.parametrize('size', [(), (5,), (10, 2, 7), (0,)], ids=['()', '(5,)', '(10, 2, 7)', '(0,)']) def test_sizes(self, size): @@ -707,7 +707,7 @@ def test_sizes(self, size): scale=1.0, size=size, dtype=None, - usm_type="device") + usm_type='device') def test_wrong_dims(self): @@ -719,8 +719,8 @@ def test_wrong_dims(self): class TestRandSample: - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, usm_type): seed = 12657 @@ -757,7 +757,7 @@ def test_distr(self, usm_type): usm_type=usm_type) - @pytest.mark.parametrize("size", + @pytest.mark.parametrize('size', [(), (5,), (10, 2, 7), (0,)], ids=['()', '(5,)', '(10, 2, 7)', '(0,)']) def test_sizes(self, size): @@ -767,7 +767,7 @@ def test_sizes(self, size): high=1.0, size=size, dtype=None, - usm_type="device") + usm_type='device') def test_wrong_dims(self): @@ -779,14 +779,14 @@ def test_wrong_dims(self): class TestUniform: - @pytest.mark.parametrize("bounds", + @pytest.mark.parametrize('bounds', [[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", + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, dpnp.float, dpnp.int32, None], ids=['float32', 'float64', 'float', 'int32', 'None']) - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_distr(self, bounds, dtype, usm_type): seed = 28041997 @@ -838,11 +838,11 @@ def test_distr(self, bounds, dtype, usm_type): assert_cfd(dpnp_data, sycl_queue, usm_type) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [dpnp.float32, dpnp.float64, dpnp.int32, None], ids=['float32', 'float64', 'int32', 'None']) - @pytest.mark.parametrize("usm_type", - ["host", "device", "shared"], + @pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared'], ids=['host', 'device', 'shared']) def test_low_high_equal(self, dtype, usm_type): seed = 28045 @@ -869,7 +869,7 @@ def test_low_high_equal(self, dtype, usm_type): assert_array_almost_equal(actual, expected, decimal=numpy.finfo(dtype=dtype).precision) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_range_bounds(self): fmin = numpy.finfo('double').min fmax = numpy.finfo('double').max @@ -885,11 +885,11 @@ def test_range_bounds(self): func(low=numpy.nextafter(fmin, 0), high=numpy.nextafter(fmax, 0)) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") - @pytest.mark.parametrize("high", + @pytest.mark.usefixtures('allow_fall_back_on_numpy') + @pytest.mark.parametrize('high', [dpnp.array([3]), numpy.array([3])], ids=['dpnp.array([3])', 'numpy.array([3])']) - @pytest.mark.parametrize("low", + @pytest.mark.parametrize('low', [[2], dpnp.array([2]), numpy.array([2])], ids=['[2]', 'dpnp.array([2])', 'numpy.array([2])']) def test_fallback(self, low, high): @@ -911,21 +911,21 @@ def test_fallback(self, low, high): assert_cfd(data, sycl_queue) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [dpnp.float16, float, dpnp.integer, dpnp.int64, dpnp.int, int, numpy.longcomplex, dpnp.complex128, dpnp.complex64, dpnp.bool, dpnp.bool_], ids=['dpnp.float16', 'float', 'dpnp.integer', 'dpnp.int64', 'dpnp.int', 'int', 'numpy.longcomplex', 'dpnp.complex128', 'dpnp.complex64', 'dpnp.bool', 'dpnp.bool_']) def test_invalid_dtype(self, dtype): 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") + 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) - @pytest.mark.parametrize("usm_type", - ["", "unknown"], + @pytest.mark.parametrize('usm_type', + ['', 'unknown'], ids=['Empty', 'Unknown']) def test_invalid_usm_type(self, usm_type): # dtype must be float32 or float64 diff --git a/tests/test_sort.py b/tests/test_sort.py index cfcef2c3db0..0bab187e170 100644 --- a/tests/test_sort.py +++ b/tests/test_sort.py @@ -9,11 +9,11 @@ ) -@pytest.mark.parametrize("kth", +@pytest.mark.parametrize('kth', [0, 1], ids=['0', '1']) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True)) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_none=True)) +@pytest.mark.parametrize('array', [[3, 4, 2, 1], [[1, 0], [3, 0]], [[3, 2], [1, 6]], @@ -37,11 +37,11 @@ def test_partition(array, dtype, kth): assert (p[..., kth:kth + 1] <= p[..., kth + 1:]).all() -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("side", - ["left", "right"], +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('side', + ['left', 'right'], ids=['"left"', '"right"']) -@pytest.mark.parametrize("v_", +@pytest.mark.parametrize('v_', [ [[3, 4], [2, 1]], [[1, 0], [3, 0]], @@ -58,10 +58,10 @@ def test_partition(array, dtype, kth): '[[1, -3, 3], [0, 5, 2], [0, 1, 1], [0, 0, 1]]', '[[[[8, 2], [3, 0]], [[5, 2], [0, 1]]], [[[1, 3], [3, 1]], [[5, 2], [0, 1]]]]' ]) -@pytest.mark.parametrize("dtype", +@pytest.mark.parametrize('dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("array", +@pytest.mark.parametrize('array', [ [1, 2, 3, 4], [-5, -1, 0, 3, 17, 100] diff --git a/tests/test_statistics.py b/tests/test_statistics.py index d9879244f09..dac18481caf 100644 --- a/tests/test_statistics.py +++ b/tests/test_statistics.py @@ -5,10 +5,10 @@ import numpy -@pytest.mark.parametrize("type", +@pytest.mark.parametrize('type', [numpy.float64, numpy.float32, numpy.int64, numpy.int32], ids=['float64', 'float32', 'int64', 'int32']) -@pytest.mark.parametrize("size", +@pytest.mark.parametrize('size', [2, 4, 8, 16, 3, 9, 27, 81]) def test_median(type, size): a = numpy.arange(size, dtype=type) @@ -20,8 +20,8 @@ def test_median(type, size): numpy.testing.assert_allclose(dpnp_res, np_res) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("axis", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('axis', [0, 1, -1, 2, -2, (1, 2), (0, -2)]) def test_max(axis): a = numpy.arange(768, dtype=numpy.float64).reshape((4, 4, 6, 8)) @@ -33,8 +33,8 @@ def test_max(axis): numpy.testing.assert_allclose(dpnp_res, np_res) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("array", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('array', [[2, 0, 6, 2], [2, 0, 6, 2, 5, 6, 7, 8], [], @@ -76,17 +76,17 @@ def test_nanvar(array): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestBincount: - @pytest.mark.parametrize("array", + @pytest.mark.parametrize('array', [[1, 2, 3], [1, 2, 2, 1, 2, 4], [2, 2, 2, 2]], ids=['[1, 2, 3]', '[1, 2, 2, 1, 2, 4]', '[2, 2, 2, 2]']) - @pytest.mark.parametrize("minlength", + @pytest.mark.parametrize('minlength', [0, 1, 3, 5], ids=['0', '1', '3', '5']) def test_bincount_minlength(self, array, minlength): @@ -97,10 +97,10 @@ def test_bincount_minlength(self, array, minlength): result = dpnp.bincount(dpnp_a, minlength=minlength) numpy.testing.assert_array_equal(expected, result) - @pytest.mark.parametrize("array", + @pytest.mark.parametrize('array', [[1, 2, 2, 1, 2, 4]], ids=['[1, 2, 2, 1, 2, 4]']) - @pytest.mark.parametrize("weights", + @pytest.mark.parametrize('weights', [None, [0.3, 0.5, 0.2, 0.7, 1., -0.6], [2, 2, 2, 2, 2, 2]], @@ -115,17 +115,15 @@ def test_bincount_weights(self, array, weights): result = dpnp.bincount(dpnp_a, weights=weights) numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_none=True, no_complex=True)) def test_cov_rowvar(dtype): a = dpnp.array([[0, 2], [1, 1], [2, 0]], dtype=dtype) b = numpy.array([[0, 2], [1, 1], [2, 0]], dtype=dtype) numpy.testing.assert_array_equal(dpnp.cov(a.T), dpnp.cov(a,rowvar=False)) numpy.testing.assert_array_equal(numpy.cov(b,rowvar=False), dpnp.cov(a,rowvar=False)) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_none=True, no_complex=True)) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_none=True, no_complex=True)) def test_cov_1D_rowvar(dtype): a = dpnp.array([[0, 1, 2]], dtype=dtype) b = numpy.array([[0, 1, 2]], dtype=dtype) numpy.testing.assert_array_equal(numpy.cov(b,rowvar=False), dpnp.cov(a,rowvar=False)) - - diff --git a/tests/test_strides.py b/tests/test_strides.py index 83396e019cb..823b1fe52f8 100644 --- a/tests/test_strides.py +++ b/tests/test_strides.py @@ -13,16 +13,16 @@ def _getattr(ex, str_): - attrs = str_.split(".") + attrs = str_.split('.') res = ex for attr in attrs: res = getattr(res, attr) return res -@pytest.mark.parametrize("func_name", +@pytest.mark.parametrize('func_name', ['abs', ]) -@pytest.mark.parametrize("dtype", get_all_dtypes()) +@pytest.mark.parametrize('dtype', get_all_dtypes()) def test_strides(func_name, dtype): shape = (4, 4) a = numpy.ones(shape[0] * shape[1], dtype=dtype).reshape(shape) @@ -39,16 +39,16 @@ def test_strides(func_name, dtype): assert_allclose(expected, result) -@pytest.mark.usefixtures("suppress_divide_invalid_numpy_warnings") -@pytest.mark.parametrize("func_name", - ["arccos", "arccosh", "arcsin", "arcsinh", "arctan", "arctanh", "cbrt", "ceil", "copy", "cos", - "cosh", "conjugate", "degrees", "ediff1d", "exp", "exp2", "expm1", "fabs", "floor", "log", - "log10", "log1p", "log2", "negative", "radians", "sign", "sin", "sinh", "sqrt", "square", - "tanh", "trunc"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.usefixtures('suppress_divide_invalid_numpy_warnings') +@pytest.mark.parametrize('func_name', + ['arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', 'cbrt', 'ceil', 'copy', 'cos', + 'cosh', 'conjugate', 'degrees', 'ediff1d', 'exp', 'exp2', 'expm1', 'fabs', 'floor', 'log', + 'log10', 'log1p', 'log2', 'negative', 'radians', 'sign', 'sin', 'sinh', 'sqrt', 'square', + 'tanh', 'trunc']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(10,)], - ids=["(10,)"]) + ids=['(10,)']) def test_strides_1arg(func_name, dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a[::2] @@ -65,10 +65,10 @@ def test_strides_1arg(func_name, dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(10,)], - ids=["(10,)"]) + ids=['(10,)']) def test_strides_erf(dtype, shape): a = dpnp.reshape(dpnp.linspace(-1, 1, num=numpy.prod(shape), dtype=dtype), shape) b = a[::2] @@ -82,10 +82,10 @@ def test_strides_erf(dtype, shape): assert_allclose(result, expected, rtol=1e-06) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(10,)], - ids=["(10,)"]) + ids=['(10,)']) def test_strides_reciprocal(dtype, shape): start, stop = 1, numpy.prod(shape) + 1 @@ -101,10 +101,10 @@ def test_strides_reciprocal(dtype, shape): assert_allclose(result, expected, rtol=1e-06) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(10,)], - ids=["(10,)"]) + ids=['(10,)']) def test_strides_tan(dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a[::2] @@ -118,12 +118,12 @@ def test_strides_tan(dtype, shape): assert_allclose(result, expected, rtol=1e-06) -@pytest.mark.parametrize("func_name", - ["add", "arctan2", "divide", "hypot", "maximum", "minimum", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('func_name', + ['add', 'arctan2', 'divide', 'hypot', 'maximum', 'minimum', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(3, 3)], - ids=["(3, 3)"]) + ids=['(3, 3)']) def test_strides_2args(func_name, dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a.T @@ -140,14 +140,14 @@ def test_strides_2args(func_name, dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("func_name", - ["bitwise_and", "bitwise_or", "bitwise_xor", "left_shift", "right_shift"]) -@pytest.mark.parametrize("dtype", +@pytest.mark.parametrize('func_name', + ['bitwise_and', 'bitwise_or', 'bitwise_xor', 'left_shift', 'right_shift']) +@pytest.mark.parametrize('dtype', [numpy.int64, numpy.int32], - ids=["int64", "int32"]) -@pytest.mark.parametrize("shape", + ids=['int64', 'int32']) +@pytest.mark.parametrize('shape', [(3, 3)], - ids=["(3, 3)"]) + ids=['(3, 3)']) def test_strides_bitwise(func_name, dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a.T @@ -164,10 +164,10 @@ def test_strides_bitwise(func_name, dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(3, 3)], - ids=["(3, 3)"]) + ids=['(3, 3)']) def test_strides_copysign(dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = -a.T @@ -181,10 +181,10 @@ def test_strides_copysign(dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(3, 3)], - ids=["(3, 3)"]) + ids=['(3, 3)']) def test_strides_fmod(dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a.T + 1 @@ -198,10 +198,10 @@ def test_strides_fmod(dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) -@pytest.mark.parametrize("shape", +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('shape', [(3, 3)], - ids=["(3, 3)"]) + ids=['(3, 3)']) def test_strides_true_devide(dtype, shape): a = numpy.arange(numpy.prod(shape), dtype=dtype).reshape(shape) b = a.T + 1 @@ -215,9 +215,9 @@ def test_strides_true_devide(dtype, shape): assert_allclose(result, expected) -@pytest.mark.parametrize("func_name", - ["add", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('func_name', + ['add', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_strided_out_2args(func_name, dtype): np_out = numpy.ones((5, 3, 2), dtype=dtype)[::3] np_a = numpy.arange(numpy.prod(np_out.shape), dtype=dtype).reshape(np_out.shape) @@ -234,9 +234,9 @@ def test_strided_out_2args(func_name, dtype): assert_allclose(dp_out.asnumpy(), np_out) -@pytest.mark.parametrize("func_name", - ["add", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('func_name', + ['add', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) def test_strided_in_out_2args(func_name, dtype): sh = (3, 4, 2) prod = numpy.prod(sh) @@ -256,9 +256,9 @@ def test_strided_in_out_2args(func_name, dtype): assert_allclose(dp_out.asnumpy(), np_out, rtol=1e-06) -@pytest.mark.parametrize("func_name", - ["add", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True)) +@pytest.mark.parametrize('func_name', + ['add', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True)) @pytest.mark.skip("dpctl doesn't support type mismatch of out array") def test_strided_in_out_2args_diff_out_dtype(func_name, dtype): sh = (3, 3, 2) @@ -279,9 +279,9 @@ def test_strided_in_out_2args_diff_out_dtype(func_name, dtype): assert_allclose(dp_out.asnumpy(), np_out, rtol=1e-06) -@pytest.mark.parametrize("func_name", - ["add", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) +@pytest.mark.parametrize('func_name', + ['add', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) @pytest.mark.skip("dpctl doesn't support overlap of arrays") def test_strided_in_2args_overlap(func_name, dtype): size = 5 @@ -296,9 +296,9 @@ def test_strided_in_2args_overlap(func_name, dtype): assert_allclose(dp_a.asnumpy(), np_a, rtol=1e-06) -@pytest.mark.parametrize("func_name", - ["add", "multiply", "power", "subtract"]) -@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) +@pytest.mark.parametrize('func_name', + ['add', 'multiply', 'power', 'subtract']) +@pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) @pytest.mark.skip("dpctl doesn't support overlap of arrays") def test_strided_in_out_2args_overlap(func_name, dtype): sh = (4, 3, 2) diff --git a/tests/test_sum.py b/tests/test_sum.py index ed382a4bcdd..b640acc69b5 100644 --- a/tests/test_sum.py +++ b/tests/test_sum.py @@ -8,7 +8,7 @@ # Note: numpy.sum() always upcast integers to (u)int64 and float32 to # float64 for dtype=None. `np.sum` does that too for integers, but not for # float32, so we need to special-case it for these tests -@pytest.mark.parametrize("dtype", get_float_dtypes()) +@pytest.mark.parametrize('dtype', get_float_dtypes()) def test_sum_float(dtype): a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]], dtype=dtype) ia = dpnp.array(a) diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index 7b72c92600c..69e703b4320 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -19,15 +19,15 @@ list_of_backend_str = [ - "host", - "level_zero", - "opencl", + 'host', + 'level_zero', + 'opencl', ] list_of_device_type_str = [ - "host", - "gpu", - "cpu", + 'host', + 'gpu', + 'cpu', ] available_devices = [d for d in dpctl.get_devices() if not getattr(d, 'has_aspect_host', False)] @@ -55,13 +55,13 @@ def assert_sycl_queue_equal(result, expected): def vvsort(val, vec, size, xp): - val_kwargs = dict() + val_kwargs = {} if hasattr(val, 'sycl_queue'): - val_kwargs['sycl_queue'] = getattr(val, "sycl_queue", None) + val_kwargs['sycl_queue'] = getattr(val, 'sycl_queue', None) - vec_kwargs = dict() + vec_kwargs = {} if hasattr(vec, 'sycl_queue'): - vec_kwargs['sycl_queue'] = getattr(vec, "sycl_queue", None) + vec_kwargs['sycl_queue'] = getattr(vec, 'sycl_queue', None) for i in range(size): imax = i @@ -86,28 +86,28 @@ def vvsort(val, vec, size, xp): @pytest.mark.parametrize( - "func, arg, kwargs", + 'func, arg, kwargs', [ - pytest.param("arange", + pytest.param('arange', [-25.7], {'stop': 10**8, 'step': 15}), - pytest.param("full", + pytest.param('full', [(2,2)], {'fill_value': 5}), - pytest.param("eye", + pytest.param('eye', [4, 2], {}), - pytest.param("linspace", + pytest.param('linspace', [0, 4, 8], {}), - pytest.param("ones", + pytest.param('ones', [(2,2)], {}), - pytest.param("zeros", + pytest.param('zeros', [(2,2)], {}) ]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_array_creation(func, arg, kwargs, device): @@ -121,7 +121,7 @@ def test_array_creation(func, arg, kwargs, device): assert dpnp_array.sycl_device == device -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_empty(device): @@ -129,10 +129,10 @@ def test_empty(device): assert dpnp_array.sycl_device == device -@pytest.mark.parametrize("device_x", +@pytest.mark.parametrize('device_x', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("device_y", +@pytest.mark.parametrize('device_y', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_empty_like(device_x, device_y): @@ -144,31 +144,31 @@ def test_empty_like(device_x, device_y): @pytest.mark.parametrize( - "func, args, kwargs", + 'func, args, kwargs', [ - pytest.param("full_like", + pytest.param('full_like', ['x0'], {'fill_value': 5}), - pytest.param("ones_like", + pytest.param('ones_like', ['x0'], {}), - pytest.param("zeros_like", + pytest.param('zeros_like', ['x0'], {}), - pytest.param("tril", + pytest.param('tril', ['x0.reshape((2,2))'], {}), - pytest.param("triu", + pytest.param('triu', ['x0.reshape((2,2))'], {}), - pytest.param("linspace", + pytest.param('linspace', ['x0', '4', '4'], {}), - pytest.param("linspace", + pytest.param('linspace', ['1', 'x0', '4'], {}) ]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_array_creation_follow_device(func, args, kwargs, device): @@ -185,33 +185,33 @@ def test_array_creation_follow_device(func, args, kwargs, device): @pytest.mark.parametrize( - "func, args, kwargs", + 'func, args, kwargs', [ - pytest.param("full_like", + pytest.param('full_like', ['x0'], {'fill_value': 5}), - pytest.param("ones_like", + pytest.param('ones_like', ['x0'], {}), - pytest.param("zeros_like", + pytest.param('zeros_like', ['x0'], {}), - pytest.param("linspace", + pytest.param('linspace', ['x0', '4', '4'], {}), - pytest.param("linspace", + pytest.param('linspace', ['1', 'x0', '4'], {}) ]) -@pytest.mark.parametrize("device_x", +@pytest.mark.parametrize('device_x', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("device_y", +@pytest.mark.parametrize('device_y', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_array_creation_cross_device(func, args, kwargs, device_x, device_y): if func is 'linspace' and is_win_platform(): - pytest.skip("CPU driver experiences an instability on Windows.") + pytest.skip('CPU driver experiences an instability on Windows.') x_orig = numpy.array([1, 2, 3, 4]) numpy_args = [eval(val, {'x0' : x_orig}) for val in args] @@ -229,10 +229,10 @@ def test_array_creation_cross_device(func, args, kwargs, device_x, device_y): assert_sycl_queue_equal(y.sycl_queue, x.to_device(device_y).sycl_queue) -@pytest.mark.parametrize("device_x", +@pytest.mark.parametrize('device_x', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("device_y", +@pytest.mark.parametrize('device_y', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_meshgrid(device_x, device_y): @@ -243,57 +243,57 @@ def test_meshgrid(device_x, device_y): assert_sycl_queue_equal(z[1].sycl_queue, y.sycl_queue) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @pytest.mark.parametrize( - "func,data", + 'func,data', [ - pytest.param("abs", + pytest.param('abs', [-1.2, 1.2]), - pytest.param("ceil", + pytest.param('ceil', [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), - pytest.param("conjugate", + pytest.param('conjugate', [[1.+1.j, 0.], [0., 1.+1.j]]), - pytest.param("copy", + pytest.param('copy', [1., 2., 3.]), - pytest.param("cumprod", + pytest.param('cumprod', [[1., 2., 3.], [4., 5., 6.]]), - pytest.param("cumsum", + pytest.param('cumsum', [[1., 2., 3.], [4., 5., 6.]]), - pytest.param("diff", + pytest.param('diff', [1., 2., 4., 7., 0.]), - pytest.param("ediff1d", + pytest.param('ediff1d', [1., 2., 4., 7., 0.]), - pytest.param("fabs", + pytest.param('fabs', [-1.2, 1.2]), - pytest.param("floor", + pytest.param('floor', [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), - pytest.param("gradient", + pytest.param('gradient', [1., 2., 4., 7., 11., 16.]), - pytest.param("nancumprod", + pytest.param('nancumprod', [1., dpnp.nan]), - pytest.param("nancumsum", + pytest.param('nancumsum', [1., dpnp.nan]), - pytest.param("nanprod", + pytest.param('nanprod', [1., dpnp.nan]), - pytest.param("nansum", + pytest.param('nansum', [1., dpnp.nan]), - pytest.param("negative", + pytest.param('negative', [1., -1.]), - pytest.param("prod", + pytest.param('prod', [1., 2.]), - pytest.param("sign", + pytest.param('sign', [-5., 4.5]), - pytest.param("sqrt", + pytest.param('sqrt', [1., 3., 9.]), - pytest.param("sum", + pytest.param('sum', [1., 2.]), - pytest.param("trapz", + pytest.param('trapz', [[0., 1., 2.], [3., 4., 5.]]), - pytest.param("trunc", + pytest.param('trunc', [-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]), ], ) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_1in_1out(func, data, device): @@ -312,56 +312,56 @@ def test_1in_1out(func, data, device): @pytest.mark.parametrize( - "func,data1,data2", + 'func,data1,data2', [ - pytest.param("add", + pytest.param('add', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), - pytest.param("copysign", + pytest.param('copysign', [0., 1., 2.], [-1., 0., 1.]), - pytest.param("cross", + pytest.param('cross', [1., 2., 3.], [4., 5., 6.]), - pytest.param("divide", + pytest.param('divide', [0., 1., 2., 3., 4.], [4., 4., 4., 4., 4.]), - pytest.param("dot", + pytest.param('dot', [[0., 1., 2.], [3., 4., 5.]], [[4., 4.], [4., 4.], [4., 4.]]), - pytest.param("floor_divide", + pytest.param('floor_divide', [1., 2., 3., 4.], [2.5, 2.5, 2.5, 2.5]), - pytest.param("fmod", + pytest.param('fmod', [-3., -2., -1., 1., 2., 3.], [2., 2., 2., 2., 2., 2.]), - pytest.param("matmul", + pytest.param('matmul', [[1., 0.], [0., 1.]], [[4., 1.], [1., 2.]]), - pytest.param("maximum", + pytest.param('maximum', [2., 3., 4.], [1., 5., 2.]), - pytest.param("minimum", + pytest.param('minimum', [2., 3., 4.], [1., 5., 2.]), - pytest.param("multiply", + pytest.param('multiply', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), - pytest.param("outer", + pytest.param('outer', [0., 1., 2., 3., 4., 5.], [0., 1., 2., 0.]), - pytest.param("power", + pytest.param('power', [0., 1., 2., 3., 4., 5.], [1., 2., 3., 3., 2., 1.]), - pytest.param("remainder", + pytest.param('remainder', [0., 1., 2., 3., 4., 5., 6.], [5., 5., 5., 5., 5., 5., 5.]), - pytest.param("subtract", + pytest.param('subtract', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), ], ) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_2in_1out(func, data1, data2, device): @@ -380,32 +380,32 @@ def test_2in_1out(func, data1, data2, device): @pytest.mark.parametrize( - "func,data1,data2", + 'func,data1,data2', [ - pytest.param("add", + pytest.param('add', [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], [0., 1., 2.]), - pytest.param("divide", + pytest.param('divide', [0., 1., 2., 3., 4.], [4.]), - pytest.param("floor_divide", + pytest.param('floor_divide', [1., 2., 3., 4.], [2.5]), - pytest.param("fmod", + pytest.param('fmod', [-3., -2., -1., 1., 2., 3.], [2.]), - pytest.param("multiply", + pytest.param('multiply', [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], [0., 1., 2.]), - pytest.param("remainder", + pytest.param('remainder', [0., 1., 2., 3., 4., 5., 6.], [5.]), - pytest.param("subtract", + pytest.param('subtract', [[0., 1., 2.], [3., 4., 5.], [6., 7., 8.]], [0., 1., 2.]), ], ) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_broadcasting(func, data1, data2, device): @@ -425,10 +425,10 @@ def test_broadcasting(func, data1, data2, device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("func", ["add", "copysign", "divide", "floor_divide", "fmod", - "maximum", "minimum", "multiply", "outer", "power", - "remainder", "subtract"]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('func', ['add', 'copysign', 'divide', 'floor_divide', 'fmod', + 'maximum', 'minimum', 'multiply', 'outer', 'power', + 'remainder', 'subtract']) +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_2in_1out_diff_queue_but_equal_context(func, device): @@ -439,36 +439,36 @@ def test_2in_1out_diff_queue_but_equal_context(func, device): @pytest.mark.parametrize( - "func, kwargs", + 'func, kwargs', [ - pytest.param("normal", + pytest.param('normal', {'loc': 1.0, 'scale': 3.4, 'size': (5, 12)}), - pytest.param("rand", + pytest.param('rand', {'d0': 20}), - pytest.param("randint", + pytest.param('randint', {'low': 2, 'high': 15, 'size': (4, 8, 16), 'dtype': dpnp.int32}), - pytest.param("randn", + pytest.param('randn', {'d0': 20}), - pytest.param("random", + pytest.param('random', {'size': (35, 45)}), - pytest.param("random_integers", + pytest.param('random_integers', {'low': -17, 'high': 3, 'size': (12, 16)}), - pytest.param("random_sample", + pytest.param('random_sample', {'size': (7, 7)}), - pytest.param("ranf", + pytest.param('ranf', {'size': (10, 7, 12)}), - pytest.param("sample", + pytest.param('sample', {'size': (7, 9)}), - pytest.param("standard_normal", + pytest.param('standard_normal', {'size': (4, 4, 8)}), - pytest.param("uniform", + pytest.param('uniform', {'low': 1.0, 'high': 2.0, 'size': (4, 2, 5)}) ]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("usm_type", - ["host", "device", "shared"]) +@pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared']) def test_random(func, kwargs, device, usm_type): kwargs = {**kwargs, 'device': device, 'usm_type': usm_type} @@ -477,7 +477,7 @@ def test_random(func, kwargs, device, usm_type): assert device == res_array.sycl_device assert usm_type == res_array.usm_type - sycl_queue = dpctl.SyclQueue(device, property="in_order") + sycl_queue = dpctl.SyclQueue(device, property='in_order') kwargs['device'] = None kwargs['sycl_queue'] = sycl_queue @@ -488,35 +488,35 @@ def test_random(func, kwargs, device, usm_type): @pytest.mark.parametrize( - "func, args, kwargs", + 'func, args, kwargs', [ - pytest.param("normal", + pytest.param('normal', [], {'loc': 1.0, 'scale': 3.4, 'size': (5, 12)}), - pytest.param("rand", + pytest.param('rand', [15, 30, 5], {}), - pytest.param("randint", + pytest.param('randint', [], {'low': 2, 'high': 15, 'size': (4, 8, 16), 'dtype': dpnp.int32}), - pytest.param("randn", + pytest.param('randn', [20, 5, 40], {}), - pytest.param("random_sample", + pytest.param('random_sample', [], {'size': (7, 7)}), - pytest.param("standard_normal", + pytest.param('standard_normal', [], {'size': (4, 4, 8)}), - pytest.param("uniform", + pytest.param('uniform', [], {'low': 1.0, 'high': 2.0, 'size': (4, 2, 5)}) ]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("usm_type", - ["host", "device", "shared"]) +@pytest.mark.parametrize('usm_type', + ['host', 'device', 'shared']) def test_random_state(func, args, kwargs, device, usm_type): kwargs = {**kwargs, 'usm_type': usm_type} @@ -526,7 +526,7 @@ def test_random_state(func, args, kwargs, device, usm_type): assert device == res_array.sycl_device assert usm_type == res_array.usm_type - sycl_queue = dpctl.SyclQueue(device, property="in_order") + sycl_queue = dpctl.SyclQueue(device, property='in_order') # test with in-order SYCL queue per a device and passed as argument seed = (147, 56, 896) if device.is_cpu else 987654 @@ -536,15 +536,15 @@ def test_random_state(func, args, kwargs, device, usm_type): assert_sycl_queue_equal(res_array.sycl_queue, sycl_queue) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @pytest.mark.parametrize( - "func,data", + 'func,data', [ - pytest.param("sqrt", + pytest.param('sqrt', [0., 1., 2., 3., 4., 5., 6., 7., 8.]), ], ) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_out_1in_1out(func, data, device): @@ -563,49 +563,49 @@ def test_out_1in_1out(func, data, device): assert_sycl_queue_equal(result.sycl_queue, x.sycl_queue) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @pytest.mark.parametrize( - "func,data1,data2", + 'func,data1,data2', [ - pytest.param("add", + pytest.param('add', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), - pytest.param("copysign", + pytest.param('copysign', [0., 1., 2.], [-1., 0., 1.]), - pytest.param("divide", + pytest.param('divide', [0., 1., 2., 3., 4.], [4., 4., 4., 4., 4.]), - pytest.param("dot", + pytest.param('dot', [[0., 1., 2.], [3., 4., 5.]], [[4., 4.], [4., 4.], [4., 4.]]), - pytest.param("floor_divide", + pytest.param('floor_divide', [1., 2., 3., 4.], [2.5, 2.5, 2.5, 2.5]), - pytest.param("fmod", + pytest.param('fmod', [-3., -2., -1., 1., 2., 3.], [2., 2., 2., 2., 2., 2.]), - pytest.param("maximum", + pytest.param('maximum', [2., 3., 4.], [1., 5., 2.]), - pytest.param("minimum", + pytest.param('minimum', [2., 3., 4.], [1., 5., 2.]), - pytest.param("multiply", + pytest.param('multiply', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), - pytest.param("power", + pytest.param('power', [0., 1., 2., 3., 4., 5.], [1., 2., 3., 3., 2., 1.]), - pytest.param("remainder", + pytest.param('remainder', [0., 1., 2., 3., 4., 5., 6.], [5., 5., 5., 5., 5., 5., 5.]), - pytest.param("subtract", + pytest.param('subtract', [0., 1., 2., 3., 4., 5., 6., 7., 8.], [0., 1., 2., 0., 1., 2., 0., 1., 2.]), ], ) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_out_2in_1out(func, data1, data2, device): @@ -627,7 +627,7 @@ def test_out_2in_1out(func, data1, data2, device): assert_sycl_queue_equal(result.sycl_queue, x2.sycl_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_modf(device): @@ -650,8 +650,8 @@ def test_modf(device): assert_sycl_queue_equal(result2_queue, expected_queue) -@pytest.mark.parametrize("type", ['complex128']) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('type', ['complex128']) +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_fft(type, device): @@ -670,9 +670,9 @@ def test_fft(type, device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("type", ['float32']) -@pytest.mark.parametrize("shape", [(8,8)]) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('type', ['float32']) +@pytest.mark.parametrize('shape', [(8,8)]) +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_fft_rfft(type, shape, device): @@ -691,7 +691,7 @@ def test_fft_rfft(type, shape, device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_cholesky(device): @@ -709,7 +709,7 @@ def test_cholesky(device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_det(device): @@ -727,8 +727,8 @@ def test_det(device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("device", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_eig(device): @@ -773,8 +773,8 @@ def test_eig(device): assert_sycl_queue_equal(dpnp_vec_queue, expected_queue) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") -@pytest.mark.parametrize("device", +@pytest.mark.usefixtures('allow_fall_back_on_numpy') +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_eigh(device): @@ -805,7 +805,7 @@ def test_eigh(device): assert_sycl_queue_equal(dpnp_vec_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_eigvals(device): @@ -826,7 +826,7 @@ def test_eigvals(device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_inv(device): @@ -844,7 +844,7 @@ def test_inv(device): assert_sycl_queue_equal(result_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_matrix_rank(device): @@ -857,7 +857,7 @@ def test_matrix_rank(device): numpy.testing.assert_array_equal(expected, result) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_qr(device): @@ -866,8 +866,8 @@ def test_qr(device): numpy_data = numpy.array(data) dpnp_data = dpnp.array(data, device=device) - np_q, np_r = numpy.linalg.qr(numpy_data, "reduced") - dpnp_q, dpnp_r = dpnp.linalg.qr(dpnp_data, "reduced") + np_q, np_r = numpy.linalg.qr(numpy_data, 'reduced') + dpnp_q, dpnp_r = dpnp.linalg.qr(dpnp_data, 'reduced') assert (dpnp_q.dtype == np_q.dtype) assert (dpnp_r.dtype == np_r.dtype) @@ -886,7 +886,7 @@ def test_qr(device): assert_sycl_queue_equal(dpnp_r_queue, expected_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_svd(device): @@ -933,10 +933,10 @@ def test_svd(device): assert_sycl_queue_equal(dpnp_vt_queue, expected_queue) -@pytest.mark.parametrize("device_from", +@pytest.mark.parametrize('device_from', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("device_to", +@pytest.mark.parametrize('device_to', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_to_device(device_from, device_to): @@ -948,35 +948,35 @@ def test_to_device(device_from, device_to): assert y.get_array().sycl_device == device_to -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("func", - ["array", "asarray"]) -@pytest.mark.parametrize("device_param", - ["", "None", "sycl_device"], - ids=['Empty', 'None', "device"]) -@pytest.mark.parametrize("queue_param", - ["", "None", "sycl_queue"], - ids=['Empty', 'None', "queue"]) +@pytest.mark.parametrize('func', + ['array', 'asarray']) +@pytest.mark.parametrize('device_param', + ['', 'None', 'sycl_device'], + ids=['Empty', 'None', 'device']) +@pytest.mark.parametrize('queue_param', + ['', 'None', 'sycl_queue'], + ids=['Empty', 'None', 'queue']) def test_array_copy(device, func, device_param, queue_param): data = numpy.ones(100) dpnp_data = getattr(dpnp, func)(data, device=device) kwargs_items = {'device': device_param, 'sycl_queue': queue_param}.items() - kwargs = {k: getattr(dpnp_data, v, None) for k,v in kwargs_items if v != ""} + kwargs = {k: getattr(dpnp_data, v, None) for k,v in kwargs_items if v != ''} result = dpnp.array(dpnp_data, **kwargs) assert_sycl_queue_equal(result.sycl_queue, dpnp_data.sycl_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) #TODO need to delete no_bool=True when use dlpack > 0.7 version -@pytest.mark.parametrize("arr_dtype", get_all_dtypes(no_float16=True, no_bool=True)) -@pytest.mark.parametrize("shape", [tuple(), (2,), (3, 0, 1), (2, 2, 2)]) +@pytest.mark.parametrize('arr_dtype', get_all_dtypes(no_float16=True, no_bool=True)) +@pytest.mark.parametrize('shape', [tuple(), (2,), (3, 0, 1), (2, 2, 2)]) def test_from_dlpack(arr_dtype, shape, device): X = dpnp.empty(shape=shape, dtype=arr_dtype, device=device) Y = dpnp.from_dlpack(X) @@ -990,10 +990,10 @@ def test_from_dlpack(arr_dtype, shape, device): assert V.strides == W.strides -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("arr_dtype", get_all_dtypes(no_float16=True)) +@pytest.mark.parametrize('arr_dtype', get_all_dtypes(no_float16=True)) def test_from_dlpack_with_dpt(arr_dtype, device): X = dpctl.tensor.empty((64,), dtype=arr_dtype, device=device) Y = dpnp.from_dlpack(X) @@ -1004,7 +1004,7 @@ def test_from_dlpack_with_dpt(arr_dtype, device): assert_sycl_queue_equal(X.sycl_queue, Y.sycl_queue) -@pytest.mark.parametrize("device", +@pytest.mark.parametrize('device', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_broadcast_to(device): @@ -1013,10 +1013,10 @@ def test_broadcast_to(device): assert_sycl_queue_equal(x.sycl_queue, y.sycl_queue) -@pytest.mark.parametrize("device_x", +@pytest.mark.parametrize('device_x', valid_devices, ids=[device.filter_string for device in valid_devices]) -@pytest.mark.parametrize("device_y", +@pytest.mark.parametrize('device_y', valid_devices, ids=[device.filter_string for device in valid_devices]) def test_asarray(device_x, device_y): diff --git a/tests/test_umath.py b/tests/test_umath.py index 7b5c4b762d8..0d95066afad 100644 --- a/tests/test_umath.py +++ b/tests/test_umath.py @@ -67,7 +67,7 @@ def get_id(val): return val.__str__() -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @pytest.mark.parametrize('test_cases', test_cases, ids=get_id) def test_umaths(test_cases): umath, args_str = test_cases @@ -100,7 +100,7 @@ def test_sin_ordinary(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -111,7 +111,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.sin(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -140,7 +140,7 @@ def test_cos(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -151,7 +151,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.cos(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -180,7 +180,7 @@ def test_log(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -191,7 +191,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.log(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -220,7 +220,7 @@ def test_exp(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -231,7 +231,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.exp(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -260,7 +260,7 @@ def test_arcsin(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -271,7 +271,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.arcsin(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -300,7 +300,7 @@ def test_arctan(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -311,7 +311,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.arctan(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -340,7 +340,7 @@ def test_tan(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.float32, numpy.int64, numpy.int32], ids=['numpy.float32', 'numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -351,7 +351,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.tan(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -379,7 +379,7 @@ def test_arctan2(self): assert_array_equal(expected, result) - @pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) + @pytest.mark.parametrize('dtype', get_all_dtypes(no_bool=True, no_complex=True, no_none=True)) def test_out_dtypes(self, dtype): size = 2 if dtype == dpnp.bool else 10 @@ -393,7 +393,7 @@ def test_out_dtypes(self, dtype): assert_allclose(expected, result) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -406,7 +406,7 @@ def test_invalid_shape(self, shape): class TestSqrt: - @pytest.mark.parametrize("dtype", get_float_dtypes()) + @pytest.mark.parametrize('dtype', get_float_dtypes()) def test_sqrt_ordinary(self, dtype): array_data = numpy.arange(10) out = numpy.empty(10, dtype=dtype) @@ -423,7 +423,7 @@ def test_sqrt_ordinary(self, dtype): numpy.testing.assert_allclose(expected, result) numpy.testing.assert_allclose(out, dp_out) - @pytest.mark.parametrize("dtype", + @pytest.mark.parametrize('dtype', [numpy.int64, numpy.int32], ids=['numpy.int64', 'numpy.int32']) def test_invalid_dtype(self, dtype): @@ -434,7 +434,7 @@ def test_invalid_dtype(self, dtype): with pytest.raises(ValueError): dpnp.sqrt(dp_array, out=dp_out) - @pytest.mark.parametrize("shape", + @pytest.mark.parametrize('shape', [(0,), (15, ), (2, 2)], ids=['(0,)', '(15, )', '(2,2)']) def test_invalid_shape(self, shape): @@ -445,7 +445,7 @@ def test_invalid_shape(self, shape): with pytest.raises(ValueError): dpnp.sqrt(dp_array, out=dp_out) - @pytest.mark.parametrize("out", + @pytest.mark.parametrize('out', [4, (), [], (3, 7), [2, 4]], ids=['4', '()', '[]', '(3, 7)', '[2, 4]']) def test_invalid_out(self, out): diff --git a/tests/test_usm_type.py b/tests/test_usm_type.py index 61145de42c7..d57bae6dbaf 100644 --- a/tests/test_usm_type.py +++ b/tests/test_usm_type.py @@ -5,14 +5,14 @@ import dpctl.utils as du list_of_usm_types = [ - "device", - "shared", - "host" + 'device', + 'shared', + 'host' ] -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_sum(usm_type_x, usm_type_y): x = dp.arange(1000, usm_type = usm_type_x) y = dp.arange(1000, usm_type = usm_type_y) @@ -28,8 +28,8 @@ def test_coerced_usm_types_sum(usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_mul(usm_type_x, usm_type_y): x = dp.arange(10, usm_type = usm_type_x) y = dp.arange(10, usm_type = usm_type_y) @@ -45,8 +45,8 @@ def test_coerced_usm_types_mul(usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_subtract(usm_type_x, usm_type_y): x = dp.arange(50, usm_type = usm_type_x) y = dp.arange(50, usm_type = usm_type_y) @@ -62,8 +62,8 @@ def test_coerced_usm_types_subtract(usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_divide(usm_type_x, usm_type_y): x = dp.arange(120, usm_type = usm_type_x) y = dp.arange(120, usm_type = usm_type_y) @@ -79,8 +79,8 @@ def test_coerced_usm_types_divide(usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_power(usm_type_x, usm_type_y): x = dp.arange(70, usm_type = usm_type_x).reshape((7, 5, 2)) y = dp.arange(70, usm_type = usm_type_y).reshape((7, 5, 2)) @@ -95,25 +95,25 @@ def test_coerced_usm_types_power(usm_type_x, usm_type_y): @pytest.mark.parametrize( - "func, args", + 'func, args', [ - pytest.param("full", + pytest.param('full', ['10', 'x0[3]']), - pytest.param("full_like", + pytest.param('full_like', ['x0', '4']), - pytest.param("zeros_like", + pytest.param('zeros_like', ['x0']), - pytest.param("ones_like", + pytest.param('ones_like', ['x0']), - pytest.param("empty_like", + pytest.param('empty_like', ['x0']), - pytest.param("linspace", + pytest.param('linspace', ['x0[0:2]', '4', '4']), - pytest.param("linspace", + pytest.param('linspace', ['0', 'x0[3:5]', '4']), ]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_array_creation(func, args, usm_type_x, usm_type_y): x0 = dp.full(10, 3, usm_type=usm_type_x) new_args = [eval(val, {'x0' : x0}) for val in args] @@ -125,8 +125,8 @@ def test_array_creation(func, args, usm_type_x, usm_type_y): assert y.usm_type == usm_type_y -@pytest.mark.parametrize("usm_type_start", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_stop", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_start', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_stop', list_of_usm_types, ids=list_of_usm_types) def test_linspace_arrays(usm_type_start, usm_type_stop): start = dp.asarray([0, 0], usm_type=usm_type_start) stop = dp.asarray([2, 4], usm_type=usm_type_stop) @@ -134,21 +134,21 @@ def test_linspace_arrays(usm_type_start, usm_type_stop): assert res.usm_type == du.get_coerced_usm_type([usm_type_start, usm_type_stop]) -@pytest.mark.parametrize("func", ["tril", "triu"], ids=["tril", "triu"]) -@pytest.mark.parametrize("usm_type", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('func', ['tril', 'triu'], ids=['tril', 'triu']) +@pytest.mark.parametrize('usm_type', list_of_usm_types, ids=list_of_usm_types) def test_tril_triu(func, usm_type): x0 = dp.ones((3,3), usm_type=usm_type) x = getattr(dp, func)(x0) assert x.usm_type == usm_type -@pytest.mark.parametrize("op", +@pytest.mark.parametrize('op', ['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal'], ids=['equal', 'greater', 'greater_equal', 'less', 'less_equal', 'logical_and', 'logical_or', 'logical_xor', 'not_equal']) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_logic_op(op, usm_type_x, usm_type_y): x = dp.arange(100, usm_type = usm_type_x) y = dp.arange(100, usm_type = usm_type_y)[::-1] @@ -162,11 +162,11 @@ def test_coerced_usm_types_logic_op(op, usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("op", +@pytest.mark.parametrize('op', ['bitwise_and', 'bitwise_or', 'bitwise_xor', 'left_shift', 'right_shift'], ids=['bitwise_and', 'bitwise_or', 'bitwise_xor', 'left_shift', 'right_shift']) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_coerced_usm_types_bitwise_op(op, usm_type_x, usm_type_y): x = dp.arange(25, usm_type = usm_type_x) y = dp.arange(25, usm_type = usm_type_y)[::-1] @@ -180,8 +180,8 @@ def test_coerced_usm_types_bitwise_op(op, usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_meshgrid(usm_type_x, usm_type_y): x = dp.arange(100, usm_type = usm_type_x) y = dp.arange(100, usm_type = usm_type_y) @@ -191,15 +191,15 @@ def test_meshgrid(usm_type_x, usm_type_y): @pytest.mark.parametrize( - "func,data", + 'func,data', [ pytest.param( - "sqrt", + 'sqrt', [1.0, 3.0, 9.0], ), ], ) -@pytest.mark.parametrize("usm_type", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type', list_of_usm_types, ids=list_of_usm_types) def test_1in_1out(func, data, usm_type): x = dp.array(data, usm_type=usm_type) res = getattr(dp, func)(x) @@ -208,15 +208,15 @@ def test_1in_1out(func, data, usm_type): @pytest.mark.parametrize( - "func,data1,data2", + 'func,data1,data2', [ - pytest.param("dot", + pytest.param('dot', [[0., 1., 2.], [3., 4., 5.]], [[4., 4.], [4., 4.], [4., 4.]]), ], ) -@pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) -@pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_x', list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type_y', list_of_usm_types, ids=list_of_usm_types) def test_2in_1out(func, data1, data2, usm_type_x, usm_type_y): x = dp.array(data1, usm_type = usm_type_x) y = dp.array(data2, usm_type = usm_type_y) @@ -227,7 +227,7 @@ def test_2in_1out(func, data1, data2, usm_type_x, usm_type_y): assert z.usm_type == du.get_coerced_usm_type([usm_type_x, usm_type_y]) -@pytest.mark.parametrize("usm_type", list_of_usm_types, ids=list_of_usm_types) +@pytest.mark.parametrize('usm_type', list_of_usm_types, ids=list_of_usm_types) def test_broadcast_to(usm_type): x = dp.ones(7, usm_type=usm_type) y = dp.broadcast_to(x, (2, 7)) diff --git a/tests/tests_perf/data_generator.py b/tests/tests_perf/data_generator.py old mode 100644 new mode 100755 index bf568d7f610..2fdd00d44fa --- a/tests/tests_perf/data_generator.py +++ b/tests/tests_perf/data_generator.py @@ -31,8 +31,8 @@ __all__ = [ - "gen_array_1d", - "gen_array_2d" + 'gen_array_1d', + 'gen_array_2d' ] @@ -70,7 +70,7 @@ def gen_ndarray(size, dtype=numpy.float64, low=None, high=None, seed=None): return numpy.random.randint(low, high, size=size, dtype=dtype) - raise NotImplementedError(f"Generator of ndarray of type {dtype.__name__} not found.") + raise NotImplementedError(f'Generator of ndarray of type {dtype.__name__} not found.') def gen_dparray(size, dtype=numpy.float64, low=None, high=None, seed=None): @@ -134,7 +134,7 @@ def gen_array_1d(lib, size, dtype=numpy.float64, low=None, high=None, seed=None) if lib is dpnp: return gen_dparray(size, dtype=dtype, low=low, high=high, seed=seed) - raise NotImplementedError(f"{lib.__name__} array generator not found.") + raise NotImplementedError(f'{lib.__name__} array generator not found.') def gen_array_2d(lib, size_x, size_y, dtype=numpy.float64, low=None, high=None, seed=None): diff --git a/tests/tests_perf/examples/sinAB_test.py b/tests/tests_perf/examples/sinAB_test.py index 52e2b2ada6f..f2b1bf0710a 100644 --- a/tests/tests_perf/examples/sinAB_test.py +++ b/tests/tests_perf/examples/sinAB_test.py @@ -25,7 +25,7 @@ def cos_2_args(executor, size, test_type): end_time = time.perf_counter() calculation_time = end_time - start_time - print(f"memalloc_time={memalloc_time}, calculation_time={calculation_time}, executor={executor}") + print(f'memalloc_time={memalloc_time}, calculation_time={calculation_time}, executor={executor}') return result diff --git a/tests/tests_perf/math_tests/test_black_scholes.py b/tests/tests_perf/math_tests/test_black_scholes.py index fdfcccc1580..a6587f969a2 100644 --- a/tests/tests_perf/math_tests/test_black_scholes.py +++ b/tests/tests_perf/math_tests/test_black_scholes.py @@ -44,14 +44,14 @@ def black_scholes_put(lib, S, K, T, r, sigma): class TestBlackScholes(DPNPTestPerfBase): - @pytest.mark.parametrize("dtype", [numpy.float64]) - @pytest.mark.parametrize("size", [1024, 2048, 4096, 8192]) + @pytest.mark.parametrize('dtype', [numpy.float64]) + @pytest.mark.parametrize('size', [1024, 2048, 4096, 8192]) def test_bs_put(self, lib, dtype, size): numpy.random.seed(SEED) S = gen_data(lib, SL, SH, size) K = gen_data(lib, KL, KH, size) T = gen_data(lib, TL, TH, size) - self.dpnp_benchmark("bs_put", lib, dtype, size, + self.dpnp_benchmark('bs_put', lib, dtype, size, lib, S, K, T, RISK_FREE, VOLATILITY, custom_fptr=black_scholes_put) diff --git a/tests/tests_perf/math_tests/test_dpnp.py b/tests/tests_perf/math_tests/test_dpnp.py index 4c291d4aec2..8d8b15a303d 100644 --- a/tests/tests_perf/math_tests/test_dpnp.py +++ b/tests/tests_perf/math_tests/test_dpnp.py @@ -8,10 +8,10 @@ class TestDPNP(DPNPTestPerfBase): - @pytest.mark.parametrize("dtype", [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) - @pytest.mark.parametrize("size", [32, 64, 128, 256]) # , 512, 1024, 2048, 4096]) + @pytest.mark.parametrize('dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) + @pytest.mark.parametrize('size', [32, 64, 128, 256]) # , 512, 1024, 2048, 4096]) def test_matmul(self, lib, dtype, size): input1 = gen_array_2d(lib, size, size, dtype=dtype, seed=self.seed) input2 = gen_array_2d(lib, size, size, dtype=dtype, seed=self.seed) - self.dpnp_benchmark("matmul", lib, dtype, input1.size, input1, input2) + self.dpnp_benchmark('matmul', lib, dtype, input1.size, input1, input2) diff --git a/tests/tests_perf/math_tests/test_mathematical.py b/tests/tests_perf/math_tests/test_mathematical.py index 0f5382cff51..0bc901e2806 100644 --- a/tests/tests_perf/math_tests/test_mathematical.py +++ b/tests/tests_perf/math_tests/test_mathematical.py @@ -7,9 +7,9 @@ class TestDPNPMathematical(DPNPTestPerfBase): - @pytest.mark.parametrize("func_name", ["add", "divide", "multiply", "subtract"]) - @pytest.mark.parametrize("dtype", [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) - @pytest.mark.parametrize("size", [512, 1024, 2048, 4096, 8192, 16384, 32768]) + @pytest.mark.parametrize('func_name', ['add', 'divide', 'multiply', 'subtract']) + @pytest.mark.parametrize('dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) + @pytest.mark.parametrize('size', [512, 1024, 2048, 4096, 8192, 16384, 32768]) def test_math_2args(self, func_name, lib, dtype, size): input1 = gen_array_1d(lib, size, dtype=dtype, seed=self.seed) input2 = gen_array_1d(lib, size, dtype=dtype, seed=self.seed) diff --git a/tests/tests_perf/math_tests/test_trigonometric.py b/tests/tests_perf/math_tests/test_trigonometric.py index db1d90aa1b6..1c27e96fa3e 100644 --- a/tests/tests_perf/math_tests/test_trigonometric.py +++ b/tests/tests_perf/math_tests/test_trigonometric.py @@ -21,19 +21,19 @@ def cos_2_args(input_A, input_B, lib): class TestDPNPTrigonometric(DPNPTestPerfBase): - @pytest.mark.parametrize("func_name", ["arccos", "arccosh", "arcsin", "arcsinh", "arctan", "arctanh", - "cbrt", "cos", "cosh", "deg2rad", "degrees", "exp", "exp2", - "expm1", "log", "log10", "log1p", "log2", "rad2deg", "radians", - "reciprocal", "sin", "sinh", "sqrt", "square", "tan", "tanh"]) - @pytest.mark.parametrize("dtype", [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) - @pytest.mark.parametrize("size", [512, 1024, 2048, 4096, 8192, 16384, 32768]) + @pytest.mark.parametrize('func_name', ['arccos', 'arccosh', 'arcsin', 'arcsinh', 'arctan', 'arctanh', + 'cbrt', 'cos', 'cosh', 'deg2rad', 'degrees', 'exp', 'exp2', + 'expm1', 'log', 'log10', 'log1p', 'log2', 'rad2deg', 'radians', + 'reciprocal', 'sin', 'sinh', 'sqrt', 'square', 'tan', 'tanh']) + @pytest.mark.parametrize('dtype', [numpy.float64, numpy.float32, numpy.int64, numpy.int32]) + @pytest.mark.parametrize('size', [512, 1024, 2048, 4096, 8192, 16384, 32768]) def test_trig1(self, func_name, lib, dtype, size): input1 = gen_array_1d(lib, size, dtype=dtype, seed=self.seed) self.dpnp_benchmark(func_name, lib, dtype, input1.size, input1) - @pytest.mark.parametrize("dtype", [numpy.float64]) - @pytest.mark.parametrize("size", [16777216]) + @pytest.mark.parametrize('dtype', [numpy.float64]) + @pytest.mark.parametrize('size', [16777216]) def test_app1(self, lib, dtype, size): """ /opt/intel/oneapi/vtune/2021.1-beta10/bin64/vtune -collect gpu-offload @@ -45,4 +45,4 @@ def test_app1(self, lib, dtype, size): input1 = gen_array_1d(lib, size, dtype=dtype, seed=self.seed) input2 = gen_array_1d(lib, size, dtype=dtype, seed=self.seed) - self.dpnp_benchmark("cos_2_args", lib, dtype, input1.size, input1, input2, lib, custom_fptr=cos_2_args) + self.dpnp_benchmark('cos_2_args', lib, dtype, input1.size, input1, input2, lib, custom_fptr=cos_2_args) diff --git a/tests/tests_perf/test_perf_base.py b/tests/tests_perf/test_perf_base.py old mode 100644 new mode 100755 index 3443b2fd89e..73fe014426b --- a/tests/tests_perf/test_perf_base.py +++ b/tests/tests_perf/test_perf_base.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- 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 @@ -38,12 +38,12 @@ # metafunc.parametrize("lib", [numpy, dpnp], ids=["base", "DPNP"]) -@pytest.mark.parametrize("lib", [dpnp, numpy]) +@pytest.mark.parametrize('lib', [dpnp, numpy]) class DPNPTestPerfBase: seed = 777 repeat = 15 - sep = ":" - results_data = dict() + sep = ':' + results_data = {} print_width = [10, 8, 6, 10] print_num_width = 10 @@ -60,13 +60,13 @@ def add(self, name, lib, dtype, size, result): # Python does not automatically create a dictionary when you use multilevel keys if not self.results_data.get(name, False): - self.results_data[name] = dict() + self.results_data[name] = {} if not self.results_data[name].get(dtype, False): - self.results_data[name][dtype] = dict() + self.results_data[name][dtype] = {} if not self.results_data[name][dtype].get(lib, False): - self.results_data[name][dtype][lib] = dict() + self.results_data[name][dtype][lib] = {} self.results_data[name][dtype][lib][size] = result @@ -108,13 +108,13 @@ def print_head(self): print() pw = self.print_width pwn = self.print_num_width - print(f"Function".center(pw[0]), end=self.sep) - print(f"type".center(pw[1]), end=self.sep) - print(f"lib".center(pw[2]), end=self.sep) - print(f"size".center(pw[3]), end=self.sep) - print(f"median".center(pwn), end=self.sep) - print(f"min".center(pwn), end=self.sep) - print(f"max".center(pwn), end=self.sep) + print(f'Function'.center(pw[0]), end=self.sep) + print(f'type'.center(pw[1]), end=self.sep) + print(f'lib'.center(pw[2]), end=self.sep) + print(f'size'.center(pw[3]), end=self.sep) + print(f'median'.center(pwn), end=self.sep) + print(f'min'.center(pwn), end=self.sep) + print(f'max'.center(pwn), end=self.sep) print() def print_csv(self): @@ -126,30 +126,30 @@ def print_csv(self): for func_name, func_results in self.results_data.items(): for dtype_id, dtype_results in func_results.items(): dtype_id_prn = dtype_id.__name__ - graph_data = dict() + graph_data = {} for lib_id, lib_results in dtype_results.items(): lib_id_prn = lib_id.__name__ - graph_data[lib_id_prn] = {"x": list(), "y": list()} + graph_data[lib_id_prn] = {'x': [], 'y': []} for size, size_results in lib_results.items(): - print(f"{func_name:{pw[0]}}", end=self.sep) - print(f"{dtype_id_prn:{pw[1]}}", end=self.sep) - print(f"{lib_id_prn:{pw[2]}}", end=self.sep) - print(f"{size:{pw[3]}}", end=self.sep) + print(f'{func_name:{pw[0]}}', end=self.sep) + print(f'{dtype_id_prn:{pw[1]}}', end=self.sep) + print(f'{lib_id_prn:{pw[2]}}', end=self.sep) + print(f'{size:{pw[3]}}', end=self.sep) val_min = min(size_results) val_max = max(size_results) val_median = statistics.median(size_results) - print(f"{val_median:{pwn}.2e}", end=self.sep) - print(f"{val_min:{pwn}.2e}", end=self.sep) - print(f"{val_max:{pwn}.2e}", end=self.sep) + print(f'{val_median:{pwn}.2e}', end=self.sep) + print(f'{val_min:{pwn}.2e}', end=self.sep) + print(f'{val_max:{pwn}.2e}', end=self.sep) print() # prepare data for graphs - graph_data[lib_id_prn]["x"].append(size) - graph_data[lib_id_prn]["y"].append(val_median) + graph_data[lib_id_prn]['x'].append(size) + graph_data[lib_id_prn]['y'].append(val_median) self.plot_graph_2lines(self, graph_data, func_name=func_name, lib=lib_id_prn, type=dtype_id_prn) self.plot_graph_ratio(self, func_name, func_results) @@ -160,17 +160,17 @@ def plot_graph_2lines(self, graph_data, func_name, lib, type): plt.suptitle(f"'{func_name}' time in (s)") plt.title(f"for '{type}' data type") - plt.xlabel("number of elements") - plt.ylabel("time(s)") + plt.xlabel('number of elements') + plt.ylabel('time(s)') plt.grid(True) for lib_id, axis in graph_data.items(): - plt.plot(axis["x"], axis["y"], label=lib_id, marker='.') + plt.plot(axis['x'], axis['y'], label=lib_id, marker='.') plt.legend() plt.tight_layout() - plt.savefig("dpnp_perf_" + func_name + "_" + type + ".jpg", dpi=150) + plt.savefig('dpnp_perf_' + func_name + '_' + type + '.jpg', dpi=150) plt.close() def plot_graph_ratio(self, func_name, func_results): @@ -179,8 +179,8 @@ def plot_graph_ratio(self, func_name, func_results): fig, ax = plt.subplots() plt.suptitle(f"Ratio for '{func_name}' time in (s)") - plt.xlabel("number of elements") - plt.ylabel("ratio") + plt.xlabel('number of elements') + plt.ylabel('ratio') ax.spines['bottom'].set_position(('data', 1)) ax.grid(True) @@ -188,7 +188,7 @@ def plot_graph_ratio(self, func_name, func_results): dtype_id_prn = dtype_id.__name__ if (len(dtype_results.keys()) != 2): - warnings.warn(UserWarning("DPNP Performance test: expected two libraries only for this type of graph")) + warnings.warn(UserWarning('DPNP Performance test: expected two libraries only for this type of graph')) plt.close() return @@ -199,8 +199,8 @@ def plot_graph_ratio(self, func_name, func_results): lib_results_1 = dtype_results[lib_id[1]] # import pdb; pdb.set_trace() - val_ratio_x = list() - val_ratio_y = list() + val_ratio_x = [] + val_ratio_y = [] for size in lib_results_0.keys(): lib_results_0_median = statistics.median(lib_results_0[size]) lib_results_1_median = statistics.median(lib_results_1[size]) @@ -212,5 +212,5 @@ def plot_graph_ratio(self, func_name, func_results): ax.legend() plt.tight_layout() - plt.savefig("dpnp_perf_ratio_" + func_name + ".jpg", dpi=150) + plt.savefig('dpnp_perf_ratio_' + func_name + '.jpg', dpi=150) plt.close() diff --git a/tests/third_party/cupy/core_tests/test_ndarray_conversion.py b/tests/third_party/cupy/core_tests/test_ndarray_conversion.py index 2fe8952a56d..f70ea1ed718 100644 --- a/tests/third_party/cupy/core_tests/test_ndarray_conversion.py +++ b/tests/third_party/cupy/core_tests/test_ndarray_conversion.py @@ -12,7 +12,7 @@ {'shape': (1,)}, {'shape': (1, 1, 1)}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestNdarrayItem(unittest.TestCase): @testing.for_all_dtypes() diff --git a/tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py b/tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py index b026377e3e2..ae2ce28ca1a 100644 --- a/tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py +++ b/tests/third_party/cupy/core_tests/test_ndarray_copy_and_view.py @@ -159,14 +159,14 @@ def test_astype_strides_broadcast(self, xp, src_dtype, dst_dtype): return numpy.array( astype_without_warning(src, dst_dtype, order='K').strides) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() def test_diagonal1(self, xp, dtype): a = testing.shaped_arange((3, 4, 5), xp, dtype) return a.diagonal(1, 2, 0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() def test_diagonal2(self, xp, dtype): diff --git a/tests/third_party/cupy/core_tests/test_ndarray_math.py b/tests/third_party/cupy/core_tests/test_ndarray_math.py index 816261517c4..087eeeee0c6 100644 --- a/tests/third_party/cupy/core_tests/test_ndarray_math.py +++ b/tests/third_party/cupy/core_tests/test_ndarray_math.py @@ -10,7 +10,7 @@ @testing.parameterize(*testing.product({ 'decimals': [-2, -1, 0, 1, 2], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestRound(unittest.TestCase): shape = (20,) diff --git a/tests/third_party/cupy/core_tests/test_ndarray_reduction.py b/tests/third_party/cupy/core_tests/test_ndarray_reduction.py index 34275e917cf..4bcc50ad9a5 100644 --- a/tests/third_party/cupy/core_tests/test_ndarray_reduction.py +++ b/tests/third_party/cupy/core_tests/test_ndarray_reduction.py @@ -8,7 +8,7 @@ from tests.third_party.cupy import testing -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestArrayReduction(unittest.TestCase): diff --git a/tests/third_party/cupy/creation_tests/test_from_data.py b/tests/third_party/cupy/creation_tests/test_from_data.py index ce71ef311a5..25b2549c567 100644 --- a/tests/third_party/cupy/creation_tests/test_from_data.py +++ b/tests/third_party/cupy/creation_tests/test_from_data.py @@ -414,7 +414,7 @@ def test_asarray_cuda_array_zero_dim_dtype(self, xp): return xp.ascontiguousarray(a, dtype=numpy.int64) # @testing.for_CF_orders() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_orders('C') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() @@ -454,14 +454,14 @@ def test_asfortranarray_cuda_array_zero_dim_dtype( a = xp.ones((), dtype=dtype_a) return xp.asfortranarray(a, dtype=dtype_b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_fromfile(self, xp): with tempfile.TemporaryFile() as fh: - fh.write(b"\x00\x01\x02\x03\x04") + fh.write(b'\x00\x01\x02\x03\x04') fh.flush() fh.seek(0) - return xp.fromfile(fh, dtype="u1") + return xp.fromfile(fh, dtype='u1') ############################################################################### diff --git a/tests/third_party/cupy/creation_tests/test_matrix.py b/tests/third_party/cupy/creation_tests/test_matrix.py index fe144cbc58c..85a64f56319 100644 --- a/tests/third_party/cupy/creation_tests/test_matrix.py +++ b/tests/third_party/cupy/creation_tests/test_matrix.py @@ -60,19 +60,19 @@ def test_diag_construction_from_tuple(self, xp): self.assertIsInstance(r, xp.ndarray) return r - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_diag_scaler(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.diag(1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_diag_0dim(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.diag(xp.zeros(())) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_diag_3dim(self): for xp in (numpy, cupy): with pytest.raises(ValueError): @@ -93,17 +93,17 @@ def test_diagflat3(self, xp): a = testing.shaped_arange((3, 3), xp) return xp.diagflat(a, -2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_diagflat_from_scalar(self, xp): return xp.diagflat(3) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_diagflat_from_scalar_with_k0(self, xp): return xp.diagflat(3, 0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_diagflat_from_scalar_with_k1(self, xp): return xp.diagflat(3, 1) @@ -140,7 +140,7 @@ def test_tri_posi(self, xp, dtype): {'shape': (2, 3, 4)}, ) @testing.gpu -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestTriLowerAndUpper(unittest.TestCase): @testing.for_all_dtypes(no_complex=True) diff --git a/tests/third_party/cupy/creation_tests/test_ranges.py b/tests/third_party/cupy/creation_tests/test_ranges.py index 11e1d7f9604..0fca48edb63 100644 --- a/tests/third_party/cupy/creation_tests/test_ranges.py +++ b/tests/third_party/cupy/creation_tests/test_ranges.py @@ -206,13 +206,13 @@ def test_linspace_start_stop_list(self, xp, dtype): stop = [100, 16] return xp.linspace(start, stop, num=50, dtype=dtype) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) @testing.numpy_cupy_allclose() def test_logspace(self, xp, dtype): return xp.logspace(0, 2, 5, dtype=dtype) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) @testing.numpy_cupy_allclose() def test_logspace2(self, xp, dtype): @@ -223,29 +223,29 @@ def test_logspace2(self, xp, dtype): def test_logspace_zero_num(self, xp, dtype): return xp.logspace(0, 2, 0, dtype=dtype) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) @testing.numpy_cupy_allclose() def test_logspace_one_num(self, xp, dtype): return xp.logspace(0, 2, 1, dtype=dtype) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) @testing.numpy_cupy_allclose() def test_logspace_no_endpoint(self, xp, dtype): return xp.logspace(0, 2, 5, dtype=dtype, endpoint=False) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_allclose() def test_logspace_no_dtype_int(self, xp): return xp.logspace(0, 2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_allclose() def test_logspace_no_dtype_float(self, xp): return xp.logspace(0.0, 2.0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_allclose() def test_logspace_float_args_with_int_dtype(self, xp): return xp.logspace(0.1, 2.1, 11, dtype=int) @@ -255,7 +255,7 @@ def test_logspace_neg_num(self): with pytest.raises(ValueError): xp.logspace(0, 10, -1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) @testing.numpy_cupy_allclose() def test_logspace_base(self, xp, dtype): diff --git a/tests/third_party/cupy/fft_tests/test_fft.py b/tests/third_party/cupy/fft_tests/test_fft.py index e56a52f7939..8ab17dd3d7e 100644 --- a/tests/third_party/cupy/fft_tests/test_fft.py +++ b/tests/third_party/cupy/fft_tests/test_fft.py @@ -14,7 +14,7 @@ 'shape': [(0,), (10, 0), (10,), (10, 10)], 'norm': [None, 'ortho', ''], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFft(unittest.TestCase): @@ -62,7 +62,7 @@ def test_ifft(self, xp, dtype): {'shape': (3, 4), 's': (0, 5), 'axes': None, 'norm': None}, {'shape': (3, 4), 's': (1, 0), 'axes': None, 'norm': None}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFft2(unittest.TestCase): @@ -111,7 +111,7 @@ def test_ifft2(self, xp, dtype): {'shape': (2, 0, 5), 's': None, 'axes': None, 'norm': None}, {'shape': (0, 0, 5), 's': None, 'axes': None, 'norm': None}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFftn(unittest.TestCase): @@ -139,7 +139,7 @@ def test_ifftn(self, xp, dtype): 'shape': [(10,), (10, 10)], 'norm': [None, 'ortho'], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRfft(unittest.TestCase): @@ -164,7 +164,7 @@ def test_irfft(self, xp, dtype): {'shape': (3, 4), 's': None, 'axes': (), 'norm': None}, {'shape': (2, 3, 4), 's': None, 'axes': (), 'norm': None}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRfft2EmptyAxes(unittest.TestCase): @@ -187,7 +187,7 @@ def test_irfft2(self, dtype): {'shape': (3, 4), 's': None, 'axes': (), 'norm': None}, {'shape': (2, 3, 4), 's': None, 'axes': (), 'norm': None}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRfftnEmptyAxes(unittest.TestCase): @@ -211,7 +211,7 @@ def test_irfftn(self, dtype): 'shape': [(10,), (10, 10)], 'norm': [None, 'ortho'], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestHfft(unittest.TestCase): @@ -237,7 +237,7 @@ def test_ihfft(self, xp, dtype): {'n': 10, 'd': 0.5}, {'n': 100, 'd': 2}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFftfreq(unittest.TestCase): @@ -265,7 +265,7 @@ def test_rfftfreq(self, xp, dtype): {'shape': (10, 10), 'axes': 0}, {'shape': (10, 10), 'axes': (0, 1)}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFftshift(unittest.TestCase): diff --git a/tests/third_party/cupy/indexing_tests/test_generate.py b/tests/third_party/cupy/indexing_tests/test_generate.py index 2bb0404ab59..825cfec77ac 100644 --- a/tests/third_party/cupy/indexing_tests/test_generate.py +++ b/tests/third_party/cupy/indexing_tests/test_generate.py @@ -7,7 +7,7 @@ from tests.third_party.cupy import testing -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestIndices(unittest.TestCase): diff --git a/tests/third_party/cupy/indexing_tests/test_indexing.py b/tests/third_party/cupy/indexing_tests/test_indexing.py index e8292831b74..2896714ae64 100644 --- a/tests/third_party/cupy/indexing_tests/test_indexing.py +++ b/tests/third_party/cupy/indexing_tests/test_indexing.py @@ -10,19 +10,19 @@ @testing.gpu class TestIndexing(unittest.TestCase): - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_take_by_scalar(self, xp): a = testing.shaped_arange((2, 4, 3), xp) return a.take(2, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_external_take_by_scalar(self, xp): a = testing.shaped_arange((2, 4, 3), xp) return xp.take(a, 2, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_take_by_array(self, xp): a = testing.shaped_arange((2, 4, 3), xp) @@ -51,14 +51,14 @@ def test_take_index_range_overflow(self, xp, dtype): b = xp.array([0], dtype=dtype) return a.take(b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_take_along_axis(self, xp): a = testing.shaped_random((2, 4, 3), xp, dtype='float32') b = testing.shaped_random((2, 6, 3), xp, dtype='int64', scale=4) return xp.take_along_axis(a, b, axis=-2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_take_along_axis_none_axis(self, xp): a = testing.shaped_random((2, 4, 3), xp, dtype='float32') @@ -102,7 +102,7 @@ def test_diagonal(self, xp, dtype): a = testing.shaped_arange((3, 4, 5), xp, dtype) return a.diagonal(1, 2, 0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() def test_external_diagonal(self, xp, dtype): @@ -166,7 +166,7 @@ def test_extract_no_bool(self, xp, dtype): b = xp.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]], dtype=dtype) return xp.extract(b, a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_extract_shape_mismatch(self, xp): a = testing.shaped_arange((2, 3), xp) @@ -175,7 +175,7 @@ def test_extract_shape_mismatch(self, xp): [True, False]]) return xp.extract(b, a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_extract_size_mismatch(self, xp): a = testing.shaped_arange((3, 3), xp) @@ -183,7 +183,7 @@ def test_extract_size_mismatch(self, xp): [False, True, False]]) return xp.extract(b, a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_extract_size_mismatch2(self, xp): a = testing.shaped_arange((3, 3), xp) @@ -191,7 +191,7 @@ def test_extract_size_mismatch2(self, xp): [False, True, False, True]]) return xp.extract(b, a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_extract_empty_1dim(self, xp): a = testing.shaped_arange((3, 3), xp) @@ -199,7 +199,7 @@ def test_extract_empty_1dim(self, xp): return xp.extract(b, a) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestChoose(unittest.TestCase): @@ -350,7 +350,7 @@ def test_select_type_error_condlist(self, dtype): with pytest.raises(AttributeError): cupy.select(condlist, choicelist) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_bool=True) def test_select_type_error_choicelist(self, dtype): a, b = list(range(10)), list(range(-10, 0)) diff --git a/tests/third_party/cupy/indexing_tests/test_insert.py b/tests/third_party/cupy/indexing_tests/test_insert.py index 809c44b66da..fb94f159f38 100644 --- a/tests/third_party/cupy/indexing_tests/test_insert.py +++ b/tests/third_party/cupy/indexing_tests/test_insert.py @@ -39,7 +39,7 @@ class TestPlaceRaises(unittest.TestCase): # https://github.com/numpy/numpy/pull/5821 @testing.with_requires('numpy>=1.10') @testing.for_all_dtypes() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_place_empty_value_error(self, dtype): for xp in (numpy, cupy): a = testing.shaped_arange(self.shape, xp, dtype) @@ -65,7 +65,7 @@ def test_place_shape_unmatch_error(self, dtype): 'mode': ['raise', 'wrap', 'clip'], 'n_vals': [0, 1, 3, 4, 5], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestPut(unittest.TestCase): @@ -86,7 +86,7 @@ def test_put(self, xp, dtype): @testing.parameterize(*testing.product({ 'shape': [(7,), (2, 3), (4, 3, 2)], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestPutScalars(unittest.TestCase): @@ -113,7 +113,7 @@ def test_put_values_scalar(self, xp): @testing.parameterize(*testing.product({ 'shape': [(7,), (2, 3)], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestPutRaises(unittest.TestCase): @@ -182,7 +182,7 @@ def test_putmask(self, xp, dtype): return a -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestPutmask(unittest.TestCase): @@ -237,7 +237,7 @@ def test_putmask_differnt_dtypes_mask(self, xp, dtype): 'val': [1, 0, (2,), (2, 2)], 'wrap': [True, False], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestFillDiagonal(unittest.TestCase): @@ -314,7 +314,7 @@ def test_diag_indices_from(self, xp): @testing.parameterize(*testing.product({ 'shape': [(3, 5), (3, 3, 4), (5,), (0,), (-1,)], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDiagIndicesFromRaises(unittest.TestCase): diff --git a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py index 704bcf3f2e6..a8115552f56 100644 --- a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py +++ b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py @@ -105,7 +105,7 @@ def test_eigh_complex_batched(self, xp, dtype): A[i].dot(v[i]), w[i]*v[i], rtol=1e-5, atol=1e-5) return w - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') @testing.for_all_dtypes(no_float16=True, no_complex=True) @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4) def test_eigvalsh(self, xp, dtype): @@ -115,7 +115,7 @@ def test_eigvalsh(self, xp, dtype): # so they should be directly comparable return w - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') @testing.for_all_dtypes(no_float16=True, no_complex=True) @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4) def test_eigvalsh_batched(self, xp, dtype): @@ -126,7 +126,7 @@ def test_eigvalsh_batched(self, xp, dtype): # so they should be directly comparable return w - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') @testing.for_complex_dtypes() @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4) def test_eigvalsh_complex(self, xp, dtype): @@ -136,7 +136,7 @@ def test_eigvalsh_complex(self, xp, dtype): # so they should be directly comparable return w - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') @testing.for_complex_dtypes() @testing.numpy_cupy_allclose(rtol=1e-3, atol=1e-4) def test_eigvalsh_complex_batched(self, xp, dtype): @@ -163,7 +163,7 @@ def test_eigh(self, xp, dtype): assert a.size == 0 return xp.linalg.eigh(a, UPLO=self.UPLO) - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') @testing.for_dtypes('ifdFD') @testing.numpy_cupy_allclose() def test_eigvalsh(self, xp, dtype): @@ -189,7 +189,7 @@ def test_eigh_shape_error(self): with pytest.raises((numpy.linalg.LinAlgError, ValueError)): xp.linalg.eigh(a, self.UPLO) - @pytest.mark.skip("No support of dpnp.eigvalsh()") + @pytest.mark.skip('No support of dpnp.eigvalsh()') def test_eigvalsh_shape_error(self): for xp in (numpy, cupy): a = xp.zeros(self.shape) diff --git a/tests/third_party/cupy/linalg_tests/test_einsum.py b/tests/third_party/cupy/linalg_tests/test_einsum.py index 26c7639ef0c..879f260f886 100644 --- a/tests/third_party/cupy/linalg_tests/test_einsum.py +++ b/tests/third_party/cupy/linalg_tests/test_einsum.py @@ -13,7 +13,7 @@ def _dec_shape(shape, dec): return tuple(1 if s == 1 else max(0, s - dec) for s in shape) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestEinSumError(unittest.TestCase): def test_irregular_ellipsis1(self): @@ -195,25 +195,25 @@ def test_invalid_sub1(self): with pytest.raises(ValueError): xp.einsum(xp.arange(2), [None]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_invalid_sub2(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.einsum(xp.arange(2), [0], [1]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_invalid_sub3(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.einsum(xp.arange(2), [Ellipsis, 0, Ellipsis]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_dim_mismatch1(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.einsum(xp.arange(2), [0], xp.arange(3), [0]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_dim_mismatch2(self): for xp in (numpy, cupy): with pytest.raises(ValueError): @@ -224,13 +224,13 @@ def test_dim_mismatch3(self): with pytest.raises(ValueError): xp.einsum(xp.arange(6).reshape(2, 3), [0, 0]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_too_many_dims1(self): for xp in (numpy, cupy): with pytest.raises(ValueError): xp.einsum(3, [0]) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_too_many_dims2(self): for xp in (numpy, cupy): with pytest.raises(ValueError): @@ -305,7 +305,7 @@ def setUp(self): self.operands = operands - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_allclose(contiguous_check=False) def test_einsum(self, xp): # TODO(kataoka): support memory efficient cupy.einsum diff --git a/tests/third_party/cupy/linalg_tests/test_product.py b/tests/third_party/cupy/linalg_tests/test_product.py index d25cebbfa67..e2b790e5694 100644 --- a/tests/third_party/cupy/linalg_tests/test_product.py +++ b/tests/third_party/cupy/linalg_tests/test_product.py @@ -89,7 +89,7 @@ def test_dot_with_out(self, xp, dtype_a, dtype_b, dtype_c): ((2, 4, 5, 2), (2, 4, 5, 2), 0, 0, -1), ], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestCrossProduct(unittest.TestCase): @@ -225,7 +225,7 @@ def test_transposed_multidim_vdot(self, xp, dtype): (2, 2, 2, 3), xp, dtype).transpose(1, 3, 0, 2) return xp.vdot(a, b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_inner(self, xp, dtype): @@ -233,7 +233,7 @@ def test_inner(self, xp, dtype): b = testing.shaped_reverse_arange((5,), xp, dtype) return xp.inner(a, b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_reversed_inner(self, xp, dtype): @@ -241,7 +241,7 @@ def test_reversed_inner(self, xp, dtype): b = testing.shaped_reverse_arange((5,), xp, dtype)[::-1] return xp.inner(a, b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_multidim_inner(self, xp, dtype): @@ -277,7 +277,7 @@ def test_multidim_outer(self, xp, dtype): b = testing.shaped_arange((4, 5), xp, dtype) return xp.outer(a, b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_tensordot(self, xp, dtype): @@ -292,7 +292,7 @@ def test_transposed_tensordot(self, xp, dtype): b = testing.shaped_arange((4, 3, 2), xp, dtype).transpose(2, 0, 1) return xp.tensordot(a, b) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_tensordot_with_int_axes(self, xp, dtype): @@ -322,7 +322,7 @@ def test_transposed_tensordot_with_int_axes(self, xp, dtype): (5, 4, 3, 2), xp, dtype).transpose(3, 0, 2, 1) return xp.tensordot(a, b, axes=3) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_tensordot_with_list_axes(self, xp, dtype): @@ -399,7 +399,7 @@ def test_zerodim_kron(self, xp, dtype): ((0, 0, 0), ([0, 2, 1], [1, 2, 0])), ], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestProductZeroLength(unittest.TestCase): @@ -412,7 +412,7 @@ def test_tensordot_zero_length(self, xp, dtype): class TestMatrixPower(unittest.TestCase): - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_matrix_power_0(self, xp, dtype): @@ -437,7 +437,7 @@ def test_matrix_power_3(self, xp, dtype): a = testing.shaped_arange((3, 3), xp, dtype) return xp.linalg.matrix_power(a, 3) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_float_dtypes(no_float16=True) @testing.numpy_cupy_allclose(rtol=1e-5) def test_matrix_power_inv1(self, xp, dtype): @@ -445,7 +445,7 @@ def test_matrix_power_inv1(self, xp, dtype): a = a * a % 30 return xp.linalg.matrix_power(a, -1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_float_dtypes(no_float16=True) @testing.numpy_cupy_allclose(rtol=1e-5) def test_matrix_power_inv2(self, xp, dtype): @@ -453,7 +453,7 @@ def test_matrix_power_inv2(self, xp, dtype): a = a * a % 30 return xp.linalg.matrix_power(a, -2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_float_dtypes(no_float16=True) @testing.numpy_cupy_allclose(rtol=1e-4) def test_matrix_power_inv3(self, xp, dtype): diff --git a/tests/third_party/cupy/logic_tests/test_comparison.py b/tests/third_party/cupy/logic_tests/test_comparison.py index 67848359188..aba41ac9703 100644 --- a/tests/third_party/cupy/logic_tests/test_comparison.py +++ b/tests/third_party/cupy/logic_tests/test_comparison.py @@ -161,7 +161,7 @@ def test_allclose_array_scalar(self, xp, dtype): return xp.allclose(a, b) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestIsclose(unittest.TestCase): @testing.for_all_dtypes(no_complex=True) diff --git a/tests/third_party/cupy/logic_tests/test_content.py b/tests/third_party/cupy/logic_tests/test_content.py index 7172d9b12b2..3376bd5923b 100644 --- a/tests/third_party/cupy/logic_tests/test_content.py +++ b/tests/third_party/cupy/logic_tests/test_content.py @@ -24,14 +24,14 @@ def check_unary_nan(self, name, xp, dtype): dtype=dtype) return getattr(xp, name)(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_isfinite(self): self.check_unary_inf('isfinite') - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_isinf(self): self.check_unary_inf('isinf') - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_isnan(self): self.check_unary_nan('isnan') diff --git a/tests/third_party/cupy/manipulation_tests/test_basic.py b/tests/third_party/cupy/manipulation_tests/test_basic.py index 8cc170d3241..1900ac83da8 100644 --- a/tests/third_party/cupy/manipulation_tests/test_basic.py +++ b/tests/third_party/cupy/manipulation_tests/test_basic.py @@ -28,7 +28,7 @@ def test_copyto_dtype(self, xp, dtype): xp.copyto(b, a) return b - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() def test_copyto_broadcast(self, xp, dtype): @@ -37,7 +37,7 @@ def test_copyto_broadcast(self, xp, dtype): xp.copyto(b, a) return b - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() def test_copyto_where(self, xp, dtype): @@ -110,7 +110,7 @@ def test_copyto_where(self, xp, dtype): *testing.product( {'src': [float(3.2), int(0), int(4), int(-4), True, False, 1 + 1j], 'dst_shape': [(), (0,), (1,), (1, 1), (2, 2)]})) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestCopytoFromScalar(unittest.TestCase): diff --git a/tests/third_party/cupy/manipulation_tests/test_dims.py b/tests/third_party/cupy/manipulation_tests/test_dims.py index 2c3e73b596d..a9bea0449a6 100644 --- a/tests/third_party/cupy/manipulation_tests/test_dims.py +++ b/tests/third_party/cupy/manipulation_tests/test_dims.py @@ -19,18 +19,18 @@ def check_atleast(self, func, xp): f = numpy.float32(1) return func(a, b, c, d, e, f) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_atleast_1d1(self, xp): return self.check_atleast(xp.atleast_1d, xp) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_atleast_1d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_1d(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_atleast_2d1(self, xp): return self.check_atleast(xp.atleast_2d, xp) @@ -40,7 +40,7 @@ def test_atleast_2d2(self, xp): a = testing.shaped_arange((1, 3, 2), xp) return xp.atleast_2d(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_atleast_3d1(self, xp): return self.check_atleast(xp.atleast_3d, xp) diff --git a/tests/third_party/cupy/manipulation_tests/test_shape.py b/tests/third_party/cupy/manipulation_tests/test_shape.py index 826c0e49011..b20e2e5966e 100644 --- a/tests/third_party/cupy/manipulation_tests/test_shape.py +++ b/tests/third_party/cupy/manipulation_tests/test_shape.py @@ -140,7 +140,7 @@ def test_ndim_limit1(self, xp, dtype, order): a = self._test_ndim_limit(xp, 32, dtype, order) return a - @pytest.mark.skip("no max ndim limit for reshape in dpctl") + @pytest.mark.skip('no max ndim limit for reshape in dpctl') @testing.for_orders(_supported_orders) @testing.for_all_dtypes() def test_ndim_limit2(self, dtype, order): diff --git a/tests/third_party/cupy/manipulation_tests/test_tiling.py b/tests/third_party/cupy/manipulation_tests/test_tiling.py index fa00273671d..dc25f9ceac8 100644 --- a/tests/third_party/cupy/manipulation_tests/test_tiling.py +++ b/tests/third_party/cupy/manipulation_tests/test_tiling.py @@ -16,7 +16,7 @@ {'repeats': [1, 2, 3], 'axis': 1}, {'repeats': [1, 2, 3], 'axis': -2}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRepeat(unittest.TestCase): @@ -45,7 +45,7 @@ def test_method(self): {'repeats': [2], 'axis': None}, {'repeats': [2], 'axis': 1}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRepeatListBroadcast(unittest.TestCase): @@ -67,7 +67,7 @@ def test_array_repeat(self, xp): {'repeats': [1, 2, 3, 4], 'axis': None}, {'repeats': [1, 2, 3, 4], 'axis': 0}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRepeat1D(unittest.TestCase): @@ -100,7 +100,7 @@ def test_array_repeat(self, xp): {'repeats': 2, 'axis': -4}, {'repeats': 2, 'axis': 3}, ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestRepeatFailure(unittest.TestCase): diff --git a/tests/third_party/cupy/manipulation_tests/test_transpose.py b/tests/third_party/cupy/manipulation_tests/test_transpose.py index 91e8fe9a2cd..cabef3d3515 100644 --- a/tests/third_party/cupy/manipulation_tests/test_transpose.py +++ b/tests/third_party/cupy/manipulation_tests/test_transpose.py @@ -104,7 +104,7 @@ def test_rollaxis(self, xp): a = testing.shaped_arange((2, 3, 4), xp) return xp.rollaxis(a, 2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_rollaxis_failure(self): for xp in (numpy, cupy): a = testing.shaped_arange((2, 3, 4), xp) @@ -116,7 +116,7 @@ def test_swapaxes(self, xp): a = testing.shaped_arange((2, 3, 4), xp) return xp.swapaxes(a, 2, 0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_swapaxes_failure(self): for xp in (numpy, cupy): a = testing.shaped_arange((2, 3, 4), xp) diff --git a/tests/third_party/cupy/math_tests/test_arithmetic.py b/tests/third_party/cupy/math_tests/test_arithmetic.py index c52b2d2df3a..f91f681fa3e 100644 --- a/tests/third_party/cupy/math_tests/test_arithmetic.py +++ b/tests/third_party/cupy/math_tests/test_arithmetic.py @@ -58,7 +58,7 @@ def test_raises_with_numpy_input(self): 'name': ['reciprocal'], }) )) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestArithmeticUnary(unittest.TestCase): @testing.numpy_cupy_allclose(atol=1e-5) @@ -202,7 +202,7 @@ def check_binary(self, xp): 'name': ['divide', 'true_divide', 'subtract'], }) )) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestArithmeticBinary(ArithmeticBinaryBase, unittest.TestCase): def test_binary(self): @@ -252,7 +252,7 @@ def test_binary(self): 'use_dtype': [True, False], }) )) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestArithmeticBinary2(ArithmeticBinaryBase, unittest.TestCase): def test_binary(self): diff --git a/tests/third_party/cupy/math_tests/test_matmul.py b/tests/third_party/cupy/math_tests/test_matmul.py index f8533eef8c1..1b50dff07f8 100644 --- a/tests/third_party/cupy/math_tests/test_matmul.py +++ b/tests/third_party/cupy/math_tests/test_matmul.py @@ -54,7 +54,7 @@ ((1, 3, 3), (10, 1, 3, 1)), ], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestMatmul(unittest.TestCase): @@ -89,7 +89,7 @@ def test_cupy_matmul(self, xp, dtype1): ((6, 5, 3, 2), (2,)), ], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestMatmulLarge(unittest.TestCase): @@ -140,7 +140,7 @@ def test_cupy_matmul(self, xp, dtype1): ((0, 1, 1), (2, 1, 1)), ], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestMatmulInvalidShape(unittest.TestCase): diff --git a/tests/third_party/cupy/math_tests/test_rounding.py b/tests/third_party/cupy/math_tests/test_rounding.py index 91d74923f06..f0f7e64549e 100644 --- a/tests/third_party/cupy/math_tests/test_rounding.py +++ b/tests/third_party/cupy/math_tests/test_rounding.py @@ -77,7 +77,7 @@ def test_round_(self): @testing.parameterize(*testing.product({ 'decimals': [-2, -1, 0, 1, 2], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestRound(unittest.TestCase): shape = (20,) @@ -137,7 +137,7 @@ def test_round_small(self, xp, dtype): (1.6, 0), ] })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestRoundBorder(unittest.TestCase): @testing.numpy_cupy_allclose(atol=1e-5) diff --git a/tests/third_party/cupy/math_tests/test_sumprod.py b/tests/third_party/cupy/math_tests/test_sumprod.py index ae5aaed495a..02c3013ebea 100644 --- a/tests/third_party/cupy/math_tests/test_sumprod.py +++ b/tests/third_party/cupy/math_tests/test_sumprod.py @@ -296,7 +296,7 @@ def test_nansum_axis_transposed(self, xp, dtype): 'shape': [(2, 3, 4), (20, 30, 40)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestNansumNanprodExtra(unittest.TestCase): @@ -324,7 +324,7 @@ def test_nansum_out_wrong_shape(self): 'axis': [(1, 3), (0, 2, 3)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestNansumNanprodAxes(unittest.TestCase): @testing.for_all_dtypes(no_bool=True, no_float16=True) @@ -340,7 +340,7 @@ def test_nansum_axes(self, xp, dtype): @testing.parameterize(*testing.product({'axis': axes})) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestCumsum(unittest.TestCase): @@ -459,7 +459,7 @@ def test_cumprod_1dim(self, xp, dtype): a = testing.shaped_arange((5,), xp, dtype) return xp.cumprod(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_cumprod_out(self, xp, dtype): @@ -482,7 +482,7 @@ def test_cumprod_2dim_without_axis(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) return xp.cumprod(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_cumprod_2dim_with_axis(self, xp, dtype): @@ -508,7 +508,7 @@ def test_cumprod_huge_array(self): del result cupy.get_default_memory_pool().free_all_blocks() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() def test_invalid_axis_lower1(self, dtype): for xp in (numpy, cupy): @@ -516,7 +516,7 @@ def test_invalid_axis_lower1(self, dtype): with pytest.raises(numpy.AxisError): xp.cumprod(a, axis=-a.ndim - 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() def test_invalid_axis_lower2(self, dtype): for xp in (numpy, cupy): @@ -524,7 +524,7 @@ def test_invalid_axis_lower2(self, dtype): with pytest.raises(numpy.AxisError): xp.cumprod(a, axis=-a.ndim - 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() def test_invalid_axis_upper1(self, dtype): for xp in (numpy, cupy): @@ -532,7 +532,7 @@ def test_invalid_axis_upper1(self, dtype): with pytest.raises(numpy.AxisError): return xp.cumprod(a, axis=a.ndim) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() def test_invalid_axis_upper2(self, dtype): a = testing.shaped_arange((4, 5), cupy, dtype) @@ -599,7 +599,7 @@ def test_diff_2dim_with_append(self, xp, dtype): b = testing.shaped_arange((1, 5), xp, dtype) return xp.diff(a, axis=0, append=b, n=2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.with_requires('numpy>=1.16') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() @@ -607,7 +607,7 @@ def test_diff_2dim_with_scalar_append(self, xp, dtype): a = testing.shaped_arange((4, 5), xp, dtype) return xp.diff(a, prepend=1, append=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.with_requires('numpy>=1.16') def test_diff_invalid_axis(self): for xp in (numpy, cupy): diff --git a/tests/third_party/cupy/random_tests/test_distributions.py b/tests/third_party/cupy/random_tests/test_distributions.py index e53d313d91f..1df10269925 100644 --- a/tests/third_party/cupy/random_tests/test_distributions.py +++ b/tests/third_party/cupy/random_tests/test_distributions.py @@ -32,7 +32,7 @@ def check_distribution(self, dist_name, params): 'b_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsBeta(RandomDistributionsTestCase): @@ -70,7 +70,7 @@ def test_binomial(self, n_dtype, p_dtype): 'df_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsChisquare(unittest.TestCase): @@ -91,7 +91,7 @@ def test_chisquare(self, df_dtype): 'alpha_shape': [(3,)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsDirichlet(RandomDistributionsTestCase): @@ -107,7 +107,7 @@ def test_dirichlet(self, alpha_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsExponential(RandomDistributionsTestCase): @@ -117,7 +117,7 @@ def test_exponential(self, scale_dtype): self.check_distribution('exponential', {'scale': scale}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsExponentialError(RandomDistributionsTestCase): @@ -133,7 +133,7 @@ def test_negative_scale(self): 'dfden_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsF(unittest.TestCase): @@ -158,7 +158,7 @@ def test_f(self, dfnum_dtype, dfden_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsGamma(unittest.TestCase): @@ -202,7 +202,7 @@ def test_geometric(self, p_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsGumbel(RandomDistributionsTestCase): @@ -248,7 +248,7 @@ def test_hypergeometric(self, ngood_dtype, nbad_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsuLaplace(RandomDistributionsTestCase): @@ -266,7 +266,7 @@ def test_laplace(self, loc_dtype, scale_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsLogistic(RandomDistributionsTestCase): @@ -353,7 +353,7 @@ def test_normal(self, mean_dtype, cov_dtype): 'p_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsNegativeBinomial(RandomDistributionsTestCase): @@ -380,7 +380,7 @@ def test_negative_binomial_for_noninteger_n(self, n_dtype, p_dtype): 'nonc_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsNoncentralChisquare(RandomDistributionsTestCase): @@ -414,7 +414,7 @@ def test_noncentral_chisquare_for_invalid_params(self, param_dtype): 'nonc_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsNoncentralF(RandomDistributionsTestCase): @@ -458,7 +458,7 @@ def test_noncentral_f_for_invalid_params(self, param_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsNormal(RandomDistributionsTestCase): @@ -475,7 +475,7 @@ def test_normal(self, loc_dtype, scale_dtype): 'a_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsPareto(unittest.TestCase): @@ -539,7 +539,7 @@ def test_power_for_negative_a(self, a_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsRayleigh(RandomDistributionsTestCase): @@ -588,7 +588,7 @@ def test_standard_exponential(self): 'shape_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsStandardGamma(RandomDistributionsTestCase): @@ -615,7 +615,7 @@ def test_standard_normal(self): 'df_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsStandardT(unittest.TestCase): @@ -638,7 +638,7 @@ def test_standard_t(self, df_dtype): 'right_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsTriangular(RandomDistributionsTestCase): @@ -682,7 +682,7 @@ def test_triangular_for_invalid_params(self, param_dtype): 'high_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsUniform(RandomDistributionsTestCase): @@ -700,7 +700,7 @@ def test_uniform(self, low_dtype, high_dtype): 'kappa_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsVonmises(unittest.TestCase): @@ -725,7 +725,7 @@ def test_vonmises(self, mu_dtype, kappa_dtype): 'scale_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsWald(RandomDistributionsTestCase): @@ -743,7 +743,7 @@ def test_wald(self, mean_dtype, scale_dtype): 'a_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsWeibull(RandomDistributionsTestCase): @@ -770,7 +770,7 @@ def test_weibull_for_negative_a(self, a_dtype): 'a_shape': [(), (3, 2)], }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestDistributionsZipf(RandomDistributionsTestCase): diff --git a/tests/third_party/cupy/random_tests/test_sample.py b/tests/third_party/cupy/random_tests/test_sample.py index f3b844cdc6a..014475eaead 100644 --- a/tests/third_party/cupy/random_tests/test_sample.py +++ b/tests/third_party/cupy/random_tests/test_sample.py @@ -45,7 +45,7 @@ def test_zero_sizes(self): @testing.gpu class TestRandint2(unittest.TestCase): - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @condition.repeat(3, 10) def test_bound_1(self): vals = [random.randint(0, 10, (2, 3)) for _ in range(10)] @@ -54,7 +54,7 @@ def test_bound_1(self): self.assertEqual(min(_.min() for _ in vals), 0) self.assertEqual(max(_.max() for _ in vals), 9) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @condition.repeat(3, 10) def test_bound_2(self): vals = [random.randint(0, 2) for _ in range(20)] @@ -63,7 +63,7 @@ def test_bound_2(self): self.assertEqual(min(_.min() for _ in vals), 0) self.assertEqual(max(_.max() for _ in vals), 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @condition.repeat(3, 10) def test_bound_overflow(self): # 100 - (-100) exceeds the range of int8 @@ -72,7 +72,7 @@ def test_bound_overflow(self): self.assertGreaterEqual(val.min(), -100) self.assertLess(val.max(), 100) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @condition.repeat(3, 10) def test_bound_float1(self): # generate floats s.t. int(low) < int(high) @@ -85,7 +85,7 @@ def test_bound_float1(self): self.assertEqual(min(_.min() for _ in vals), int(low)) self.assertEqual(max(_.max() for _ in vals), int(high) - 1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_bound_float2(self): vals = [random.randint(-1.0, 1.0, (2, 3)) for _ in range(10)] for val in vals: @@ -152,17 +152,17 @@ class TestRandomIntegers(unittest.TestCase): def test_normal(self): with mock.patch('dpnp.random.RandomState.randint') as m: random.random_integers(3, 5) - m.assert_called_with(low=3, high=6, size=None, dtype=int, usm_type="device") + m.assert_called_with(low=3, high=6, size=None, dtype=int, usm_type='device') def test_high_is_none(self): with mock.patch('dpnp.random.RandomState.randint') as m: random.random_integers(3, None) - m.assert_called_with(low=0, high=4, size=None, dtype=int, usm_type="device") + m.assert_called_with(low=0, high=4, size=None, dtype=int, usm_type='device') def test_size_is_not_none(self): with mock.patch('dpnp.random.RandomState.randint') as m: random.random_integers(3, 5, (1, 2, 3)) - m.assert_called_with(low=3, high=6, size=(1, 2, 3), dtype=int, usm_type="device") + m.assert_called_with(low=3, high=6, size=(1, 2, 3), dtype=int, usm_type='device') @testing.fix_random() @@ -261,7 +261,7 @@ def test_rand_default_dtype(self): with mock.patch('dpnp.random.RandomState.random_sample') as m: random.rand(1, 2, 3) m.assert_called_once_with( - size=(1, 2, 3), usm_type="device") + size=(1, 2, 3), usm_type='device') def test_rand_invalid_argument(self): with self.assertRaises(TypeError): @@ -270,12 +270,12 @@ def test_rand_invalid_argument(self): def test_randn(self): with mock.patch('dpnp.random.RandomState.standard_normal') as m: random.randn(1, 2, 3) - m.assert_called_once_with(size=(1, 2, 3), usm_type="device") + m.assert_called_once_with(size=(1, 2, 3), usm_type='device') def test_randn_default_dtype(self): with mock.patch('dpnp.random.RandomState.standard_normal') as m: random.randn(1, 2, 3) - m.assert_called_once_with(size=(1, 2, 3), usm_type="device") + m.assert_called_once_with(size=(1, 2, 3), usm_type='device') def test_randn_invalid_argument(self): with self.assertRaises(TypeError): diff --git a/tests/third_party/cupy/sorting_tests/test_search.py b/tests/third_party/cupy/sorting_tests/test_search.py index b0531244a2f..920df44b10d 100644 --- a/tests/third_party/cupy/sorting_tests/test_search.py +++ b/tests/third_party/cupy/sorting_tests/test_search.py @@ -29,35 +29,35 @@ def test_argmax_nan(self, xp, dtype): a = xp.array([float('nan'), -1, 1], dtype) return a.argmax() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmax_axis_large(self, xp, dtype): a = testing.shaped_random((3, 1000), xp, dtype) return a.argmax(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_external_argmax_axis_large(self, xp, dtype): a = testing.shaped_random((3, 1000), xp, dtype) return xp.argmax(a, axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmax_axis0(self, xp, dtype): a = testing.shaped_random((2, 3, 4), xp, dtype) return a.argmax(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmax_axis1(self, xp, dtype): a = testing.shaped_random((2, 3, 4), xp, dtype) return a.argmax(axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmax_axis2(self, xp, dtype): @@ -77,7 +77,7 @@ def test_argmax_zero_size(self, dtype): with pytest.raises(ValueError): a.argmax() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) def test_argmax_zero_size_axis0(self, dtype): for xp in (numpy, cupy): @@ -85,7 +85,7 @@ def test_argmax_zero_size_axis0(self, dtype): with pytest.raises(ValueError): a.argmax(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmax_zero_size_axis1(self, xp, dtype): @@ -110,35 +110,35 @@ def test_external_argmin_all(self, xp, dtype): a = testing.shaped_random((2, 3), xp, dtype) return xp.argmin(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmin_axis_large(self, xp, dtype): a = testing.shaped_random((3, 1000), xp, dtype) return a.argmin(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_external_argmin_axis_large(self, xp, dtype): a = testing.shaped_random((3, 1000), xp, dtype) return xp.argmin(a, axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmin_axis0(self, xp, dtype): a = testing.shaped_random((2, 3, 4), xp, dtype) return a.argmin(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmin_axis1(self, xp, dtype): a = testing.shaped_random((2, 3, 4), xp, dtype) return a.argmin(axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmin_axis2(self, xp, dtype): @@ -158,7 +158,7 @@ def test_argmin_zero_size(self, dtype): with pytest.raises(ValueError): return a.argmin() - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) def test_argmin_zero_size_axis0(self, dtype): for xp in (numpy, cupy): @@ -166,7 +166,7 @@ def test_argmin_zero_size_axis0(self, dtype): with pytest.raises(ValueError): a.argmin(axis=0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes(no_complex=True) @testing.numpy_cupy_allclose() def test_argmin_zero_size_axis1(self, xp, dtype): @@ -585,7 +585,7 @@ def test_nanargmax_zero_size_axis1(self, xp, dtype): 'side': ['left', 'right'], 'shape': [(), (10,), (6, 3, 3)]}) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestSearchSorted(unittest.TestCase): @testing.for_all_dtypes(no_bool=True) @@ -601,7 +601,7 @@ def test_searchsorted(self, xp, dtype): @testing.parameterize( {'side': 'left'}, {'side': 'right'}) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestSearchSortedNanInf(unittest.TestCase): @testing.numpy_cupy_array_equal() @@ -664,7 +664,7 @@ def test_searchsorted_minf(self, xp): return y, -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestSearchSortedInvalid(unittest.TestCase): @@ -679,7 +679,7 @@ def test_searchsorted_ndbins(self): xp.searchsorted(bins, x) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestSearchSortedWithSorter(unittest.TestCase): diff --git a/tests/third_party/cupy/sorting_tests/test_sort.py b/tests/third_party/cupy/sorting_tests/test_sort.py index eb3cc8a1a80..6a7fa5cd3af 100644 --- a/tests/third_party/cupy/sorting_tests/test_sort.py +++ b/tests/third_party/cupy/sorting_tests/test_sort.py @@ -34,14 +34,14 @@ def test_external_sort_zero_dim(self): with pytest.raises(numpy.AxisError): xp.sort(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_sort_two_or_more_dim(self, xp): a = testing.shaped_random((2, 3, 3), xp) a.sort() return a - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_external_sort_two_or_more_dim(self, xp): a = testing.shaped_random((2, 3, 3), xp) @@ -105,7 +105,7 @@ def test_sort_axis3(self, xp): a.sort(axis=2) return a - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_external_sort_axis(self, xp): a = testing.shaped_random((2, 3, 3), xp) @@ -117,13 +117,13 @@ def test_sort_negative_axis(self, xp): a.sort(axis=-2) return a - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_external_sort_negative_axis(self, xp): a = testing.shaped_random((2, 3, 3), xp) return xp.sort(a, axis=-2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.numpy_cupy_array_equal() def test_external_sort_none_axis(self, xp): a = testing.shaped_random((2, 3, 3), xp) @@ -140,14 +140,14 @@ def test_sort_invalid_axis2(self): with self.assertRaises(numpy.AxisError): a.sort(axis=3) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_external_sort_invalid_axis1(self): for xp in (numpy, cupy): a = testing.shaped_random((2, 3, 3), xp) with pytest.raises(numpy.AxisError): xp.sort(a, axis=3) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_external_sort_invalid_axis2(self): a = testing.shaped_random((2, 3, 3), cupy) with self.assertRaises(numpy.AxisError): @@ -164,14 +164,14 @@ def test_sort_invalid_negative_axis2(self): with self.assertRaises(numpy.AxisError): a.sort(axis=-4) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_external_sort_invalid_negative_axis1(self): for xp in (numpy, cupy): a = testing.shaped_random((2, 3, 3), xp) with pytest.raises(numpy.AxisError): xp.sort(a, axis=-4) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_external_sort_invalid_negative_axis2(self): a = testing.shaped_random((2, 3, 3), cupy) with self.assertRaises(numpy.AxisError): @@ -468,7 +468,7 @@ def test_sort_complex_nan(self, xp, dtype): 'external': [False, True], 'length': [10, 20000], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestPartition(unittest.TestCase): def partition(self, a, kth, axis=-1): diff --git a/tests/third_party/cupy/statistics_tests/test_correlation.py b/tests/third_party/cupy/statistics_tests/test_correlation.py index b37d2c95b27..8e9ccced83b 100644 --- a/tests/third_party/cupy/statistics_tests/test_correlation.py +++ b/tests/third_party/cupy/statistics_tests/test_correlation.py @@ -87,7 +87,7 @@ def check_raises(self, a_shape, y_shape=None, xp.cov(a, y, rowvar, bias, ddof, fweights, aweights, dtype=dtype) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_cov(self): self.check((2, 3)) self.check((2,), (2,)) @@ -102,12 +102,12 @@ def test_cov(self): self.check((1, 3), fweights=(1, 4, 1), aweights=(1.0, 4.0, 1.0)) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_cov_warns(self): self.check_warns((2, 3), ddof=3) self.check_warns((2, 3), ddof=4) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_cov_raises(self): self.check_raises((2, 3), ddof=1.2) self.check_raises((3, 4, 2)) @@ -123,7 +123,7 @@ def test_cov_empty(self): 'shape1': [(5,), (6,), (20,), (21,)], 'shape2': [(5,), (6,), (20,), (21,)], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestCorrelateShapeCombination(unittest.TestCase): @testing.for_all_dtypes(no_float16=True) @@ -138,7 +138,7 @@ def test_correlate(self, xp, dtype): @testing.parameterize(*testing.product({ 'mode': ['valid', 'full', 'same'] })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestCorrelate(unittest.TestCase): @testing.for_all_dtypes() @@ -167,7 +167,7 @@ def test_correlate_diff_types(self, xp, dtype1, dtype2): @testing.parameterize(*testing.product({ 'mode': ['valid', 'same', 'full'] })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') class TestCorrelateInvalid(unittest.TestCase): @testing.with_requires('numpy>=1.18') diff --git a/tests/third_party/cupy/statistics_tests/test_histogram.py b/tests/third_party/cupy/statistics_tests/test_histogram.py index 2065a826986..79274091a64 100644 --- a/tests/third_party/cupy/statistics_tests/test_histogram.py +++ b/tests/third_party/cupy/statistics_tests/test_histogram.py @@ -138,7 +138,7 @@ def test_histogram_float_weights_dtype(self, xp, dtype): assert xp.issubdtype(h.dtype, xp.floating) return h - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_histogram_weights_basic(self): v = cupy.random.rand(100) w = cupy.ones(100) * 5 diff --git a/tests/third_party/cupy/statistics_tests/test_meanvar.py b/tests/third_party/cupy/statistics_tests/test_meanvar.py index cbe162ba0be..6b4c7800aa6 100644 --- a/tests/third_party/cupy/statistics_tests/test_meanvar.py +++ b/tests/third_party/cupy/statistics_tests/test_meanvar.py @@ -7,7 +7,7 @@ from tests.third_party.cupy import testing ignore_runtime_warnings = pytest.mark.filterwarnings( - "ignore", category=RuntimeWarning) + 'ignore', category=RuntimeWarning) @testing.gpu @@ -19,42 +19,42 @@ def test_median_noaxis(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_median_axis1(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_median_axis2(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a, axis=2) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_median_overwrite_input(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a, overwrite_input=True) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_median_keepdims_axis1(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a, axis=1, keepdims=True) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_median_keepdims_noaxis(self, xp, dtype): a = testing.shaped_random((3, 4, 5), xp, dtype) return xp.median(a, keepdims=True) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') def test_median_invalid_axis(self): for xp in [numpy, cupy]: a = testing.shaped_random((3, 4, 5), xp) @@ -78,7 +78,7 @@ def test_median_invalid_axis(self): 'keepdims': [True, False] }) ) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestMedianAxis(unittest.TestCase): @@ -100,14 +100,14 @@ def test_average_all(self, xp, dtype): a = testing.shaped_arange((2, 3), xp, dtype) return xp.average(a) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_average_axis(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return xp.average(a, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_average_weights(self, xp, dtype): @@ -115,7 +115,7 @@ def test_average_weights(self, xp, dtype): w = testing.shaped_arange((2, 3), xp, dtype) return xp.average(a, weights=w) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_average_axis_weights(self, xp, dtype): @@ -134,7 +134,7 @@ def check_returned(self, a, axis, weights): testing.assert_allclose(average_cpu, average_gpu) testing.assert_allclose(sum_weights_cpu, sum_weights_gpu) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() def test_returned(self, dtype): a = testing.shaped_arange((2, 3), numpy, dtype) @@ -213,28 +213,28 @@ def test_external_var_all_ddof(self, xp, dtype): a = testing.shaped_arange((2, 3), xp, dtype) return xp.var(a, ddof=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_var_axis(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return a.var(axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_external_var_axis(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return xp.var(a, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_var_axis_ddof(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return a.var(axis=1, ddof=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_external_var_axis_ddof(self, xp, dtype): @@ -265,28 +265,28 @@ def test_external_std_all_ddof(self, xp, dtype): a = testing.shaped_arange((2, 3), xp, dtype) return xp.std(a, ddof=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_std_axis(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return a.std(axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_external_std_axis(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return xp.std(a, axis=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_std_axis_ddof(self, xp, dtype): a = testing.shaped_arange((2, 3, 4), xp, dtype) return a.std(axis=1, ddof=1) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") + @pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.for_all_dtypes() @testing.numpy_cupy_allclose() def test_external_std_axis_ddof(self, xp, dtype): @@ -473,7 +473,7 @@ def test_nanstd_float16(self, xp): ], 'func': ['mean', 'std', 'var'], })) -@pytest.mark.usefixtures("allow_fall_back_on_numpy") +@pytest.mark.usefixtures('allow_fall_back_on_numpy') @testing.gpu class TestProductZeroLength(unittest.TestCase): diff --git a/tests/third_party/cupy/testing/helper.py b/tests/third_party/cupy/testing/helper.py index bfd64d32a58..82744427359 100644 --- a/tests/third_party/cupy/testing/helper.py +++ b/tests/third_party/cupy/testing/helper.py @@ -277,12 +277,12 @@ def test_func(self, *args, **kw): if type_check: for cupy_r, numpy_r in zip(cupy_result, numpy_result): if cupy_r.dtype != numpy_r.dtype: - print(f"\nERROR:\n\tcupy_r.dtype={cupy_r.dtype},\n\tnumpy_r.dtype={numpy_r.dtype}") + print(f'\nERROR:\n\tcupy_r.dtype={cupy_r.dtype},\n\tnumpy_r.dtype={numpy_r.dtype}') assert cupy_r.dtype == numpy_r.dtype for cupy_r, numpy_r in zip(cupy_result, numpy_result): if cupy_r.shape != numpy_r.shape: - print(f"\nERROR:\n\tcupy_r.shape={cupy_r.shape},\n\tnumpy_r.shape={numpy_r.shape}") + print(f'\nERROR:\n\tcupy_r.shape={cupy_r.shape},\n\tnumpy_r.shape={numpy_r.shape}') assert cupy_r.shape == numpy_r.shape # Behavior of assigning a negative value to an unsigned integer diff --git a/tests/third_party/intel/test_zero_copy_test1.py b/tests/third_party/intel/test_zero_copy_test1.py index f573f42ea2c..e177bacd807 100644 --- a/tests/third_party/intel/test_zero_copy_test1.py +++ b/tests/third_party/intel/test_zero_copy_test1.py @@ -11,10 +11,10 @@ class dummymodule: module_not_found = False -reason = "" +reason = '' try: - zero_copy_test1 = importlib.import_module("zero-copy-test1") + zero_copy_test1 = importlib.import_module('zero-copy-test1') except ModuleNotFoundError as e: module_not_found = True reason = str(e) diff --git a/tests/third_party/intel/zero-copy-test1.py b/tests/third_party/intel/zero-copy-test1.py index 0d9040311d8..dd51bf970bb 100644 --- a/tests/third_party/intel/zero-copy-test1.py +++ b/tests/third_party/intel/zero-copy-test1.py @@ -8,12 +8,12 @@ class DuckUSMArray: - def __init__(self, shape, dtype="d", host_buffer=None): + def __init__(self, shape, dtype='d', host_buffer=None): nelems = np.prod(shape) bytes = nelems * np.dtype(dtype).itemsize shmem = dpmem.MemoryUSMShared(bytes) if isinstance(host_buffer, np.ndarray): - shmem.copy_from_host(host_buffer.view(dtype="|u1")) + shmem.copy_from_host(host_buffer.view(dtype='|u1')) self.arr = np.ndarray(shape, dtype=dtype, buffer=shmem) def __getitem__(self, indx): @@ -26,8 +26,8 @@ def __setitem__(self, indx, val): def __sycl_usm_array_interface__(self): iface = self.arr.__array_interface__ b = self.arr.base - iface["syclobj"] = b.__sycl_usm_array_interface__["syclobj"] - iface["version"] = 1 + iface['syclobj'] = b.__sycl_usm_array_interface__['syclobj'] + iface['version'] = 1 return iface @@ -58,15 +58,15 @@ def dppy_f(array_like_obj): array_like_obj[i] = 10 global_size = 100 - hb = np.arange(0, global_size, dtype="i4") + hb = np.arange(0, global_size, dtype='i4') da = DuckUSMArray(hb.shape, dtype=hb.dtype, host_buffer=hb) if dpctl.has_gpu_queues(dpctl.backend_type.level_zero): - print("\nScheduling on OpenCL GPU\n") - with dpctl.device_context("opencl:gpu") as gpu_queue: + print('\nScheduling on OpenCL GPU\n') + with dpctl.device_context('opencl:gpu') as gpu_queue: dppy_f[global_size, dppy.DEFAULT_LOCAL_SIZE](da) else: - print("\nSkip scheduling on OpenCL GPU\n") + print('\nSkip scheduling on OpenCL GPU\n') assert da[0] == 10 @@ -74,10 +74,10 @@ def dppy_f(array_like_obj): def test_dpctl_dparray_has_iface(): """Tests if dpctl.dptensor.numpy_usm_shared defines '__sycl_usm_array_interface__'""" X = usmarray.ones(10) - assert type(getattr(X, "__sycl_usm_array_interface__", None) is dict) + assert type(getattr(X, '__sycl_usm_array_interface__', None) is dict) def test_dpnp_array_has_iface(): """Tests if dpnp.ndarray defines '__sycl_usm_array_interface__'""" X = dpnp.array([1]) - assert type(getattr(X, "__sycl_usm_array_interface__", None) is dict) + assert type(getattr(X, '__sycl_usm_array_interface__', None) is dict) From ae86241d1d10fd43042d6aefa94d6819ae0ba5a7 Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Mon, 19 Jun 2023 13:29:13 -0500 Subject: [PATCH 2/2] Updated copyright in all files --- benchmarks/pytest_benchmark/test_random.py | 2 +- doc/docstring_template.py | 2 +- dpnp/__init__.py | 2 +- dpnp/backend/cmake/Modules/TBBConfig.cmake | 2 +- dpnp/backend/examples/example10.cpp | 2 +- dpnp/backend/examples/example11.cpp | 2 +- dpnp/backend/examples/example3.cpp | 2 +- dpnp/backend/examples/example5.cpp | 2 +- dpnp/backend/examples/example7.cpp | 2 +- dpnp/backend/examples/example8.cpp | 2 +- dpnp/backend/examples/example9.cpp | 2 +- dpnp/backend/examples/example_bs.cpp | 2 +- dpnp/backend/examples/example_experimental_iface.cpp | 2 +- dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp | 2 +- dpnp/backend/include/dpnp_iface_fft.hpp | 2 +- dpnp/backend/include/dpnp_iface_random.hpp | 2 +- dpnp/backend/kernels/dpnp_krnl_common.cpp | 2 +- dpnp/backend/kernels/dpnp_krnl_linalg.cpp | 2 +- dpnp/backend/kernels/dpnp_krnl_reduction.cpp | 2 +- dpnp/backend/kernels/dpnp_krnl_statistics.cpp | 2 +- dpnp/backend/src/constants.cpp | 2 +- dpnp/backend/src/constants.hpp | 2 +- dpnp/backend/src/dpnp_iface_fptr.cpp | 2 +- dpnp/backend/src/dpnp_iterator.hpp | 2 +- dpnp/backend/src/dpnp_pstl.hpp | 2 +- dpnp/backend/src/memory_sycl.cpp | 2 +- dpnp/backend/src/verbose.cpp | 2 +- dpnp/backend/src/verbose.hpp | 2 +- dpnp/backend/tests/CMakeLists.txt | 2 +- dpnp/backend/tests/test_broadcast_iterator.cpp | 2 +- dpnp/backend/tests/test_main.cpp | 2 +- dpnp/backend/tests/test_random.cpp | 2 +- dpnp/backend/tests/test_utils.cpp | 2 +- dpnp/backend/tests/test_utils_iterator.cpp | 2 +- dpnp/config.py | 2 +- dpnp/dparray.pxd | 2 +- dpnp/dpnp_algo/__init__.pxd | 2 +- dpnp/dpnp_algo/__init__.py | 2 +- dpnp/dpnp_flatiter.py | 2 +- dpnp/dpnp_iface_counting.py | 2 +- dpnp/dpnp_iface_libmath.py | 2 +- dpnp/dpnp_iface_sorting.py | 2 +- dpnp/dpnp_utils/__init__.pxd | 2 +- dpnp/dpnp_utils/__init__.py | 2 +- dpnp/fft/__init__.py | 2 +- dpnp/fft/dpnp_iface_fft.py | 2 +- dpnp/linalg/__init__.py | 2 +- dpnp/random/__init__.py | 2 +- dpnp/to_numba/__init__.py | 2 +- dpnp/to_numba/dpnp_iface_to_numba.py | 2 +- examples/example1.py | 2 +- examples/example10.py | 2 +- examples/example2.py | 2 +- examples/example6.py | 2 +- examples/example7.py | 2 +- examples/example_bs.py | 2 +- tests/testing/array.py | 2 +- tests/tests_perf/data_generator.py | 2 +- tests/third_party/numpy_ext/__init__.py | 2 +- tests_external/numpy/runtests.py | 2 +- 60 files changed, 60 insertions(+), 60 deletions(-) diff --git a/benchmarks/pytest_benchmark/test_random.py b/benchmarks/pytest_benchmark/test_random.py index dc8d8b8807a..b703ba0861f 100644 --- a/benchmarks/pytest_benchmark/test_random.py +++ b/benchmarks/pytest_benchmark/test_random.py @@ -2,7 +2,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 diff --git a/doc/docstring_template.py b/doc/docstring_template.py index 61751d7d093..a31bb250576 100644 --- a/doc/docstring_template.py +++ b/doc/docstring_template.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 diff --git a/dpnp/__init__.py b/dpnp/__init__.py index 0a7bcfb3a6d..8ef34b1ce43 100644 --- a/dpnp/__init__.py +++ b/dpnp/__init__.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 diff --git a/dpnp/backend/cmake/Modules/TBBConfig.cmake b/dpnp/backend/cmake/Modules/TBBConfig.cmake index 55811100c93..5363c1d3808 100644 --- a/dpnp/backend/cmake/Modules/TBBConfig.cmake +++ b/dpnp/backend/cmake/Modules/TBBConfig.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2017-2021 Intel Corporation +# Copyright (c) 2017-2023 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/dpnp/backend/examples/example10.cpp b/dpnp/backend/examples/example10.cpp index 77175e03022..05e484d4eda 100644 --- a/dpnp/backend/examples/example10.cpp +++ b/dpnp/backend/examples/example10.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example11.cpp b/dpnp/backend/examples/example11.cpp index 8cda6c386b9..a99788239f8 100644 --- a/dpnp/backend/examples/example11.cpp +++ b/dpnp/backend/examples/example11.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example3.cpp b/dpnp/backend/examples/example3.cpp index 43a5eb23daa..8c55c871409 100644 --- a/dpnp/backend/examples/example3.cpp +++ b/dpnp/backend/examples/example3.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example5.cpp b/dpnp/backend/examples/example5.cpp index 6ae921cde35..8ab26a7ddd4 100644 --- a/dpnp/backend/examples/example5.cpp +++ b/dpnp/backend/examples/example5.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example7.cpp b/dpnp/backend/examples/example7.cpp index 96c59c59415..4dcc7d00096 100644 --- a/dpnp/backend/examples/example7.cpp +++ b/dpnp/backend/examples/example7.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example8.cpp b/dpnp/backend/examples/example8.cpp index 4ccfa5f298b..739b9568724 100644 --- a/dpnp/backend/examples/example8.cpp +++ b/dpnp/backend/examples/example8.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example9.cpp b/dpnp/backend/examples/example9.cpp index 4370e3e3864..55aa767da69 100644 --- a/dpnp/backend/examples/example9.cpp +++ b/dpnp/backend/examples/example9.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example_bs.cpp b/dpnp/backend/examples/example_bs.cpp index b0c315e7af7..e61ca3db54f 100644 --- a/dpnp/backend/examples/example_bs.cpp +++ b/dpnp/backend/examples/example_bs.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/examples/example_experimental_iface.cpp b/dpnp/backend/examples/example_experimental_iface.cpp index cd3b08619d7..dcf8295c572 100644 --- a/dpnp/backend/examples/example_experimental_iface.cpp +++ b/dpnp/backend/examples/example_experimental_iface.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp b/dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp index 71caeef9111..ff68a532ba0 100644 --- a/dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp +++ b/dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/include/dpnp_iface_fft.hpp b/dpnp/backend/include/dpnp_iface_fft.hpp index 47d9a7b952b..6ddcfc41d04 100644 --- a/dpnp/backend/include/dpnp_iface_fft.hpp +++ b/dpnp/backend/include/dpnp_iface_fft.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/include/dpnp_iface_random.hpp b/dpnp/backend/include/dpnp_iface_random.hpp index 713954c43bf..581265282a4 100644 --- a/dpnp/backend/include/dpnp_iface_random.hpp +++ b/dpnp/backend/include/dpnp_iface_random.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 diff --git a/dpnp/backend/kernels/dpnp_krnl_common.cpp b/dpnp/backend/kernels/dpnp_krnl_common.cpp index 86a38b45d6c..e2607e9e245 100644 --- a/dpnp/backend/kernels/dpnp_krnl_common.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_common.cpp @@ -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 diff --git a/dpnp/backend/kernels/dpnp_krnl_linalg.cpp b/dpnp/backend/kernels/dpnp_krnl_linalg.cpp index 71390dedeb6..78d9df91796 100644 --- a/dpnp/backend/kernels/dpnp_krnl_linalg.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_linalg.cpp @@ -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 diff --git a/dpnp/backend/kernels/dpnp_krnl_reduction.cpp b/dpnp/backend/kernels/dpnp_krnl_reduction.cpp index e03aabee5ae..40610727fef 100644 --- a/dpnp/backend/kernels/dpnp_krnl_reduction.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_reduction.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/kernels/dpnp_krnl_statistics.cpp b/dpnp/backend/kernels/dpnp_krnl_statistics.cpp index 5dc3dc95373..1a75e9291a8 100644 --- a/dpnp/backend/kernels/dpnp_krnl_statistics.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_statistics.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/constants.cpp b/dpnp/backend/src/constants.cpp index 2a1083f39de..020e962812f 100644 --- a/dpnp/backend/src/constants.cpp +++ b/dpnp/backend/src/constants.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/constants.hpp b/dpnp/backend/src/constants.hpp index f84ff2dd040..f9e4dddc9e2 100644 --- a/dpnp/backend/src/constants.hpp +++ b/dpnp/backend/src/constants.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/dpnp_iface_fptr.cpp b/dpnp/backend/src/dpnp_iface_fptr.cpp index 1e1e32b9684..83316a6670e 100644 --- a/dpnp/backend/src/dpnp_iface_fptr.cpp +++ b/dpnp/backend/src/dpnp_iface_fptr.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/dpnp_iterator.hpp b/dpnp/backend/src/dpnp_iterator.hpp index d046545fdab..b1606c91df4 100644 --- a/dpnp/backend/src/dpnp_iterator.hpp +++ b/dpnp/backend/src/dpnp_iterator.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/dpnp_pstl.hpp b/dpnp/backend/src/dpnp_pstl.hpp index 94c83ede8a9..445b4374eb9 100644 --- a/dpnp/backend/src/dpnp_pstl.hpp +++ b/dpnp/backend/src/dpnp_pstl.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/memory_sycl.cpp b/dpnp/backend/src/memory_sycl.cpp index be7349bf129..de77ac22303 100644 --- a/dpnp/backend/src/memory_sycl.cpp +++ b/dpnp/backend/src/memory_sycl.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/verbose.cpp b/dpnp/backend/src/verbose.cpp index d5549cbcfc4..b53acef180d 100644 --- a/dpnp/backend/src/verbose.cpp +++ b/dpnp/backend/src/verbose.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/src/verbose.hpp b/dpnp/backend/src/verbose.hpp index baefdeafd75..e0c2420b357 100644 --- a/dpnp/backend/src/verbose.hpp +++ b/dpnp/backend/src/verbose.hpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/tests/CMakeLists.txt b/dpnp/backend/tests/CMakeLists.txt index 8729b76a684..e8bd37d2532 100644 --- a/dpnp/backend/tests/CMakeLists.txt +++ b/dpnp/backend/tests/CMakeLists.txt @@ -1,5 +1,5 @@ # ***************************************************************************** -# 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 diff --git a/dpnp/backend/tests/test_broadcast_iterator.cpp b/dpnp/backend/tests/test_broadcast_iterator.cpp index dd465e9b82a..acdb4baa880 100644 --- a/dpnp/backend/tests/test_broadcast_iterator.cpp +++ b/dpnp/backend/tests/test_broadcast_iterator.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/tests/test_main.cpp b/dpnp/backend/tests/test_main.cpp index a28463c31c7..31b3d9cf986 100644 --- a/dpnp/backend/tests/test_main.cpp +++ b/dpnp/backend/tests/test_main.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/tests/test_random.cpp b/dpnp/backend/tests/test_random.cpp index 8c91fbdf84b..4ee73713fe8 100644 --- a/dpnp/backend/tests/test_random.cpp +++ b/dpnp/backend/tests/test_random.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/tests/test_utils.cpp b/dpnp/backend/tests/test_utils.cpp index 055b9194da7..dca418e2672 100644 --- a/dpnp/backend/tests/test_utils.cpp +++ b/dpnp/backend/tests/test_utils.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/backend/tests/test_utils_iterator.cpp b/dpnp/backend/tests/test_utils_iterator.cpp index a0b09fae445..c9aa0a8f7ec 100644 --- a/dpnp/backend/tests/test_utils_iterator.cpp +++ b/dpnp/backend/tests/test_utils_iterator.cpp @@ -1,5 +1,5 @@ //***************************************************************************** -// 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 diff --git a/dpnp/config.py b/dpnp/config.py index 58a35f88a6e..417c35e041f 100644 --- a/dpnp/config.py +++ b/dpnp/config.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 diff --git a/dpnp/dparray.pxd b/dpnp/dparray.pxd index 7ed8b3ec796..9f94db42f40 100644 --- a/dpnp/dparray.pxd +++ b/dpnp/dparray.pxd @@ -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 diff --git a/dpnp/dpnp_algo/__init__.pxd b/dpnp/dpnp_algo/__init__.pxd index 9e15f78acd0..a366ade85c4 100644 --- a/dpnp/dpnp_algo/__init__.pxd +++ b/dpnp/dpnp_algo/__init__.pxd @@ -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 diff --git a/dpnp/dpnp_algo/__init__.py b/dpnp/dpnp_algo/__init__.py index 1444eb89c4a..ae617d8ae81 100644 --- a/dpnp/dpnp_algo/__init__.py +++ b/dpnp/dpnp_algo/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/dpnp_flatiter.py b/dpnp/dpnp_flatiter.py index 93545d119dd..6845468e2f7 100644 --- a/dpnp/dpnp_flatiter.py +++ b/dpnp/dpnp_flatiter.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/dpnp_iface_counting.py b/dpnp/dpnp_iface_counting.py index 9f14e3f36bf..31890a242e5 100644 --- a/dpnp/dpnp_iface_counting.py +++ b/dpnp/dpnp_iface_counting.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 diff --git a/dpnp/dpnp_iface_libmath.py b/dpnp/dpnp_iface_libmath.py index 15e7dab5c1b..b3129147c05 100644 --- a/dpnp/dpnp_iface_libmath.py +++ b/dpnp/dpnp_iface_libmath.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 diff --git a/dpnp/dpnp_iface_sorting.py b/dpnp/dpnp_iface_sorting.py index cdce86cbacc..88fcdddb546 100644 --- a/dpnp/dpnp_iface_sorting.py +++ b/dpnp/dpnp_iface_sorting.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 diff --git a/dpnp/dpnp_utils/__init__.pxd b/dpnp/dpnp_utils/__init__.pxd index 80028907504..e0da397b168 100644 --- a/dpnp/dpnp_utils/__init__.pxd +++ b/dpnp/dpnp_utils/__init__.pxd @@ -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 diff --git a/dpnp/dpnp_utils/__init__.py b/dpnp/dpnp_utils/__init__.py index 911793dc244..e198f23aff3 100644 --- a/dpnp/dpnp_utils/__init__.py +++ b/dpnp/dpnp_utils/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/fft/__init__.py b/dpnp/fft/__init__.py index cef01ce5eda..0c980d00bcf 100644 --- a/dpnp/fft/__init__.py +++ b/dpnp/fft/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/fft/dpnp_iface_fft.py b/dpnp/fft/dpnp_iface_fft.py index 606cd103035..29e81ca7afc 100644 --- a/dpnp/fft/dpnp_iface_fft.py +++ b/dpnp/fft/dpnp_iface_fft.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 diff --git a/dpnp/linalg/__init__.py b/dpnp/linalg/__init__.py index b03be2440fd..40d9338cf8b 100644 --- a/dpnp/linalg/__init__.py +++ b/dpnp/linalg/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/random/__init__.py b/dpnp/random/__init__.py index 9c3e2421bef..0c3495b2bde 100644 --- a/dpnp/random/__init__.py +++ b/dpnp/random/__init__.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 diff --git a/dpnp/to_numba/__init__.py b/dpnp/to_numba/__init__.py index 8fe2adefc41..aee2bba3ee8 100644 --- a/dpnp/to_numba/__init__.py +++ b/dpnp/to_numba/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/dpnp/to_numba/dpnp_iface_to_numba.py b/dpnp/to_numba/dpnp_iface_to_numba.py index 421b7f11637..3b5bd6980be 100644 --- a/dpnp/to_numba/dpnp_iface_to_numba.py +++ b/dpnp/to_numba/dpnp_iface_to_numba.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/examples/example1.py b/examples/example1.py index 7c4351998d4..4db1d5185ea 100644 --- a/examples/example1.py +++ b/examples/example1.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 diff --git a/examples/example10.py b/examples/example10.py index 5e5e367a7e1..d367a34fcd2 100644 --- a/examples/example10.py +++ b/examples/example10.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 diff --git a/examples/example2.py b/examples/example2.py index bf3d6ad4b9a..202ea94b57c 100644 --- a/examples/example2.py +++ b/examples/example2.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 diff --git a/examples/example6.py b/examples/example6.py index 9319bfe6a66..b520a244de2 100644 --- a/examples/example6.py +++ b/examples/example6.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 diff --git a/examples/example7.py b/examples/example7.py index 99a33cad8d8..935d8729071 100644 --- a/examples/example7.py +++ b/examples/example7.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 diff --git a/examples/example_bs.py b/examples/example_bs.py index 0dd298faf47..7ad116900de 100644 --- a/examples/example_bs.py +++ b/examples/example_bs.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 diff --git a/tests/testing/array.py b/tests/testing/array.py index 247811a019d..a036fa4ca1a 100644 --- a/tests/testing/array.py +++ b/tests/testing/array.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/tests/tests_perf/data_generator.py b/tests/tests_perf/data_generator.py index 2fdd00d44fa..dab9718fd71 100755 --- a/tests/tests_perf/data_generator.py +++ b/tests/tests_perf/data_generator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- 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 diff --git a/tests/third_party/numpy_ext/__init__.py b/tests/third_party/numpy_ext/__init__.py index ee770ae9364..18d3869a148 100644 --- a/tests/third_party/numpy_ext/__init__.py +++ b/tests/third_party/numpy_ext/__init__.py @@ -1,6 +1,6 @@ # -*- 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 diff --git a/tests_external/numpy/runtests.py b/tests_external/numpy/runtests.py index 70c7d171294..6434104735b 100644 --- a/tests_external/numpy/runtests.py +++ b/tests_external/numpy/runtests.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