Skip to content

feat(fft): numpy.fft on arrays, over go-fft - #43

Merged
tannevaled merged 1 commit into
mainfrom
feat/fft
Oct 9, 2026
Merged

tannevaled merged 1 commit into
mainfrom
feat/fft

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

numpy.fft on arrays: a new fft subpackage applying go-fft v0.23.0's transforms along any axes of an Array, with numpy's n/s, axes and norm.

What

  • FFT/IFFT, RFFT/IRFFT, HFFT/IHFFT, FFT2/IFFT2/RFFT2/IRFFT2, FFTN/IFFTN/RFFTN/IRFFTN (each with a ...With(a, Options{S, Axes, Norm}) form), FFTFreq/RFFTFreq, FFTShift/IFFTShift.
  • As in NumPy 2, float32/complex64 inputs stay in single precision (go-fft's ...32 transforms); a complex input to a real transform is an error.
  • An axis listed twice is transformed twice, in numpy's order (rfftn: the real pass first, then the others; lengths fixed before the first pass). go-fft refuses a repeated axis, so those calls run one axis at a time.
  • The module now requires github.com/go-fft/fft (zero dependencies of its own); only importers of ndarray/fft compile it.

Verification

  • fft/testdata/cases.py → cases.json (embedded): 617 numpy.fft 2.5.3 cases over 5 dtypes × 4 shapes × 33 argument sets, 110 of them errors in numpy that must be errors here. All pass: dtype and shape exact, values within 64 eps of the result's magnitude.
  • Negative control: computing hfft with the unswapped norm fails 20 cases.
  • 100% coverage; README gains the dtypes and the fft package.

🤖 Generated with Claude Code

Package fft applies go-fft's transforms along any axes of an array, with
numpy's n/s, axes and norm: FFT/IFFT, RFFT/IRFFT, HFFT/IHFFT, the 2-D and
N-D forms, FFTFreq/RFFTFreq and FFTShift/IFFTShift. As in NumPy 2,
float32 and complex64 inputs stay in single precision; a complex input to
a real transform is an error. An axis listed twice is transformed twice,
in numpy's order (go-fft refuses it, so those calls run one axis at a time).

Checked against numpy.fft 2.5.3: 617 cases over 5 dtypes, 4 shapes and 33
argument sets (110 of them errors in both), within 64 eps of the result's
magnitude. Swapping hfft's scaling fails 20 of them. Coverage 100%.

Also: README describes the dtypes and the fft package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 90c2da1 into main Oct 9, 2026
12 checks passed
@tannevaled
tannevaled deleted the feat/fft branch October 9, 2026 19:14
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.

1 participant