wright-group / WrightTools

Tools for loading, processing, and plotting multidimensional spectroscopy data.
http://wright.tools
MIT License
17 stars 9 forks source link

Kit leastsq should not except BaseException #681

Closed ksunden closed 6 years ago

ksunden commented 6 years ago

https://github.com/wright-group/WrightTools/blob/f22920579f45632b4123661d9832ff0cc1b614c4/WrightTools/kit/_leastsq.py#L74

The exception caught should be limited to those known to be raised inside.

ksunden commented 6 years ago

@untzag @darienmorrow Dow we know what exception this should be catching?

ksunden commented 6 years ago

(or exceptions)

darienmorrow commented 6 years ago

I have no idea. I think the idea is to handle any wonky values in the covariance matrix (e.g. inf, -inf), but I don't have good reason to think those would pop up. I will note that the original idea/code come from this stackoverflow thread.

I think it should be probably just be a try except instead of using BaseException.

ksunden commented 6 years ago

Note that just try/except is functionally identical to try/except BaseException. Ideally we know what exceptions may arise from the try block, and only handle those

ksunden commented 6 years ago

np.absolute and append should not throw errors, as long as we give absolute numeric data.

The other things that may cause errors have to do with indexing pcov, which is None if a singular matrix is encountered according to scipy docs. Our code will set it to np.inf in that case, then indexing into it will generate an error.