jax-ml/jax · error · NotImplementedError
overwrite_data argument not implemented.
Error message
overwrite_data argument not implemented.
What it means
jax.scipy.signal.detrend does not implement the overwrite_data parameter (in-place detrending is incompatible with JAX's immutable arrays and functional model). Passing any non-None value raises NotImplementedError.
Source
Thrown at jax/_src/scipy/signal.py:528
>>> detrended = jax.scipy.signal.detrend(data)
>>> with jnp.printoptions(precision=3, suppress=True): # suppress float error
... print("Detrended:", detrended)
... print("Underlying trend:", data - detrended)
Detrended: [-1. -0. 2. -0. -1.]
Underlying trend: [ 2. 4. 6. 8. 10.]
Removing a constant trend from the data:
>>> detrended = jax.scipy.signal.detrend(data, type='constant')
>>> with jnp.printoptions(precision=3): # suppress float error
... print("Detrended:", detrended)
... print("Underlying trend:", data - detrended)
Detrended: [-5. -2. 2. 2. 3.]
Underlying trend: [6. 6. 6. 6. 6.]
"""
if overwrite_data is not None:
raise NotImplementedError("overwrite_data argument not implemented.")
if type not in ['constant', 'linear']:
raise ValueError("Trend type must be 'linear' or 'constant'.")
data_arr, = promote_dtypes_inexact(jnp.asarray(data))
if type == 'constant':
return data_arr - data_arr.mean(axis, keepdims=True)
else:
N = data_arr.shape[axis]
# bp is static, so we use np operations to avoid pushing to device.
bp_arr = np.sort(np.unique(np.r_[0, bp, N]))
if bp_arr[0] < 0 or bp_arr[-1] > N:
raise ValueError("Breakpoints must be non-negative and less than length of data along given axis.")
data_arr = jnp.moveaxis(data_arr, axis, 0)
shape = data_arr.shape
data_arr = data_arr.reshape(N, -1)
for m in range(len(bp_arr) - 1):
Npts = bp_arr[m + 1] - bp_arr[m]
A = jnp.vstack([
jnp.ones(Npts, dtype=data_arr.dtype),View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Drop the argument (call detrend(data) or overwrite_data=None) since JAX returns a new array anyway
- Assign the result: data = jax.scipy.signal.detrend(data)
Example fix
// before out = jax.scipy.signal.detrend(data, type='linear', overwrite_data=True) // after out = jax.scipy.signal.detrend(data, type='linear')
Defensive patterns
Strategy: validation
Validate before calling
kwargs = {} # never pass overwrite_data to JAX detrend
out = jax.scipy.signal.detrend(data, **kwargs) Prevention
- Strip scipy-only kwargs when porting to jax.scipy
- Remember JAX arrays are immutable; reassign results instead
When it happens
Trigger: Calling detrend(data, overwrite_data=True) as copied from scipy.signal.detrend usage.
Common situations: Porting scipy signal-preprocessing scripts wholesale; defaulting all scipy kwargs to True defensively.
Related errors
- convolve2d() only supports boundary='fill', fillvalue=0
- correlate2d() only supports boundary='fill', fillvalue=0
- Trend type must be 'linear' or 'constant'.
- Breakpoints must be non-negative and less than length of dat
- Computations for m!=n are not yet supported.
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/0d7514e1ce93f088.
Report an issue: GitHub.