docs: def safe_div(a, b, inf=INF):
      """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...>
      """
      with np.errstate(divide='raise', invalid='raise'):
          try:
              return 1. * a / b
          except (ZeroDivisionError, FloatingPointError):
              return inf
          except TypeError:
              try:
                  1. / b
              except TypeError:
                  return b
              return a
          except RuntimeWarning:
              try:
                  1. / b
              except RuntimeWarning:
                  return b
              return a
          return 1. * a / b