Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend pre-commit hooks with codespell #1798

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{% endblock %}

..
Atributes
Attributes

{% block attributes %} {% if attributes %}

Expand Down
2 changes: 1 addition & 1 deletion doc/docstring_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/cmake/Modules/IntelSYCLConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions dpnp/backend/examples/example_bs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double, double, double>(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<double, double, double>(d1, half, scalar_size, &scalar_size,
ndim, halfs_mul_erf_w1, size, &size,
ndim, NULL);
Expand All @@ -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<double, double, double>(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<double, double, double>(d2, half, scalar_size, &scalar_size,
ndim, halfs_mul_erf_w2, size, &size,
ndim, NULL);
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/blas/gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ std::pair<sycl::event, sycl::event>
}
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;
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/extensions/blas/gemm_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ std::pair<sycl::event, sycl::event>
}
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;
Expand Down
8 changes: 4 additions & 4 deletions dpnp/backend/extensions/sycl_ext/dispatcher_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,11 @@ struct coord_in_space<DispatchT, Matcher, std::tuple<CurrentAxis>>
}
};

template <typename DispatchT, typename Matcher, typename... Axises>
struct coord_in_space<DispatchT, Matcher, std::tuple<Axises...>>
template <typename DispatchT, typename Matcher, typename... Axes>
struct coord_in_space<DispatchT, Matcher, std::tuple<Axes...>>
{
using CurrentAxis = typename pop_tuple_type<std::tuple<Axises...>>::element;
using OtherAxises = typename pop_tuple_type<std::tuple<Axises...>>::rest;
using CurrentAxis = typename pop_tuple_type<std::tuple<Axes...>>::element;
using OtherAxises = typename pop_tuple_type<std::tuple<Axes...>>::rest;

static bool get(const DispatchT *data, int *result)
{
Expand Down
8 changes: 5 additions & 3 deletions dpnp/dpnp_iface_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/example4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

"""

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_deps_dpctl_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion scripts/gen_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sycl_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/third_party/cupy/indexing_tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions tests/third_party/cupy/linalg_tests/test_eigenvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand All @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions tests/third_party/cupy/manipulation_tests/test_tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/third_party/cupy/sorting_tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/third_party/cupy/testing/_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions tests/third_party/cupy/testing/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/third_party/cupy/testing/_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions tests_external/numpy/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_",
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
Loading