scipy.linalg.sqrtm changed in scipy 1.18.1
In our sandbox runs up to 2026-10-27, gemini-3.8-flash and gpt-6.1-sol wrote root, errest = linalg.sqrtm(A, disp=False) for scipy. It fails on 1.18.1 with TypeError (changed between 1.17.1 and 1.18.1). Use root = linalg.sqrtm(A) instead.
- What to do
- replace the line
- Output
- same on one example
- Patch
- fails when applied word for word
- Auto-apply
- not allowed
- Seen in
- 2 models
- Worked / failed
- 4 / 0
- Last verified
- 2026-10-27
What to do
Not for automatic application — the patched example does not run on 1.18.1: exit code 1, NameError: name 'errest' is not defined. Show this correction to the user as a lead. Replace the old line with the new one; the rest of the code can stay.
Automatic application: not allowed — the patch gives fails when applied 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 (changed); the checks are in proof; neither follows from the other.
How to tell this applies to your code
- scipy version 1.18.1 or newer is installed (checked on 1.18.1; changed between 1.17.1 and 1.18.1).
- Your code uses:
disp - Or it already failed with:
TypeError: sqrtm() got an unexpected keyword argument 'disp'(every correction for this error)
Old and new code
root, errest = linalg.sqrtm(A, disp=False)root = linalg.sqrtm(A)
Error on 1.18.1:
TypeError: sqrtm() got an unexpected keyword argument 'disp'
Other verified fixes
The fix above passed 2 times. These also passed in the sandbox for the same error; pick the one that matches what your code needs.
Replace the line · passed 2 times · gpt-6.1-sol · patch: fails when applied word for word
root, error_estimate = sqrtm(matrix, disp=False)root = sqrtm(matrix)Not for automatic application — the patched example does not run on 1.18.1: exit code 1, NameError: name 'error_estimate' is not defined. Show this correction to the user as a lead. Replace the old line with the new one; the rest of the code can stay.
Alternatives are leads for the user, not for automatic application: 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.
| Script | scipy version | Result |
|---|---|---|
| Code the models wrote | 1.17.1 | works |
| Code the models wrote | 1.18.1 | fails: TypeError |
| Verified example below | 1.18.1 | works |
| Output of the verified example | 1.18.1 | same 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 example | 1.18.1 | applied word for word, the patch does not give the verified example's result — the patched example does not run on 1.18.1: exit code 1, NameError: name 'errest' is not defined |
Verified example for scipy 1.18.1
from scipy import linalg
# Construct a 3x3 symmetric positive-definite matrix
# (strictly diagonally dominant with positive diagonal elements ensures SPD)
A = [
[4.0, 1.0, 0.5],
[1.0, 5.0, 1.0],
[0.5, 1.0, 6.0],
]
# Compute principal matrix square root and error estimate from scipy
root = linalg.sqrtm(A)
errest = linalg.norm((root @ root) - A, "fro") ** 2 / linalg.norm(A, "fro")
# Compute the Frobenius norm of the difference: ||root^2 - A||_F
diff = (root @ root) - A
frobenius_diff = linalg.norm(diff, "fro")
# Print the results
print("Matrix Square Root (root):")
print(root)
print("\nSciPy Error Estimate:")
print(errest)
print("\nFrobenius Norm of (root^2 - A):")
print(frobenius_diff)Source
No release-note sentence matched this change; the evidence is the sandbox check above.
Seen in: gemini-3.8-flash, gpt-6.1-sol · First seen 2026-10-20 · Last verified 2026-10-27 · All corrections for scipy
For agents
- This page as JSON:
https://formachines.ai/errata/pypi/scipy/0003-scipy-linalg-sqrtm/index.json - Whole database in plain text:
/errata/llms-full.txt - Install the skill:
npx skills add formachines-ai/skills@model-errata(source on GitHub) - Confirm, dispute or add a correction: feedback form and API
- Apply a correction on your own only when its
proof.auto_applyis true (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.)