Skip to content

BF: Exclude complex infinities from finite_range - #1588

Merged
effigies merged 1 commit into
nipy:masterfrom
galafis:fix-complex-finite-range
Nov 7, 2026
Merged

effigies merged 1 commit into
nipy:masterfrom
galafis:fix-complex-finite-range

Conversation

@galafis

@galafis galafis commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

finite_range explicitly supports complex arrays, but its fast path tests extrema against real +/- infinity. A complex value such as inf+1j is unequal to real infinity, so it is incorrectly accepted as finite. An infinite imaginary component can leak into the reported range in the same way.

Use isfinite for both extrema before taking the fast path. Extend the existing parameterized range tests with positive/negative real infinities, an infinite imaginary component and an all-nonfinite complex array; the existing checks exercise both return signatures and flattened inputs.

Validation: the four new cases fail on the original implementation while 21 finite-range controls pass. After the fix, the scaling, arraywriter and volumeutils test modules pass (106 passed, 68 numeric cast/overflow warnings in existing tests). Ruff lint and formatting checks and git diff --check pass. Python 3.12.14 and NumPy 2.5.4. The full package suite was not run.

@effigies effigies left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a straightforward fix, thanks.

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.49%. Comparing base (fdacbf0) to head (a9bf7b8).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1588      +/-   ##
==========================================
- Coverage   95.49%   95.49%   -0.01%     
==========================================
  Files         209      209              
  Lines       30123    30123              
  Branches     5201     5201              
==========================================
- Hits        28766    28765       -1     
  Misses        928      928              
- Partials      429      430       +1     

☔ View full report in Codecov by Harness.
📢 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.

@effigies
effigies merged commit b6a5f46 into nipy:master Nov 7, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants