From da4f18267d25515b2c36e3f8e65182e9573566e6 Mon Sep 17 00:00:00 2001 From: Nathan Chandrasekar <322284620+vera-rubin@users.noreply.github.com> Date: Thu, 3 Dec 2026 20:36:51 -0500 Subject: [PATCH] fix: match SciPy rfft2 positional argument order --- CHANGELOG.md | 1 + mkl_fft/interfaces/_scipy_fft.py | 2 +- mkl_fft/tests/test_interfaces.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac22bf04..577a62d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * `irfft` with `out=` now writes directly into `out` when the cast or zero-padded copy of a non-contiguous input has the same memory order as `out`, avoiding a temporary array and an extra copy [gh-396](https://github.com/IntelPython/mkl_fft/pull/396) ### Fixed +* Fixed `mkl_fft.interfaces.scipy_fft.rfft2` ignoring a positional `norm` argument by matching SciPy's parameter order * Zero-padding (`n` larger than the input length along the axis) of input that is both C- and F-contiguous, such as shape `(m, 1)` padded along axis 1, now gives a C-contiguous result as NumPy does instead of a Fortran-contiguous one, so a C-ordered `out` is also written directly without a temporary copy [gh-397](https://github.com/IntelPython/mkl_fft/pull/397) ## [2.4.0] - 2026-10-16 diff --git a/mkl_fft/interfaces/_scipy_fft.py b/mkl_fft/interfaces/_scipy_fft.py index f9e84042..a530f3c5 100644 --- a/mkl_fft/interfaces/_scipy_fft.py +++ b/mkl_fft/interfaces/_scipy_fft.py @@ -410,8 +410,8 @@ def rfft2( x, s=None, axes=(-2, -1), - overwrite_x=False, norm=None, + overwrite_x=False, workers=None, *, plan=None, diff --git a/mkl_fft/tests/test_interfaces.py b/mkl_fft/tests/test_interfaces.py index 14b8c4a0..ec01ddb8 100644 --- a/mkl_fft/tests/test_interfaces.py +++ b/mkl_fft/tests/test_interfaces.py @@ -93,6 +93,16 @@ def test_scipy_rfft(norm, dtype): assert np.allclose(x, xx, atol=tol, rtol=tol) +@pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"]) +@pytest.mark.parametrize("dtype", [np.float32, np.float64]) +def test_scipy_rfft2_positional_norm(norm, dtype): + sp_fft = pytest.importorskip("scipy.fft", reason="requires scipy") + x = np.ones((2, 2), dtype=dtype) + result = mfi.scipy_fft.rfft2(x, None, (-2, -1), norm) + expected = sp_fft.rfft2(x, norm=norm) + np.testing.assert_allclose(result, expected) + + @pytest.mark.parametrize("norm", [None, "forward", "backward", "ortho"]) @pytest.mark.parametrize("dtype", [np.float32, np.float64]) def test_numpy_rfft(norm, dtype):