{"record":{"id":"76639c5959a4bb4a","repo":"jax-ml/jax","slug":"unknown-fft-type-s","errorCode":null,"errorMessage":"Unknown FFT type '{s}'","messagePattern":"Unknown FFT type '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/fft.py","lineNumber":65,"sourceCode":"\n  RFFT = 2\n  \"Forward real-to-complex FFT.\"\n\n  IRFFT = 3\n  \"Inverse real-to-complex FFT.\"\n\n\ndef _str_to_fft_type(s: str) -> FftType:\n  if s in (\"fft\", \"FFT\"):\n    return FftType.FFT\n  elif s in (\"ifft\", \"IFFT\"):\n    return FftType.IFFT\n  elif s in (\"rfft\", \"RFFT\"):\n    return FftType.RFFT\n  elif s in (\"irfft\", \"IRFFT\"):\n    return FftType.IRFFT\n  else:\n    raise ValueError(f\"Unknown FFT type '{s}'\")\n\n@jit(static_argnums=(1, 2))\ndef fft(x, fft_type: FftType | str, fft_lengths: Sequence[int]):\n  if isinstance(fft_type, str):\n    typ = _str_to_fft_type(fft_type)\n  elif isinstance(fft_type, FftType):\n    typ = fft_type\n  else:\n    raise TypeError(f\"Unknown FFT type value '{fft_type}'\")\n\n  if typ == FftType.RFFT:\n    if np.iscomplexobj(x):\n      raise ValueError(\"only real valued inputs supported for rfft\")\n    x = lax.convert_element_type(x, dtypes.to_inexact_dtype(dtypes.dtype(x)))\n  else:\n    x = lax.convert_element_type(x, dtypes.to_complex_dtype(dtypes.dtype(x)))\n  if len(fft_lengths) == 0:\n    # XLA FFT doesn't support 0-rank.","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/fft.py#L47-L83","documentation":"jax.lax.fft accepts the FFT type either as a FftType enum or as one of the strings 'fft','ifft','rfft','irfft' (case-insensitive). Any other string falls through _str_to_fft_type and raises this ValueError echoing the unknown name.","triggerScenarios":"Calling jax.lax.fft(x, 'dft', (n,)) or 'fft2'/'complex_fft' — names that exist in other libraries but not here.","commonSituations":"Porting from numpy/scipy or TensorFlow naming (fft2, fftn, hfft); typos like 'fftn' expecting multi-axis behavior.","solutions":["Use one of 'fft', 'ifft', 'rfft', 'irfft' or the lax.FftType enum members","For multi-axis FFTs, pass all axes in fft_lengths with type 'fft' rather than a 'fft2' name","Prefer jax.numpy.fft wrappers (jnp.fft.fft2 etc.) for familiar names"],"exampleFix":"# before\ny = lax.fft(x, 'fft2', (64, 64))\n# after\ny = lax.fft(x, 'fft', (64, 64))  # or jnp.fft.fft2(x)","handlingStrategy":"type-guard","validationCode":"assert fft_type in ('fft','ifft','rfft','irfft') or isinstance(fft_type, lax.FftType)","typeGuard":"def valid_fft_type(t) -> bool:\n    return (isinstance(t, lax.FftType) or\n            (isinstance(t, str) and t.lower() in ('fft','ifft','rfft','irfft')))","tryCatchPattern":null,"preventionTips":["Use the lax.FftType enum instead of strings","For familiar semantics, call jnp.fft.* wrappers"],"tags":["jax","fft","api-misuse","invalid-enum-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}