Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This release is compatible with NumPy 2.4.5.
* Fixed `conda build` command syntax in GitHub workflows and documentation to use `conda-build` [#2888](https://github.com/IntelPython/dpnp/pull/2888)
* Fixed incorrect `dpnp.tensor.acosh` result for `complex(±0, NaN)` special case to match the Python Array API specification [#2914](https://github.com/IntelPython/dpnp/pull/2914)
* Fixed fork PR documentation workflow failures by implementing conditional publishing strategy: upstream PRs publish to GitHub Pages with comment, fork PRs upload artifacts [#2910](https://github.com/IntelPython/dpnp/pull/2910)
* Fixed incorrect `dpnp.tensor.expm1` result for `complex(±0, 0)` special case on CPU to match the Python Array API specification [#2926](https://github.com/IntelPython/dpnp/pull/2926)

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ struct Expm1Functor
}
}

if (x == realT(0) && y == realT(0)) {
return resT{realT(0), y};
}

// x, y finite numbers
const realT cosY_val = sycl::cos(y);
const realT sinY_val = (y == 0) ? y : sycl::sin(y);
Expand Down
11 changes: 10 additions & 1 deletion dpnp/tests/tensor/elementwise/test_expm1.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def test_expm1_special_cases():
num_finite = 1.0
vals = [
complex(0.0, 0.0),
complex(-0.0, 0.0),
complex(num_finite, dpt.inf),
complex(num_finite, dpt.nan),
complex(dpt.inf, 0.0),
Expand All @@ -165,6 +166,7 @@ def test_expm1_special_cases():
c_nan = complex(np.nan, np.nan)
res = np.asarray(
[
complex(0.0, 0.0),
complex(0.0, 0.0),
c_nan,
c_nan,
Expand All @@ -184,4 +186,11 @@ def test_expm1_special_cases():

tol = dpt.finfo(X.dtype).resolution
with np.errstate(invalid="ignore"):
assert_allclose(dpt.asnumpy(dpt.expm1(X)), res, atol=tol, rtol=tol)
Y = dpt.asnumpy(dpt.expm1(X))
assert_allclose(Y, res, atol=tol, rtol=tol)

# assert_allclose treats +0 == -0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to validate the sign in other cases also when imag=0.0 ?

# verify sign bits for zero cases
for i in (0, 1):
assert not np.signbit(Y[i].real)
assert not np.signbit(Y[i].imag)
Loading