Skip to content

fix: match SciPy rfft2 positional argument order - #419

Open
vera-rubin wants to merge 1 commit into
IntelPython:masterfrom
vera-rubin:fix/scipy-rfft2-norm
Open

vera-rubin wants to merge 1 commit into
IntelPython:masterfrom
vera-rubin:fix/scipy-rfft2-norm

Conversation

@vera-rubin

Copy link
Copy Markdown

Description

mkl_fft.interfaces.scipy_fft.rfft2 declares overwrite_x before norm, while scipy.fft.rfft2 is rfft2(x, s=None, axes=(-2, -1), norm=None, overwrite_x=False, workers=None, *, plan=None). A call that passes norm positionally, as SciPy allows, binds the string to overwrite_x and the normalization is silently ignored. For a 2x2 array of ones this returns (4+0j) instead of SciPy's (2+0j):

import numpy as np
from mkl_fft.interfaces import scipy_fft
x = np.ones((2, 2), dtype=np.float64)
print(scipy_fft.rfft2(x, None, (-2, -1), "ortho")[0, 0])

The fix puts norm before overwrite_x, as in SciPy and as the other functions in this module already do (rfft2 was the only one with the two swapped). A regression test compares the positional call with scipy.fft.rfft2 for all four norm values and both real precisions; it fails for "forward" and "ortho" without the fix and passes with it.

Verification

Linux x86_64, Python 3.12.3, NumPy 2.5.5, SciPy 1.18.1, MKL 2026.2, built with pip install -e . --no-build-isolation on master 84ce3f4.

  • Tests: python -m pytest mkl_fft/tests -q: 2817 passed, 2 skipped (without the fix: the 4 new forward/ortho cases fail, everything else passes).
  • Lint: not run locally.

Not verified

Pre-commit hooks, Windows and macOS: left to CI.

Checklist

  • NumPy/SciPy FFT API compatibility preserved, or the break is intentional and called out above.
  • Behavior changes have tests in mkl_fft/tests/; bug fixes have a regression test.
  • CHANGELOG.md updated under ## [dev] with a [gh-NNN] link, or the change isn't user-visible. (Entry added under ### Fixed; the link will be added once this PR has a number.)

ChipLab's AI agents
Nathan Chandrasekar

Copilot AI balanced review requested due to automatic review settings December 4, 2026 01:45

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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.

2 participants