{"record":{"id":"f8372af0bff62b08","repo":"jax-ml/jax","slug":"got-method-expected-auto-fft-or-direct","errorCode":null,"errorMessage":"Got {method=}; expected 'auto', 'fft', or 'direct'.","messagePattern":"Got (.+?); expected 'auto', 'fft', or 'direct'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/signal.py","lineNumber":260,"sourceCode":"\n    Specifying ``mode = 'same'`` returns a centered convolution the same size\n    as the first input:\n\n    >>> jax.scipy.signal.convolve(x, y, mode='same')\n    Array([3., 6., 7., 6., 3.], dtype=float32)\n\n    Specifying ``mode = 'valid'`` returns only the portion where the two arrays\n    fully overlap:\n\n    >>> jax.scipy.signal.convolve(x, y, mode='valid')\n    Array([6., 7., 6.], dtype=float32)\n  \"\"\"\n  if method == 'fft':\n    return fftconvolve(in1, in2, mode=mode)\n  elif method in ['direct', 'auto']:\n    return _convolve_nd(in1, in2, mode, precision=precision)\n  else:\n    raise ValueError(f\"Got {method=}; expected 'auto', 'fft', or 'direct'.\")\n\n\ndef convolve2d(in1: Array, in2: Array, mode: ModeString = 'full', boundary: str = 'fill',\n               fillvalue: float = 0, precision: PrecisionLike = None) -> Array:\n  \"\"\"Convolution of two 2-dimensional arrays.\n\n  JAX implementation of :func:`scipy.signal.convolve2d`.\n\n  Args:\n    in1: left-hand input to the convolution. Must have ``in1.ndim == 2``.\n    in2: right-hand input to the convolution. Must have ``in2.ndim == 2``.\n    mode: controls the size of the output. Available operations are:\n\n      * ``\"full\"``: (default) output the full convolution of the inputs.\n      * ``\"same\"``: return a centered portion of the ``\"full\"`` output which\n        is the same size as ``in1``.\n      * ``\"valid\"``: return the portion of the ``\"full\"`` output which do not\n        depend on padding at the array edges.","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/signal.py#L242-L278","documentation":"The public convolve/correlate 'method' parameter selects the implementation: 'fft' uses fftconvolve, 'direct'/'auto' use the spatial path. Any other string raises this error listing the accepted values.","triggerScenarios":"jax.scipy.signal.convolve(x, y, method='fft ') (trailing space), method='FFT', or method='auto' misspelled; passing a scipy-style method default copied incorrectly.","commonSituations":"Config-driven code where method comes from a YAML/env string; case or whitespace mismatches; version drift from scipy APIs that accept different method names.","solutions":["Set method to exactly 'auto', 'fft', or 'direct'","Strip/lowercase external strings before passing: method = method.strip().lower()","Default to omitting method (defaults to 'auto') when unsure"],"exampleFix":"// before\nconvolve(x, y, method=os.environ['CONV_METHOD'])\n// after\nconvolve(x, y, method=os.environ['CONV_METHOD'].strip().lower())","handlingStrategy":"validation","validationCode":"METHODS = ('auto', 'fft', 'direct')\nassert method in METHODS, f'method must be one of {METHODS}'","typeGuard":"def is_valid_method(m: str) -> bool:\n    return m in ('auto', 'fft', 'direct')","tryCatchPattern":null,"preventionTips":["Strip().lower() external method strings before passing","Omit method to use the safe 'auto' default"],"tags":["jax","scipy","convolution","invalid-argument-value"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}