Python tensorflow.python.framework.test_util.TensorFlowTestCase() Examples

The following are 5 code examples of tensorflow.python.framework.test_util.TensorFlowTestCase(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tensorflow.python.framework.test_util , or try the search function .
Example #1
Source File: analyzer_cli_test.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def check_error_output(tst, out, command_prefix, args):
  """Check RichTextLines output from invalid/erroneous commands.

  Args:
    tst: A test_util.TensorFlowTestCase instance.
    out: The RichTextLines object to be checked.
    command_prefix: The command prefix of the command that caused the error.
    args: The arguments (excluding prefix) of the command that caused the error.
  """

  tst.assertGreater(len(out.lines), 2)
  tst.assertStartsWith(out.lines[0],
                       "Error occurred during handling of command: %s %s" %
                       (command_prefix, " ".join(args))) 
Example #2
Source File: analyzer_cli_test.py    From deep_image_model with Apache License 2.0 5 votes vote down vote up
def check_error_output(tst, out, command_prefix, args):
  """Check RichTextLines output from invalid/erroneous commands.

  Args:
    tst: A test_util.TensorFlowTestCase instance.
    out: The RichTextLines object to be checked.
    command_prefix: The command prefix of the command that caused the error.
    args: The arguments (excluding prefix) of the command that caused the error.
  """

  tst.assertGreater(len(out.lines), 2)
  tst.assertStartsWith(out.lines[0],
                       "Error occurred during handling of command: %s %s" %
                       (command_prefix, " ".join(args))) 
Example #3
Source File: ragged_test_util.py    From text with Apache License 2.0 5 votes vote down vote up
def _eval_tensor(self, tensor):
    if ragged_tensor.is_ragged(tensor):
      return ragged_tensor_value.RaggedTensorValue(
          self._eval_tensor(tensor.values),
          self._eval_tensor(tensor.row_splits))
    else:
      return test_util.TensorFlowTestCase._eval_tensor(self, tensor) 
Example #4
Source File: analyzer_cli_test.py    From keras-lambda with MIT License 5 votes vote down vote up
def check_error_output(tst, out, command_prefix, args):
  """Check RichTextLines output from invalid/erroneous commands.

  Args:
    tst: A test_util.TensorFlowTestCase instance.
    out: The RichTextLines object to be checked.
    command_prefix: The command prefix of the command that caused the error.
    args: The arguments (excluding prefix) of the command that caused the error.
  """

  tst.assertGreater(len(out.lines), 2)
  tst.assertStartsWith(out.lines[0],
                       "Error occurred during handling of command: %s %s" %
                       (command_prefix, " ".join(args))) 
Example #5
Source File: analyzer_cli_test.py    From deep_image_model with Apache License 2.0 4 votes vote down vote up
def assert_listed_tensors(tst,
                          out,
                          expected_tensor_names,
                          node_name_regex=None,
                          op_type_regex=None,
                          tensor_filter_name=None):
  """Check RichTextLines output for list_tensors commands.

  Args:
    tst: A test_util.TensorFlowTestCase instance.
    out: The RichTextLines object to be checked.
    expected_tensor_names: Expected tensor names in the list.
    node_name_regex: Optional: node name regex filter.
    op_type_regex: Optional: op type regex filter.
    tensor_filter_name: Optional: name of the tensor filter.
  """

  line_iter = iter(out.lines)

  num_tensors = len(expected_tensor_names)

  if tensor_filter_name is None:
    tst.assertEqual("%d dumped tensor(s):" % num_tensors, next(line_iter))
  else:
    tst.assertEqual("%d dumped tensor(s) passing filter \"%s\":" %
                    (num_tensors, tensor_filter_name), next(line_iter))

  if op_type_regex is not None:
    tst.assertEqual("Op type regex filter: \"%s\"" % op_type_regex,
                    next(line_iter))

  if node_name_regex is not None:
    tst.assertEqual("Node name regex filter: \"%s\"" % node_name_regex,
                    next(line_iter))

  tst.assertEqual("", next(line_iter))

  # Verify the listed tensors and their timestamps.
  tensor_timestamps = []
  tensor_names = []
  for line in line_iter:
    rel_time = float(line.split("ms] ")[0].replace("[", ""))
    tst.assertGreaterEqual(rel_time, 0.0)

    tensor_timestamps.append(rel_time)
    tensor_names.append(line.split("ms] ")[1])

  # Verify that the tensors should be listed in ascending order of their
  # timestamps.
  tst.assertEqual(sorted(tensor_timestamps), tensor_timestamps)

  # Verify that the tensors are all listed.
  for tensor_name in expected_tensor_names:
    tst.assertIn(tensor_name, tensor_names)