An offline robot calibration job can return a parameter vector even when its sparse solver reaches the iteration cap. The vector alone gives the report little evidence about how the solve ended. A small fixture makes it possible to check both the termination reason and the residual before applying the same checks to a larger job.
Compare two runs on the same data
In this fixture two parameters explain the first two observations. The third row represents a reading that neither parameter can change. It leaves a residual of 0.5 even at the best fit. SciPy's LSQR returns the parameter vector followed by the stopping code, iteration count, and norm of the residual. Keeping those fields together distinguishes a limited run from a least-squares solution on this dataset.
import numpy as np
from scipy.sparse import csr_array
from scipy.sparse.linalg import lsqr
a = csr_array([[1., 0.], [0., 2.], [0., 0.]])
b = np.array([1., 2., 0.5])
limited = lsqr(a, b, iter_lim=1, atol=1e-12, btol=1e-12)
fitted = lsqr(a, b, atol=1e-12, btol=1e-12)
reference = np.linalg.lstsq(a.toarray(), b, rcond=None)[0]
assert limited[1:3] == (7, 1)
assert fitted[1:3] == (2, 2)
assert np.allclose(fitted[0], reference)
assert np.isclose(fitted[3], 0.5)
With SciPy 1.18.1 and NumPy 2.5.5 the one-iteration estimate was approximately [0.26154, 1.04615]. Its residual norm was about 0.89657 and stop code 7 recorded the iteration limit. The second run returned approximately [1, 1], which matched the dense reference. It stopped with code 2 and a residual norm of 0.5. That remaining residual comes from the third observation, whose model prediction is zero for either parameter value.
Make the residual traceable
Log the stopping code and its interpretation along with the iteration cap, tolerances, and residual norm. If the residual exceeds the calibration procedure's acceptance threshold, inspect the residual by observation. The stopping code describes the numerical solve. The residual check shows how closely the fitted parameters explain the measurements.
Use a dense reference only on a small fixture where it is inexpensive. For a larger calibration run, retain the identities and units of the input rows and validate selected residuals directly with b - A @ x. A deliberately capped run makes a useful test for reports that might otherwise display any returned vector as a completed fit.
Sources
SciPy LSQR reference for stopping criteria, iterations, and residual outputs
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.lsqr.html
NumPy lstsq reference for the small dense reference solve
https://numpy.org/doc/stable/reference/generated/numpy.linalg.lstsq.html