Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request fixes two issues in the istft implementation in jax/_src/scipy/signal.py. First, it ensures that noverlap=0 is honored instead of being overridden by the default nperseg // 2. Second, it uses nfft_int instead of nfft when performing the inverse FFT, resolving an issue when nfft is None and nperseg is odd. Corresponding unit tests have been added to verify these fixes. I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Fixes #38315
istft resolves the overlap with noverlap or nperseg_int // 2, so an explicit noverlap=0 (a valid value) is treated as unset and is replaced by the nperseg // 2 default, producing a wrong reconstruction that diverges from SciPy
Its inverse FFT is called with the raw nfft instead of the resolved nfft_int, so a one-sided transform with nfft=None and an odd nperseg drops the length correction and crashes with a broadcasting error
Also added some tests for it
(Caught a test tolerance issue where float64/complex128 cases used a flat rtol/atol=1e-4. With JAX x64 disabled, those inputs downcast to float32, making the tolerance mislabeled and too loose for true float64. Switched to dtype-specific tolerances: 1e-6 for float64/complex128 and 1e-4 for float32/complex64, matching the existing istft test behavior before submitting this pr)