{"record":{"id":"0d7514e1ce93f088","repo":"jax-ml/jax","slug":"overwrite-data-argument-not-implemented","errorCode":null,"errorMessage":"overwrite_data argument not implemented.","messagePattern":"overwrite_data argument not implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/signal.py","lineNumber":528,"sourceCode":"\n    >>> detrended = jax.scipy.signal.detrend(data)\n    >>> with jnp.printoptions(precision=3, suppress=True):  # suppress float error\n    ...   print(\"Detrended:\", detrended)\n    ...   print(\"Underlying trend:\", data - detrended)\n    Detrended: [-1. -0.  2. -0. -1.]\n    Underlying trend: [ 2.  4.  6.  8. 10.]\n\n    Removing a constant trend from the data:\n\n    >>> detrended = jax.scipy.signal.detrend(data, type='constant')\n    >>> with jnp.printoptions(precision=3):  # suppress float error\n    ...   print(\"Detrended:\", detrended)\n    ...   print(\"Underlying trend:\", data - detrended)\n    Detrended: [-5. -2.  2.  2.  3.]\n    Underlying trend: [6. 6. 6. 6. 6.]\n  \"\"\"\n  if overwrite_data is not None:\n    raise NotImplementedError(\"overwrite_data argument not implemented.\")\n  if type not in ['constant', 'linear']:\n    raise ValueError(\"Trend type must be 'linear' or 'constant'.\")\n  data_arr, = promote_dtypes_inexact(jnp.asarray(data))\n  if type == 'constant':\n    return data_arr - data_arr.mean(axis, keepdims=True)\n  else:\n    N = data_arr.shape[axis]\n    # bp is static, so we use np operations to avoid pushing to device.\n    bp_arr = np.sort(np.unique(np.r_[0, bp, N]))\n    if bp_arr[0] < 0 or bp_arr[-1] > N:\n      raise ValueError(\"Breakpoints must be non-negative and less than length of data along given axis.\")\n    data_arr = jnp.moveaxis(data_arr, axis, 0)\n    shape = data_arr.shape\n    data_arr = data_arr.reshape(N, -1)\n    for m in range(len(bp_arr) - 1):\n      Npts = bp_arr[m + 1] - bp_arr[m]\n      A = jnp.vstack([\n        jnp.ones(Npts, dtype=data_arr.dtype),","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/signal.py#L510-L546","documentation":"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.","triggerScenarios":"Calling detrend(data, overwrite_data=True) as copied from scipy.signal.detrend usage.","commonSituations":"Porting scipy signal-preprocessing scripts wholesale; defaulting all scipy kwargs to True defensively.","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)"],"exampleFix":"// before\nout = jax.scipy.signal.detrend(data, type='linear', overwrite_data=True)\n// after\nout = jax.scipy.signal.detrend(data, type='linear')","handlingStrategy":"validation","validationCode":"kwargs = {}  # never pass overwrite_data to JAX detrend\nout = jax.scipy.signal.detrend(data, **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip scipy-only kwargs when porting to jax.scipy","Remember JAX arrays are immutable; reassign results instead"],"tags":["jax","scipy","detrend","not-implemented","immutable-arrays"],"backgroundTag":"unsupported-feature-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}