def invcheck(x): eps2 = 2 * np.finfo(np.float).eps if(x > eps2): x = 1 / x else: x = 0 warnings.warn( "Ill-conditioning encountered, result accuracy may be poor") return(x)