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

Add pre-commit hooks #1448

Merged
merged 2 commits into from
Jun 19, 2023
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
19 changes: 18 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 11 additions & 11 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Copyright (c) 2016-2020, Intel Corporation
Copyright (c) 2016-2023, Intel Corporation
antonwolfy marked this conversation as resolved.
Show resolved Hide resolved
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.
2 changes: 1 addition & 1 deletion benchmarks/pytest_benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 11 additions & 11 deletions benchmarks/pytest_benchmark/test_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Empty file modified conda-recipe/build.sh
100644 → 100755
Empty file.
Empty file modified conda-recipe/run_test.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion doc/_templates/autosummary/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
{% for item in attributes %}
.. autoattribute:: {{ item }}
{%- endfor %}
{% endif %} {% endblock %}
{% endif %} {% endblock %}
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/docstring_template.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/linalg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Matrix and vector products
.. autosummary::
:toctree: generated/
:nosignatures:

dpnp.cross
dpnp.dot
dpnp.linalg.multi_dot
Expand Down
2 changes: 1 addition & 1 deletion doc/reference/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,4 @@ Miscellaneous
dpnp.blackman
dpnp.hamming
dpnp.hanning
dpnp.kaiser
dpnp.kaiser
6 changes: 3 additions & 3 deletions dpnp/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/cmake/Modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
environment.
16 changes: 8 additions & 8 deletions dpnp/backend/cmake/Modules/TBBConfig.cmake
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand Down
Empty file modified dpnp/backend/cmake/Modules/oneDPLConfig.cmake
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example10.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example11.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example3.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example5.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example7.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example8.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example9.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example_bs.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/examples/example_experimental_iface.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/include/dpnp_gen_1arg_2type_tbl.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/include/dpnp_iface_fft.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/include/dpnp_iface_random.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/kernels/dpnp_krnl_common.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions dpnp/backend/kernels/dpnp_krnl_linalg.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -1038,7 +1038,7 @@ void func_map_init_linalg_func(func_map_t& fmap)
(void*)dpnp_svd_default_c<double, double, double>};
fmap[DPNPFuncName::DPNP_FN_SVD][eft_C128][eft_C128] = {
eft_C128, (void*)dpnp_svd_default_c<std::complex<double>, std::complex<double>, double>};

fmap[DPNPFuncName::DPNP_FN_SVD_EXT][eft_INT][eft_INT] = {eft_DBL,
(void*)dpnp_svd_ext_c<int32_t, double, double>};
fmap[DPNPFuncName::DPNP_FN_SVD_EXT][eft_LNG][eft_LNG] = {eft_DBL,
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/kernels/dpnp_krnl_random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,7 @@ void func_map_init_random(func_map_t& fmap)
(void*)dpnp_rng_binomial_default_c<int32_t>};

fmap[DPNPFuncName::DPNP_FN_RNG_BINOMIAL_EXT][eft_INT][eft_INT] = {eft_INT,
(void*)dpnp_rng_binomial_ext_c<int32_t>};
(void*)dpnp_rng_binomial_ext_c<int32_t>};

fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_DBL][eft_DBL] = {eft_DBL,
(void*)dpnp_rng_chisquare_default_c<double>};
Expand Down
2 changes: 1 addition & 1 deletion dpnp/backend/kernels/dpnp_krnl_reduction.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading