class_docstr: Customizes how `want` and `got` are compared, see `check_output`.
class_docstr_tok: ["Customizes","how","`","want","`","and","`","got","`","are","compared",",","see","`","check_output","`","."]
docstr: Compares the docstring output to the output gotten by running the code.
  
  Python addresses in the output are replaced with wildcards.
  
  Float values in the output compared as using `np.allclose`:
  
    * Float values are extracted from the text and replaced with wildcards.
    * The wildcard text is compared to the actual output.
    * The float values are compared using `np.allclose`.
  
  The method returns `True` if both the text comparison and the numeric
  comparison are successful.
  
  The numeric comparison will fail if either:
  
    * The wrong number of floats are found.
    * The float values are not within tolerence.
  
  Args:
    want: The output in the docstring.
    got: The output generated after running the snippet.
    optionflags: Flags passed to the doctest.
  
  Returns:
    A bool, indicating if the check was successful or not.
docstr_tok: ["Compares","the","docstring","output","to","the","output","gotten","by","running","the","code",".","Python","addresses","in","the","output","are","replaced","with","wildcards",".","Float","values","in","the","output","compared","as","using","`","np.allclose","`",":","*","Float","values","are","extracted","from","the","text","and","replaced","with","wildcards",".","*","The","wildcard","text","is","compared","to","the","actual","output",".","*","The","float","values","are","compared","using","`","np.allclose","`",".","The","method","returns","`","True","`","if","both","the","text","comparison","and","the","numeric","comparison","are","successful",".","The","numeric","comparison","will","fail","if","either",":","*","The","wrong","number","of","floats","are","found",".","*","The","float","values","are","not","within","tolerence",".","Args",":","want",":","The","output","in","the","docstring",".","got",":","The","output","generated","after","running","the","snippet",".","optionflags",":","Flags","passed","to","the","doctest",".","Returns",":","A","bool",",","indicating","if","the","check","was","successful","or","not","."]
code: def check_output(self, want, got, optionflags):
      """Compares the docstring output to the output gotten by running the code.
  
      Python addresses in the output are replaced with wildcards.
  
      Float values in the output compared as using `np.allclose`:
  
        * Float values are extracted from the text and replaced with wildcards.
        * The wildcard text is compared to the actual output.
        * The float values are compared using `np.allclose`.
  
      The method returns `True` if both the text comparison and the numeric
      comparison are successful.
  
      The numeric comparison will fail if either:
  
        * The wrong number of floats are found.
        * The float values are not within tolerence.
  
      Args:
        want: The output in the docstring.
        got: The output generated after running the snippet.
        optionflags: Flags passed to the doctest.
  
      Returns:
        A bool, indicating if the check was successful or not.
      """
  
      # If the docstring's output is empty and there is some output generated
      # after running the snippet, return True. This is because if the user
      # doesn't want to display output, respect that over what the doctest wants.
      if got and not want:
          return True
  
      if want is None:
          want = ""
  
      if want == got:
          return True
  
      # Replace python's addresses with ellipsis (`...`) since it can change on
      # each execution.
      want = self._ADDRESS_RE.sub("at ...>", want)
  
      # Replace tf.Tensor strings with only their numpy field values.
      want, want_changed = self._tf_tensor_numpy_output(want)
      if want_changed:
          got, _ = self._tf_tensor_numpy_output(got)
  
      # Separate out the floats, and replace `want` with the wild-card version
      # "result=7.0" => "result=..."
      want_text_parts, self.want_floats = self.extract_floats(want)
      # numpy sometimes pads floats in arrays with spaces
      # got: [1.2345, 2.3456, 3.0   ]  want:  [1.2345, 2.3456, 3.0001]
      # And "normalize whitespace" only works when there's at least one space,
      # so strip them and let the wildcard handle it.
      want_text_parts = [part.strip(" ") for part in want_text_parts]
      want_text_wild = "...".join(want_text_parts)
      if "...." in want_text_wild:
          # If a float comes just after a period you'll end up four dots and the
          # first three count as the ellipsis. Replace it with three dots.
          want_text_wild = re.sub(r"\.\.\.\.+", "...", want_text_wild)
  
      # Find the floats in the string returned by the test
      _, self.got_floats = self.extract_floats(got)
  
      self.text_good = super(TfDoctestOutputChecker, self).check_output(
          want=want_text_wild, got=got, optionflags=optionflags
      )
      if not self.text_good:
          return False
  
      if self.want_floats.size == 0:
          # If there are no floats in the "want" string, ignore all the floats in
          # the result. "np.array([ ... ])" matches "np.array([ 1.0, 2.0 ])"
          return True
  
      self.float_size_good = (
          self.want_floats.size == self.got_floats.size
      )
  
      if self.float_size_good:
          return self._allclose(self.want_floats, self.got_floats)
      else:
          return False
  
file_path: tensorflow-upstream/tensorflow/tools/docs/tf_doctest_lib.py
imports: import doctest
  import re
  import textwrap
  import numpy
label_desc: Use image node_id 4 for calling the TfDoctestOutputChecker obj's underlying member method code with example usage: obj.check_output(want, got, optionflags) and returns: True, True, False, True, self, False