desihub / specter

A toolkit for simulating multi-object spectrographs
Other
8 stars 7 forks source link

what rcond should we use for matrix solving? #80

Open sbailey opened 4 years ago

sbailey commented 4 years ago

In specter.util.util.weighted_solve:

    x = np.linalg.lstsq(iCov, y)[0]

is generating

FutureWarning: `rcond` parameter will change to the default of machine precision
times ``max(M, N)`` where M and N are the input matrix dimensions.
To use the future default and silence this warning we advise to pass 
`rcond=None`, to keep using the old, explicitly pass `rcond=-1`.

Study whether we want to keep current behavior, or whether this change of default is giving us a hint that we're pushing our luck with rcond. Note that some of our matrices can be illconditioned, so study the impact on actual full extractions with real data and not just toy cases.

While we're at it, @dmargala discovered that np.linalg.solve() is ~15x faster than np.linalg.lstsq because lstsq is solving a more general case (under, over, or exactly constrained). This isn't a huge part of our runtime, but consider if solve would work just as well for our case.