Skip to content

Commit

Permalink
Merge branch 'master' into correlate_fft
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKalistratov authored Feb 4, 2025
2 parents ad361dd + 2ac196c commit cead9a7
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
# https://github.com/marketplace/actions/doxygen-action
- name: Build backend docs
uses: mattnotmitt/doxygen-action@cbe72c8e402e8a3faa1f0b247ef90aa6c8e4ce74 # v1.9.8
uses: mattnotmitt/doxygen-action@b84fe17600245bb5db3d6c247cc274ea98c15a3b # v1.12
with:
working-directory: 'dpnp/backend/doc'

Expand Down Expand Up @@ -266,6 +266,7 @@ jobs:
- name: Modify the comment with URL to official documentation
uses: mshick/add-pr-comment@b8f338c590a895d50bcbfa6c5859251edc8952fc # v2.8.2
with:
message-id: url_to_docs
find: |
View rendered docs @.+
replace: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openssf-scorecard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f6091c0113d1dcf9b98e269ee48e8a7e51b7bdd4 # v3.28.5
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: '3.13'

Expand Down
17 changes: 12 additions & 5 deletions dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

import dpnp as cp
from dpnp.tests.helper import has_support_aspect64
from dpnp.tests.third_party.cupy import testing

# TODO: remove once all dtype aliases added
Expand All @@ -15,8 +16,6 @@
"uint8(1) + 2",
"array([1], uint8) + int64(1)",
"array([1], uint8) + array(1, int64)",
"array([1.], float32) + float64(1.)",
"array([1.], float32) + array(1., float64)",
"array([1], uint8) + 1",
"array([1], uint8) + 200",
"array([100], uint8) + 200",
Expand All @@ -25,7 +24,6 @@
"uint8(100) + 200",
"float32(1) + 3e100",
"array([1.0], float32) + 1e-14 == 1.0",
"array([0.1], float32) == float64(0.1)",
"array(1.0, float32) + 1e-14 == 1.0",
"array([1.], float32) + 3",
"array([1.], float32) + int64(3)",
Expand All @@ -42,25 +40,34 @@
"1.0 + array([1, 2, 3], int8)",
"array([1], float32) + 1j",
]
if has_support_aspect64():
examples += [
"array([1.], float32) + float64(1.)",
"array([1.], float32) + array(1., float64)",
"array([0.1], float32) == float64(0.1)",
]


@pytest.mark.filterwarnings("ignore::RuntimeWarning")
@testing.with_requires("numpy>=2.0")
@pytest.mark.parametrize("example", examples)
@testing.numpy_cupy_allclose(atol=1e-15, accept_error=OverflowError)
@testing.numpy_cupy_allclose(
atol=1e-15, accept_error=OverflowError, type_check=has_support_aspect64()
)
def test_nep50_examples(xp, example):
dct = {
"array": xp.array,
"uint8": xp.uint8,
"int64": xp.int64,
"float32": xp.float32,
"float64": xp.float64,
"int16": xp.int16,
"bool_": xp.bool_,
"int32": xp.int32,
"complex64": xp.complex64,
"int8": xp.int8,
}
if has_support_aspect64():
dct["float64"] = xp.float64

if isinstance(example, tuple):
example, mesg = example
Expand Down
2 changes: 1 addition & 1 deletion dpnp/tests/third_party/cupy/linalg_tests/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class TestLinalgCrossProduct(unittest.TestCase):

@testing.with_requires("numpy>=2.0")
@testing.for_all_dtypes_combination(["dtype_a", "dtype_b"])
@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(type_check=has_support_aspect64())
def test_cross(self, xp, dtype_a, dtype_b):
if dtype_a == dtype_b == numpy.bool_:
# cross does not support bool-bool inputs.
Expand Down
2 changes: 1 addition & 1 deletion dpnp/tests/third_party/cupy/math_tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_fabs(self, xp, dtype):

@testing.with_requires("numpy>=2.0")
@testing.for_all_dtypes(no_complex=True)
@testing.numpy_cupy_allclose(atol=1e-5)
@testing.numpy_cupy_allclose(atol=1e-5, type_check=has_support_aspect64())
def test_fabs_negative(self, xp, dtype):
if numpy.issubdtype(dtype, numpy.unsignedinteger):
pytest.skip("trying to set negative value to unsigned integer")
Expand Down
40 changes: 32 additions & 8 deletions dpnp/tests/third_party/cupy/math_tests/test_sumprod.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,51 +1162,75 @@ def test_ediff1d_ed2(self, xp, dtype):
class TestTrapezoid:

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_1dim(self, xp, dtype):
a = testing.shaped_arange((5,), xp, dtype)
return xp.trapezoid(a)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_1dim_with_x(self, xp, dtype):
a = testing.shaped_arange((5,), xp, dtype)
x = testing.shaped_arange((5,), xp, dtype)
return xp.trapezoid(a, x=x)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_1dim_with_dx(self, xp, dtype):
a = testing.shaped_arange((5,), xp, dtype)
return xp.trapezoid(a, dx=0.1)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_2dim_without_axis(self, xp, dtype):
a = testing.shaped_arange((4, 5), xp, dtype)
return xp.trapezoid(a)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_2dim_with_axis(self, xp, dtype):
a = testing.shaped_arange((4, 5), xp, dtype)
return xp.trapezoid(a, axis=-2)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_2dim_with_x_and_axis(self, xp, dtype):
a = testing.shaped_arange((4, 5), xp, dtype)
x = testing.shaped_arange((5,), xp, dtype)
return xp.trapezoid(a, x=x, axis=1)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_2dim_with_dx_and_axis(self, xp, dtype):
a = testing.shaped_arange((4, 5), xp, dtype)
return xp.trapezoid(a, dx=0.1, axis=1)

@testing.for_all_dtypes()
@testing.numpy_cupy_allclose(rtol={numpy.float16: 1e-1, "default": 1e-7})
@testing.numpy_cupy_allclose(
rtol={numpy.float16: 1e-1, "default": 1e-7},
type_check=has_support_aspect64(),
)
def test_trapz_1dim_with_x_and_dx(self, xp, dtype):
a = testing.shaped_arange((5,), xp, dtype)
x = testing.shaped_arange((5,), xp, dtype)
Expand Down
12 changes: 6 additions & 6 deletions dpnp/tests/third_party/cupy/testing/_loops.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,12 @@ def numpy_cupy_allclose(
# When `type_check` is `False`, cupy result and numpy result may have
# different dtypes so we can not determine the dtype to use from the
# tolerance associations.
if not type_check:
if isinstance(rtol, dict) or isinstance(atol, dict):
raise TypeError(
"When `type_check` is `False`, `rtol` and `atol` "
"must be supplied as float."
)
# if not type_check:
# if isinstance(rtol, dict) or isinstance(atol, dict):
# raise TypeError(
# "When `type_check` is `False`, `rtol` and `atol` "
# "must be supplied as float."
# )

def check_func(c, n):
rtol1, atol1 = _resolve_tolerance(type_check, c, rtol, atol)
Expand Down

0 comments on commit cead9a7

Please sign in to comment.