def safe_div(a, b, inf=INF):
with np.errstate(divide='<STR_LIT>', invalid='<STR_LIT>'):<EOL><INDENT>try:<EOL><INDENT>return <NUM_LIT:1.> * a / b<EOL><DEDENT>except (ZeroDivisionError, FloatingPointError):<EOL><INDENT>return inf<EOL><DEDENT>except TypeError:<EOL><INDENT>try:<EOL><INDENT><NUM_LIT:1.> / b<EOL><DEDENT>except TypeError:<EOL><INDENT>return b<EOL><DEDENT>return a<EOL><DEDENT>except RuntimeWarning:<EOL><INDENT>try:<EOL><INDENT><NUM_LIT:1.> / b<EOL><DEDENT>except RuntimeWarning:<EOL><INDENT>return b<EOL><DEDENT>return a<EOL><DEDENT>return <NUM_LIT:1.> * a / b<EOL><DEDENT>
Safely divide by zero and inf and nan and produce floating point result
    Numerical results are equivalent to `from __future__ import division`
    Args:
      a (float or int): numerator
      b (float or int): denominator
      inf (float or object): value to return in place of division by zero errors
      none (float or object): value to return in place of TypeErrors (division by None)
    Returns:
      dividend:
        b if b is None or NaN
        a if a is None or NaN
        inf (specified by caller, default is np.inf) if b is 0
        pd.NaT if b or a is pd.NaT
    >>> safe_div(84, 2)
    42.0
    >>> safe_div(-85, 2)
    -42.5
    >>> safe_div(42, 0)
    inf
    >>> safe_div(-42, 0)
    inf
    >>> safe_div(1, 0.)
    inf
    >>> safe_div(1, 0., inf="custom OutOfBounds str")
    'custom OutOfBounds str'
    >>> safe_div(np.inf, np.inf)
    nan
    >>> safe_div(1e200, np.inf)
    0.0
    >>> safe_div(np.inf, np.nan)
    nan
    >>> safe_div(np.nan, 0)
    inf
    >>> repr(safe_div(99.99, None))
    'None'
    >>> safe_div(42, object())
    <object object at 0x...>