def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
 if ((not np.isfinite(vmin)) or (not np.isfinite(vmax))):
  return ((- expander), expander)
 swapped = False
 if (vmax < vmin):
  (vmin, vmax) = (vmax, vmin)
  swapped = True
 maxabsvalue = max(abs(vmin), abs(vmax))
 if (maxabsvalue < ((1000000.0 / tiny) * np.finfo(float).tiny)):
  vmin = (- expander)
  vmax = expander
 elif ((vmax - vmin) <= (maxabsvalue * tiny)):
  if ((vmax == 0) and (vmin == 0)):
   vmin = (- expander)
   vmax = expander
  else:
   vmin -= (expander * abs(vmin))
   vmax += (expander * abs(vmax))
 if (swapped and (not increasing)):
  (vmin, vmax) = (vmax, vmin)
 return (vmin, vmax)

def nonsingular ( vmin , vmax , expander = 0.001 , tiny = 1e-15 , increasing = True ) : if ( ( not np . isfinite ( vmin ) ) or ( not np . isfinite ( vmax ) ) ) : return ( ( - expander ) , expander ) swapped = False if ( vmax < vmin ) : ( vmin , vmax ) = ( vmax , vmin ) swapped = True maxabsvalue = max ( abs ( vmin ) , abs ( vmax ) ) if ( maxabsvalue < ( ( 1000000.0 / tiny ) * np . finfo ( float ) . tiny ) ) : vmin = ( - expander ) vmax = expander elif ( ( vmax - vmin ) <= ( maxabsvalue * tiny ) ) : if ( ( vmax == 0 ) and ( vmin == 0 ) ) : vmin = ( - expander ) vmax = expander else : vmin -= ( expander * abs ( vmin ) ) vmax += ( expander * abs ( vmax ) ) if ( swapped and ( not increasing ) ) : ( vmin , vmax ) = ( vmax , vmin ) return ( vmin , vmax )
ensure the endpoints of a range are finite and not too close together .