tensorflow_probability/python/internal/distribution_util.py
def _largest_integer_by_dtype(dt):
  """Helper returning the largest integer exactly representable by dtype."""
  if not _is_known_dtype(dt):
    raise TypeError("Unrecognized dtype: {}".format(dt.name))
  if dt.is_floating:
    return int(2**(np.finfo(dt.as_numpy_dtype).nmant + 1))
  if dt.is_integer:
    return np.iinfo(dt.as_numpy_dtype).max
  if dt.base_dtype == tf.bool:
    return int(1)
  # We actually can't land here but keep the case for completeness.
  raise TypeError("Unrecognized dtype: {}".format(dt.name))
def _largest_integer_by_dtype(dt):
  if not _is_known_dtype(dt):
    raise TypeError("Unrecognized dtype: {}".format(dt.name))
  if dt.is_floating:
    return int(2**(np.finfo(dt.as_numpy_dtype).nmant + 1))
  if dt.is_integer:
    return np.iinfo(dt.as_numpy_dtype).max
  if dt.base_dtype == tf.bool:
    return int(1)
  # We actually can't land here but keep the case for completeness.
  raise TypeError("Unrecognized dtype: {}".format(dt.name))
def _largest_integer_by_dtype ( dt ) : if not _is_known_dtype ( dt ) : raise TypeError ( "Unrecognized dtype: {}" . format ( dt . name ) ) if dt . is_floating : return int ( 2 ** ( np . finfo ( dt . as_numpy_dtype ) . nmant + 1 ) ) if dt . is_integer : return np . iinfo ( dt . as_numpy_dtype ) . max if dt . base_dtype == tf . bool : return int ( 1 ) # We actually can't land here but keep the case for completeness. raise TypeError ( "Unrecognized dtype: {}" . format ( dt . name ) )
Helper returning the largest integer exactly representable by dtype.
Helper returning the largest integer exactly representable by dtype .