safe_invert¶
- eazy.utils.safe_invert(arr, tol=None)[source]¶
Version-safe matrix inversion using
numpy.linalg.invornumpy.matrix.I- Parameters:
- arrarray-like
Square matrix to invert
- tolfloat
Tolerance parameter for calculating if arr is singular using the rank from
np.linalg.matrix_rank(arr, tol=tol). If None, use the numpy default derived from the matrix size and machine epsilon. Ifarris found to be singular (rank < max(arr.shape)), don’t try to invert it and just return an array of NaN values.
- Returns:
- invarray-like
Inverse of
arr