Skip to content

Adds runtime warning on divide-by-zero, fixes use of "out" and "where" in arctan2#5315

Open
drculhane wants to merge 3 commits intoBears-R-Us:mainfrom
drculhane:Alternate-Closes-5132
Open

Adds runtime warning on divide-by-zero, fixes use of "out" and "where" in arctan2#5315
drculhane wants to merge 3 commits intoBears-R-Us:mainfrom
drculhane:Alternate-Closes-5132

Conversation

@drculhane
Copy link
Contributor

Closes #5132 and #5149.

This takes the place of PR #5204.

  • The binops in pdarrayclass.py now give a RuntimeWarning or a Floating Point Error (or nothing) if / or // cause a divide-by-zero, depending on the "divide" setting of ak.errstate.

  • Because the RuntimeWarning surfaced an issue in arctan2, I've rewritten that function somewhat. It now has an "out" parameter matching numpy, and uses the "where" parameter correctly.

  • arctan2 now also accepts bool inputs, which requires special handling. np.arctan2, if given bool inputs, returns np.float16, which arkouda doesn't like.

  • Most of the original arctan2 function remains as _arctan2_, because (subjective opinion here) I think that calling it as a separate function improves the readability of the code.

  • In doing this rewriting, I removed some mypy ignores that are no longer needed.

  • I rewrote the unit tests for arctan2 to use our newer assert functions. I think this cleans up that code significantly. In the cases that use "where," I check both the returned result, and the returned "out" pdarray, since they should match.

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@c235a25). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5315   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         5           
  Lines           ?       115           
  Branches        ?         0           
========================================
  Hits            ?       115           
  Misses          ?         0           
  Partials        ?         0           
Flag Coverage Δ
python-coverage 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@drculhane drculhane force-pushed the Alternate-Closes-5132 branch from 8864961 to 566cc9d Compare January 23, 2026 13:56
@drculhane drculhane marked this pull request as ready for review January 23, 2026 13:58
Copy link
Contributor

@ajpotts ajpotts left a comment

Choose a reason for hiding this comment

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

Nice work.

@ajpotts ajpotts enabled auto-merge February 3, 2026 17:55
@ajpotts ajpotts disabled auto-merge February 3, 2026 21:29
@ajpotts ajpotts enabled auto-merge February 3, 2026 21:29
@drculhane drculhane force-pushed the Alternate-Closes-5132 branch from cc36f0b to 8864961 Compare February 4, 2026 12:32
@drculhane drculhane force-pushed the Alternate-Closes-5132 branch from 2eb0ae4 to a795292 Compare February 4, 2026 12:49
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.

floor division by zero doesn't match numpy

2 participants