diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 9bd715ac657..7ddb03cdbf7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -18,10 +18,11 @@ jobs: sudo ln -s /usr/bin/clang-format-12 /usr/bin/clang-format clang-format --version - - name: Set up pylint + - name: Set up pip packages uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1 with: packages: | + codespell pylint - name: Checkout DPNP repo diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1b5bd46e5e5..690e131f6f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/PyCQA/bandit - rev: '1.7.7' + rev: '1.7.8' hooks: - id: bandit pass_filenames: false @@ -42,8 +42,14 @@ repos: - id: rst-directive-colons - id: rst-inline-touching-normal - id: text-unicode-replacement-char +- repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + additional_dependencies: + - tomli - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.4.0 hooks: - id: black args: ["--check", "--diff", "--color"] diff --git a/doc/_templates/autosummary/class.rst b/doc/_templates/autosummary/class.rst index 90e3fe72754..1016b42d336 100644 --- a/doc/_templates/autosummary/class.rst +++ b/doc/_templates/autosummary/class.rst @@ -41,7 +41,7 @@ {% endblock %} .. - Atributes + Attributes {% block attributes %} {% if attributes %} diff --git a/doc/docstring_template.py b/doc/docstring_template.py index 2239d97e227..28fa30e7d60 100644 --- a/doc/docstring_template.py +++ b/doc/docstring_template.py @@ -42,7 +42,7 @@ Recommendations: 1. Short description - maybe partially taken/combinated from `numpy` and `cupy` docstrings. + maybe partially taken/combined from `numpy` and `cupy` docstrings. 2. Limitations basically should be described according to the code, paying attention to raised exceptions and fallback to `numpy`. 3. See Also may include links to similar functionality in `dpnp` diff --git a/dpnp/backend/cmake/Modules/IntelSYCLConfig.cmake b/dpnp/backend/cmake/Modules/IntelSYCLConfig.cmake index 052aaa965dc..9120f04f6ea 100644 --- a/dpnp/backend/cmake/Modules/IntelSYCLConfig.cmake +++ b/dpnp/backend/cmake/Modules/IntelSYCLConfig.cmake @@ -188,7 +188,7 @@ function(SYCL_FEATURE_TEST_RUN TEST_EXE) set(IntelSYCL_FOUND False) set(SYCL_REASON_FAILURE "SYCL: feature test execution failed!!") endif() - # TODO: what iff the result is false.. error or ignore? + # TODO: what if the result is false.. error or ignore? set( test_result "${result}" PARENT_SCOPE) set( test_output "${output}" PARENT_SCOPE) diff --git a/dpnp/backend/examples/example_bs.cpp b/dpnp/backend/examples/example_bs.cpp index 6fcbd9b142f..c20c6d27e29 100644 --- a/dpnp/backend/examples/example_bs.cpp +++ b/dpnp/backend/examples/example_bs.cpp @@ -144,13 +144,13 @@ void black_scholes(double *price, dpnp_memory_free_c(w1); double *halfs_mul_erf_w1 = (double *)dpnp_memory_alloc_c(size * sizeof(double)); - // halfs_mul_erf_w1 = halfs * erf_w1 + // halfs_mul_erf_w1 = half * erf_w1 dpnp_multiply_c(halfs_mul_erf_w1, half, scalar_size, &scalar_size, ndim, erf_w1, size, &size, ndim, NULL); dpnp_memory_free_c(erf_w1); double *d1 = (double *)dpnp_memory_alloc_c(size * sizeof(double)); - // d1 = halfs + halfs_mul_erf_w1 + // d1 = half + halfs_mul_erf_w1 dpnp_add_c(d1, half, scalar_size, &scalar_size, ndim, halfs_mul_erf_w1, size, &size, ndim, NULL); @@ -161,13 +161,13 @@ void black_scholes(double *price, dpnp_memory_free_c(w2); double *halfs_mul_erf_w2 = (double *)dpnp_memory_alloc_c(size * sizeof(double)); - // halfs_mul_erf_w2 = halfs * erf_w2 + // halfs_mul_erf_w2 = half * erf_w2 dpnp_multiply_c(halfs_mul_erf_w2, half, scalar_size, &scalar_size, ndim, erf_w2, size, &size, ndim, NULL); dpnp_memory_free_c(erf_w2); double *d2 = (double *)dpnp_memory_alloc_c(size * sizeof(double)); - // d2 = halfs + halfs_mul_erf_w2 + // d2 = half + halfs_mul_erf_w2 dpnp_add_c(d2, half, scalar_size, &scalar_size, ndim, halfs_mul_erf_w2, size, &size, ndim, NULL); diff --git a/dpnp/backend/extensions/blas/gemm.cpp b/dpnp/backend/extensions/blas/gemm.cpp index 00dea46c575..ae20ea9efee 100644 --- a/dpnp/backend/extensions/blas/gemm.cpp +++ b/dpnp/backend/extensions/blas/gemm.cpp @@ -181,7 +181,7 @@ std::pair } if (b_shape[1] != c_shape[1]) { throw py::value_error("The number of columns in B must be equal to " - "the number of coulmns in result array."); + "the number of columns in result array."); } size_t src_nelems = m * n; diff --git a/dpnp/backend/extensions/blas/gemm_batch.cpp b/dpnp/backend/extensions/blas/gemm_batch.cpp index a182a9c6a18..5c81ea41c97 100644 --- a/dpnp/backend/extensions/blas/gemm_batch.cpp +++ b/dpnp/backend/extensions/blas/gemm_batch.cpp @@ -198,7 +198,7 @@ std::pair } if (b_shape[matrixB_nd - 1] != c_shape[resultC_nd - 1]) { throw py::value_error("The number of columns in B must be equal to " - "the number of coulmns in result array."); + "the number of columns in result array."); } bool shapes_equal = true; diff --git a/dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp b/dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp index 49364ad1e90..d3709537b22 100644 --- a/dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp +++ b/dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp @@ -300,11 +300,11 @@ struct coord_in_space> } }; -template -struct coord_in_space> +template +struct coord_in_space> { - using CurrentAxis = typename pop_tuple_type>::element; - using OtherAxises = typename pop_tuple_type>::rest; + using CurrentAxis = typename pop_tuple_type>::element; + using OtherAxises = typename pop_tuple_type>::rest; static bool get(const DispatchT *data, int *result) { diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 0bcaf6fe62e..c1f15c6a1bb 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -1410,9 +1410,11 @@ def result_type(*arrays_and_dtypes): """ usm_arrays_and_dtypes = [ - dpnp.get_usm_ndarray(X) - if isinstance(X, (dpnp_array, dpt.usm_ndarray)) - else X + ( + dpnp.get_usm_ndarray(X) + if isinstance(X, (dpnp_array, dpt.usm_ndarray)) + else X + ) for X in arrays_and_dtypes ] return dpt.result_type(*usm_arrays_and_dtypes) diff --git a/examples/example4.py b/examples/example4.py index 9ee8292077f..cf1ed719d77 100644 --- a/examples/example4.py +++ b/examples/example4.py @@ -28,7 +28,7 @@ """Example 1. This example shows input and output types of specified function -This is usefull for development +This is useful for development """ diff --git a/pyproject.toml b/pyproject.toml index f818602954b..2f090ab069e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,12 @@ line-length = 80 target-version = ['py38', 'py39', 'py310'] +[tool.codespell] +builtin = "clear,rare,informal,names" +check-filenames = true +ignore-words-list="amin,arange,elemt,fro,hist,ith,mone,nd,nin,sinc,vart" +quiet-level = 3 + [tool.pylint.basic] include-naming-hint = true diff --git a/scripts/build_deps_dpctl_win.bat b/scripts/build_deps_dpctl_win.bat index 25f59290829..c97aef51472 100644 --- a/scripts/build_deps_dpctl_win.bat +++ b/scripts/build_deps_dpctl_win.bat @@ -10,7 +10,7 @@ set DPCTL_DIST=%CD%\dist_dpctl call conda uninstall -y dpctl -echo +++++++++++++++++++++++++ Downlowd DPCTL +++++++++++++++++++++++++++ +echo +++++++++++++++++++++++++ Download DPCTL +++++++++++++++++++++++++++ call git clone https://github.com/IntelPython/dpctl.git cd dpctl diff --git a/scripts/gen_coverage.py b/scripts/gen_coverage.py index 44022dac1ae..348e691fd3c 100644 --- a/scripts/gen_coverage.py +++ b/scripts/gen_coverage.py @@ -46,7 +46,7 @@ def run( "LLVM_TOOLS_HOME": bin_llvm, } - # extend with global enviroment variables + # extend with global environment variables env.update({k: v for k, v in os.environ.items() if k != "PATH"}) if verbose: diff --git a/setup.py b/setup.py index 174851ab770..7ee870b0a32 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ __version__ = version_mod.get_versions()["version"] """ -Set project auxilary data like readme and licence files +Set project auxiliary data like readme and licence files """ with open("README.md") as f: __readme_file__ = f.read() diff --git a/tests/helper.py b/tests/helper.py index 280e0800dff..a081fbf060b 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -235,7 +235,7 @@ def is_cpu_device(device=None): def is_win_platform(): """ - Return True if a test is runing on Windows OS, False otherwise. + Return True if a test is running on Windows OS, False otherwise. """ return platform.startswith("win") diff --git a/tests/test_linalg.py b/tests/test_linalg.py index 7d31cb66617..690e1666be0 100644 --- a/tests/test_linalg.py +++ b/tests/test_linalg.py @@ -510,7 +510,7 @@ def test_eigenvalues(self, func, shape, dtype, order): # NumPy with OneMKL and with rocSOLVER sorts in ascending order, # so w's should be directly comparable. # However, both OneMKL and rocSOLVER pick a different convention for - # constructing eigenvectors, so v's are not directly comparible and + # constructing eigenvectors, so v's are not directly comparable and # we verify them through the eigen equation A*v=w*v. if func in ("eig", "eigh"): w, _ = getattr(numpy.linalg, func)(a_order) diff --git a/tests/test_logic.py b/tests/test_logic.py index 1e110b4c717..1b8e34a6fe8 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -297,8 +297,8 @@ def test_logical_not(dtype): @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)) def test_elemwise_comparison(op, x1, x2, dtype): - create_func = ( - lambda xp, a: xp.asarray(a, dtype=dtype) + create_func = lambda xp, a: ( + xp.asarray(a, dtype=dtype) if not numpy.isscalar(a) else numpy.dtype(dtype=dtype).type(a) ) diff --git a/tests/test_random.py b/tests/test_random.py index 1fd058e2d13..36323ae51b2 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -1139,7 +1139,7 @@ def test_no_miss_numbers(self, dtype): ], ) def test_shuffle1(self, conv): - # `conv` contans test lists, arrays (of various dtypes), and multidimensional + # `conv` contains test lists, arrays (of various dtypes), and multidimensional # versions of both, c-contiguous or not. # # This test is a modification of the original tests of `numpy.random` (both the same): diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index 08db52ad70c..cdd3f9f23db 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -43,7 +43,7 @@ elif device.device_type.name not in list_of_device_type_str: pass elif device.backend.name in "opencl" and device.is_gpu: - # due to reproted crash on Windows: CMPLRLLVM-55640 + # due to reported crash on Windows: CMPLRLLVM-55640 pass else: valid_devices.append(device) diff --git a/tests/third_party/cupy/indexing_tests/test_indexing.py b/tests/third_party/cupy/indexing_tests/test_indexing.py index 7237e3991e2..01761c13a0c 100644 --- a/tests/third_party/cupy/indexing_tests/test_indexing.py +++ b/tests/third_party/cupy/indexing_tests/test_indexing.py @@ -235,7 +235,7 @@ def test_unknown_clip(self): a = xp.array([0, 3, -1, 5]) c = testing.shaped_arange((3, 4), xp, numpy.float32) with pytest.raises(ValueError): - a.choose(c, mode="unknow") + a.choose(c, mode="unknown") def test_raise(self): a = cupy.array([2]) diff --git a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py index 18107d945d9..be8e2bbed9d 100644 --- a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py +++ b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py @@ -78,7 +78,7 @@ def test_eigh_batched(self, xp, dtype): # NumPy, cuSOLVER, rocSOLVER all sort in ascending order, # so w's should be directly comparable. However, both cuSOLVER # and rocSOLVER pick a different convention for constructing - # eigenvectors, so v's are not directly comparible and we verify + # eigenvectors, so v's are not directly comparable and we verify # them through the eigen equation A*v=w*v. A = _get_hermitian(xp, a, self.UPLO) for i in range(a.shape[0]): @@ -102,7 +102,7 @@ def test_eigh_complex_batched(self, xp, dtype): # NumPy, cuSOLVER, rocSOLVER all sort in ascending order, # so w's should be directly comparable. However, both cuSOLVER # and rocSOLVER pick a different convention for constructing - # eigenvectors, so v's are not directly comparible and we verify + # eigenvectors, so v's are not directly comparable and we verify # them through the eigen equation A*v=w*v. A = _get_hermitian(xp, a, self.UPLO) diff --git a/tests/third_party/cupy/manipulation_tests/test_tiling.py b/tests/third_party/cupy/manipulation_tests/test_tiling.py index 6fc75cf8298..eb29036d248 100644 --- a/tests/third_party/cupy/manipulation_tests/test_tiling.py +++ b/tests/third_party/cupy/manipulation_tests/test_tiling.py @@ -44,7 +44,6 @@ def test_method(self): ) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestRepeatListBroadcast(unittest.TestCase): - """Test for `repeats` argument using single element list. This feature is only supported in NumPy 1.10 or later. @@ -76,7 +75,6 @@ def test_array_repeat(self, xp): {"repeats": [2], "axis": 0}, ) class TestRepeat1DListBroadcast(unittest.TestCase): - """See comment in TestRepeatListBroadcast class.""" @testing.numpy_cupy_array_equal() diff --git a/tests/third_party/cupy/sorting_tests/test_search.py b/tests/third_party/cupy/sorting_tests/test_search.py index 7f947498e64..bbf97220326 100644 --- a/tests/third_party/cupy/sorting_tests/test_search.py +++ b/tests/third_party/cupy/sorting_tests/test_search.py @@ -709,7 +709,7 @@ def test_searchsorted_minf(self, xp): class TestSearchSortedInvalid: - # Cant test unordered bins due to numpy undefined + # Can't test unordered bins due to numpy undefined # behavior for searchsorted def test_searchsorted_ndbins(self): diff --git a/tests/third_party/cupy/testing/_condition.py b/tests/third_party/cupy/testing/_condition.py index 3533ef8b84d..903a3c07be5 100644 --- a/tests/third_party/cupy/testing/_condition.py +++ b/tests/third_party/cupy/testing/_condition.py @@ -65,7 +65,7 @@ def fail(): result = QuietTestRunner().run(suite) if len(result.skipped) == 1: # "Skipped" is a special case of "Successful". - # When the test has been skipped, immedeately quit the + # When the test has been skipped, immediately quit the # test regardleess of `times` and `min_success` by raising # SkipTest exception using the original reason. instance.skipTest(result.skipped[0][1]) diff --git a/tests/third_party/cupy/testing/_helper.py b/tests/third_party/cupy/testing/_helper.py index 1afa9aa65e6..c5ab00e2b26 100644 --- a/tests/third_party/cupy/testing/_helper.py +++ b/tests/third_party/cupy/testing/_helper.py @@ -216,7 +216,7 @@ def generate_matrix( matrices. It must be broadcastable to shape :math:`(B..., K)`. Returns: - numpy.ndarray or cupy.ndarray: A random matrix that has specifiec + numpy.ndarray or cupy.ndarray: A random matrix that has specific singular values. """ @@ -264,7 +264,7 @@ def assert_warns(expected): except AttributeError: exc_name = str(expected) - raise AssertionError("%s not triggerred" % exc_name) + raise AssertionError("%s not triggered" % exc_name) class NumpyAliasTestBase(unittest.TestCase): diff --git a/tests/third_party/cupy/testing/_loops.py b/tests/third_party/cupy/testing/_loops.py index d1833b97743..d1d2313a629 100644 --- a/tests/third_party/cupy/testing/_loops.py +++ b/tests/third_party/cupy/testing/_loops.py @@ -349,7 +349,7 @@ def test_func(*args, **kw): ) ) - # Check contiguities + # Check contiguous if contiguous_check: for cupy_r, numpy_r in zip(cupy_result, numpy_result): if isinstance(numpy_r, numpy.ndarray): @@ -1149,7 +1149,7 @@ def for_signed_dtypes(name="dtype"): def for_unsigned_dtypes(name="dtype"): - """Decorator that checks the fixture with unsinged dtypes. + """Decorator that checks the fixture with unsigned dtypes. Args: name(str): Argument name to which specified dtypes are passed. diff --git a/tests_external/numpy/runtests.py b/tests_external/numpy/runtests.py index d0c605e21be..f6673f31d9a 100644 --- a/tests_external/numpy/runtests.py +++ b/tests_external/numpy/runtests.py @@ -137,7 +137,7 @@ def wrapper(*args, **kwargs): return wrapper -# setting some dummy attrubutes to dpnp +# setting some dummy attributes to dpnp unsupported_classes = [ "byte", "bytes_", @@ -278,7 +278,7 @@ def wrapper(*args, **kwargs): None, ) -# setting some dummy attrubutes to dpnp +# setting some dummy attributes to dpnp dpnp.add.reduce = dummy_func dpnp.allclose = dummy_func dpnp.csingle = dpnp.complex64 @@ -318,7 +318,7 @@ def wrapper(*args, **kwargs): dpnp.ufunc = types.FunctionType -# setting some numpy attrubutes to dpnp +# setting some numpy attributes to dpnp NUMPY_ONLY_ATTRS = [ "BUFSIZE", "_NoValue",