class_docstr: This is a medium test due to the moments computation taking some time.
class_docstr_tok: ["This","is","a","medium","test","due","to","the","moments","computation","taking","some","time","."]
docstr: Zero isn't in the support of the gamma distribution.
  
  But quantized floating point math has its limits.
  TODO(bjp): Implement log-gamma sampler for small-shape distributions.
  
  Args:
    alpha: float shape value to test
docstr_tok: ["Zero","is","n't","in","the","support","of","the","gamma","distribution",".","But","quantized","floating","point","math","has","its","limits",".","TODO","(","bjp",")",":","Implement","log-gamma","sampler","for","small-shape","distributions",".","Args",":","alpha",":","float","shape","value","to","test"]
code: def _testZeroDensity(self, alpha):
      """Zero isn't in the support of the gamma distribution.
  
      But quantized floating point math has its limits.
      TODO(bjp): Implement log-gamma sampler for small-shape distributions.
  
      Args:
        alpha: float shape value to test
      """
      try:
          from scipy import stats  # pylint: disable=g-import-not-at-top
      except ImportError as e:
          tf_logging.warn(
              "Cannot test zero density proportions: %s" % e
          )
          return
      allowable_zeros = {
          dtypes.float16: stats.gamma(alpha).cdf(
              np.finfo(np.float16).tiny
          ),
          dtypes.float32: stats.gamma(alpha).cdf(
              np.finfo(np.float32).tiny
          ),
          dtypes.float64: stats.gamma(alpha).cdf(
              np.finfo(np.float64).tiny
          ),
      }
      failures = []
      for dt in dtypes.float16, dtypes.float32, dtypes.float64:
          sampler = self._Sampler(10000, alpha, 1.0, dt, seed=12345)
          x = sampler()
          allowable = allowable_zeros[dt] * x.size
          allowable = (
              allowable * 2 if allowable < 10 else allowable * 1.05
          )
          if np.sum(x <= 0) > allowable:
              failures += [dt]
      self.assertEqual([], failures)
  
imports: import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.kernel_tests.random import util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
label_desc: Use image node_id 8 for calling the RandomGammaTest obj's underlying member method code with example usage: obj._testZeroDensity(alpha) without return types