code: def isfinite(val):
      
      if not np.isscalar(val):
          val = asarray(val, strict=False)
  
      if val is None:
          return False
      elif isinstance(val, np.ndarray):
          if val.dtype.kind == 'M':
              return ~isnat(val)
          elif val.dtype.kind == 'O':
              return np.array([isfinite(v) for v in val], dtype=bool)
          elif val.dtype.kind in 'US':
              return np.ones_like(val, dtype=bool)
          return np.isfinite(val)
      elif isinstance(val, datetime_types+timedelta_types):
          return not isnat(val)
      elif isinstance(val, basestring):
          return True
      return np.isfinite(val)
docs: Helper function to determine if scalar or array value is finite extending
      np.isfinite with support for None, string, datetime types.