Skip to content

Fix dpnp.tensor.expm1 handling of complex(+-0, 0) #2926

Merged
vlad-perevezentsev merged 6 commits into
masterfrom
fix_expm1_complex
May 27, 2026
Merged

Fix dpnp.tensor.expm1 handling of complex(+-0, 0) #2926
vlad-perevezentsev merged 6 commits into
masterfrom
fix_expm1_complex

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
Contributor

This PR proposes to fix issue #2878 where dpnp.tensor.expm1(complex(-0.0, 0.0)) returned -0.0 + 0.0j on CPU instead of 0.0 + 0.0j as required by the Array API specification

The fix adds an explicit special-case branch for complex(±0, 0) in expm1.hpp so CPU and GPU behavior are now consistent and compliant with the specification.

Also test_expm1_special_cases test was extended to cover complex(-0.0, 0.0)

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@github-actions
Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2926/index.html

Comment thread dpnp/tests/tensor/elementwise/test_expm1.py
@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 19, 2026

Coverage Status

coverage: 78.242%. remained the same — fix_expm1_complex into master

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_53 ran successfully.
Passed: 1357
Failed: 3
Skipped: 16

@vlad-perevezentsev vlad-perevezentsev linked an issue May 19, 2026 that may be closed by this pull request
@vlad-perevezentsev
Copy link
Copy Markdown
Contributor Author

@ndgrigorian this is RFR

Copy link
Copy Markdown
Collaborator

@ndgrigorian ndgrigorian left a comment

Choose a reason for hiding this comment

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

LGTM

@vlad-perevezentsev vlad-perevezentsev merged commit 87510bb into master May 27, 2026
107 of 108 checks passed
@vlad-perevezentsev vlad-perevezentsev deleted the fix_expm1_complex branch May 27, 2026 11:56
github-actions Bot added a commit that referenced this pull request May 27, 2026
This PR proposes to fix issue #2878 where
`dpnp.tensor.expm1(complex(-0.0, 0.0))` returned `-0.0 + 0.0j` on CPU
instead of `0.0 + 0.0j` as required by the Array API specification

The fix adds an explicit special-case branch for `complex(±0, 0)` in
`expm1.hpp` so CPU and GPU behavior are now consistent and compliant
with the specification.

Also `test_expm1_special_cases` test was extended to cover
`complex(-0.0, 0.0)` 87510bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expm1 returns wrong result for -0 + 0 j on CPU

4 participants