Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This release is compatible with NumPy 2.4.5.
* Fixed missing `libtensor` headers in the installed `dpnp` package [#2915](https://github.com/IntelPython/dpnp/pull/2915)
* Fixed boolean mask indexing to raise `IndexError` when mask dimensions don't match the indexed array dimensions, aligning with NumPy behavior. Previously, incompatible boolean masks silently returned incorrect results instead of raising an error [#2929](https://github.com/IntelPython/dpnp/pull/2929)
* Fixed a bug in `astype` where casting floating point types to unsigned integral types could cause an intermediate signed integral type to overflow, leading to incorrect results [#2930](https://github.com/IntelPython/dpnp/pull/2930)
* 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
10 changes: 9 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,10 @@ 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
Comment thread
vlad-perevezentsev marked this conversation as resolved.
# verify sign bits for zero real parts
for i in (0, 1):
assert not np.signbit(Y[i].real)
Loading