formachines / errata

Errata / PyPI / scipy

scipy.optimize.nnls removed in scipy 1.18.1

In our sandbox runs up to 2026-10-27, gpt-6.1-sol wrote x, residual_norm = nnls(A, b, atol=1e-8) for scipy. It fails on 1.18.1 with TypeError (changed between 1.17.1 and 1.18.1). Use x, residual_norm = nnls(A, b) instead.

What to do
replace the line
Output
same on one example
Patch
applies word for word
Auto-apply
allowed
Seen in
1 model
Worked / failed
2 / 0
Last verified
2026-10-27

What to do

Replace the old line with the new one; the rest of the code can stay.

Automatic application: allowed — proof.equivalent is true and the patch applies word for word. Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own. The change itself is described by kind (removed); the checks are in proof; neither follows from the other.

How to tell this applies to your code

Old and new code

x, residual_norm = nnls(A, b, atol=1e-8)
x, residual_norm = nnls(A, b)

Error on 1.18.1:

TypeError: nnls() got an unexpected keyword argument 'atol'
Sandbox proof
Scriptscipy versionResult
Code the models wrote1.17.1works
Code the models wrote1.18.1fails: TypeError
Verified example below1.18.1works
Output of the verified example1.18.1same as the original's on 1.17.1 (observed stdout of one example; not a proof of equivalent behaviour)
Patch applied word for word to the example1.18.1applied word for word, the patch parses, runs and prints what the verified example prints

Verified example for scipy 1.18.1

from scipy.optimize import nnls


def main():
    A = [
        [1, 0, 2],
        [0, 1, 1],
        [3, 1, 0],
        [1, 2, 1],
    ]
    b = [4, 2, 5, 3]

    x, residual_norm = nnls(A, b)

    print("Solution vector:", x)
    print("Residual norm:", residual_norm)


if __name__ == "__main__":
    main()

Source

The deprecated ``atol`` argument of `scipy.optimize.nnls` has been

Release notes · Seen in: gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for scipy

For agents