class_docstr: Mixin for TestCase-type classes with Hypothesis-specific utilities.
class_docstr_tok: ["Mixin","for","TestCase-type","classes","with","Hypothesis-specific","utilities","."]
docstr: Hypothesis assumption that `dist` has reasonable a location and scale.
  
  To wit, `hp.assume` that location / scale < 1e7.  Why this check?  Because
  by assumption we tend to think of samples as being near the location, with
  nearness determined by the scale.  If the scale is close to machine epsilon
  near the location, then the distribution is close to being numerically
  degenerate, and therefore not a good test case.
  
  This assumption is currently only checked for (batch) scalar locations and
  scales, and only if the distribution is parameterized with parameters named
  `loc` and `scale`.
  
  The assumption is applied recursively through meta distributions.
  
  Args:
    dist: TFP `Distribution` to check.
docstr_tok: ["Hypothesis","assumption","that","`","dist","`","has","reasonable","a","location","and","scale",".","To","wit",",","`","hp.assume","`","that","location","\/","scale","<","1e7",".","Why","this","check","?","Because","by","assumption","we","tend","to","think","of","samples","as","being","near","the","location",",","with","nearness","determined","by","the","scale",".","If","the","scale","is","close","to","machine","epsilon","near","the","location",",","then","the","distribution","is","close","to","being","numerically","degenerate",",","and","therefore","not","a","good","test","case",".","This","assumption","is","currently","only","checked","for","(","batch",")","scalar","locations","and","scales",",","and","only","if","the","distribution","is","parameterized","with","parameters","named","`","loc","`","and","`","scale","`",".","The","assumption","is","applied","recursively","through","meta","distributions",".","Args",":","dist",":","TFP","`","Distribution","`","to","check","."]
code: def assume_loc_scale_ok(self, dist):
      """Hypothesis assumption that `dist` has reasonable a location and scale.
  
      To wit, `hp.assume` that location / scale < 1e7.  Why this check?  Because
      by assumption we tend to think of samples as being near the location, with
      nearness determined by the scale.  If the scale is close to machine epsilon
      near the location, then the distribution is close to being numerically
      degenerate, and therefore not a good test case.
  
      This assumption is currently only checked for (batch) scalar locations and
      scales, and only if the distribution is parameterized with parameters named
      `loc` and `scale`.
  
      The assumption is applied recursively through meta distributions.
  
      Args:
        dist: TFP `Distribution` to check.
      """
      if hasattr(dist, "distribution"):
          # BatchReshape, Independent, TransformedDistribution, and
          # QuantizedDistribution
          self.assume_loc_scale_ok(dist.distribution)
      if isinstance(dist, tfd.MixtureSameFamily):
          self.assume_loc_scale_ok(dist.mixture_distribution)
          self.assume_loc_scale_ok(dist.components_distribution)
      if isinstance(dist, tfd.Mixture):
          self.assume_loc_scale_ok(dist.cat)
          self.assume_loc_scale_ok(dist.components)
      if hasattr(dist, "loc") and hasattr(dist, "scale"):
          try:
              loc_ = tf.convert_to_tensor(dist.loc)
              scale_ = tf.convert_to_tensor(dist.scale)
          except (ValueError, TypeError):
              # If they're not Tensor-convertible, don't try to check them.  This is
              # the case, in, for example, multivariate normal, where the scale is a
              # `LinearOperator`.
              return
          loc, scale = self.evaluate([loc_, scale_])
          hp.assume(np.all(np.abs(loc / scale) < 1e7))
  
imports: import collections
  import functools
  import inspect
  from absl import logging
  import hypothesis
  from hypothesis import strategies
  import numpy
  import six
  import tensorflow.compat.v2
  from tensorflow_probability.python import distributions
  from tensorflow_probability.python import util
  from tensorflow_probability.python.bijectors import ascending
  from tensorflow_probability.python.bijectors import hypothesis_testlib
  from tensorflow_probability.python.distributions import distribution
  from tensorflow_probability.python.experimental import distributions
  from tensorflow_probability.python.internal import hypothesis_testlib
  from tensorflow_probability.python.internal import tensorshape_util
label_desc: Use image node_id 1 for calling the TestCase obj's underlying member method code with example usage: obj.assume_loc_scale_ok(dist) without return types