def test_check_computations_succeeds(self): computation_1 = building_block_test_utils.create_nested_syntax_tree() computation_2 = building_block_test_utils.create_nested_syntax_tree() computations = collections.OrderedDict(computation_1=computation_1, computation_2=computation_2) compiler_test_utils.check_computations( 'test_check_computations.expected', computations)
class CheckCompiledComputationsTest(parameterized.TestCase): def test_check_computations_succeeds(self): computation_1 = building_block_test_utils.create_nested_syntax_tree() computation_2 = building_block_test_utils.create_nested_syntax_tree() computations = collections.OrderedDict(computation_1=computation_1, computation_2=computation_2) compiler_test_utils.check_computations( 'test_check_computations.expected', computations) def test_check_computations_fails(self): computations = collections.OrderedDict( computation=building_block_test_utils.create_nested_syntax_tree()) with self.assertRaises(golden.MismatchedGoldenError): compiler_test_utils.check_computations( 'test_check_computations.expected', computations) @parameterized.named_parameters([ ('invalid_filename', 1.0, collections.OrderedDict( computation=building_block_test_utils.create_nested_syntax_tree()) ), ('invalid_computations', 'test_check_computations.expected', [building_block_test_utils.create_nested_syntax_tree()]), ('invalid_computation', 'test_check_computations.expected', collections.OrderedDict(computation=1.0)), ]) def test_check_computations_raises_type_error(self, filename, computations): with self.assertRaises(TypeError): compiler_test_utils.check_computations(filename, computations)
def test_adds_no_nodes_to_set_with_constant_false_predicate(self): nested_tree = building_block_test_utils.create_nested_syntax_tree() all_nodes = tree_analysis.extract_nodes_consuming( nested_tree, lambda x: False) self.assertEmpty(all_nodes)
def test_adds_all_nodes_to_set_with_constant_true_predicate(self): nested_tree = building_block_test_utils.create_nested_syntax_tree() all_nodes = tree_analysis.extract_nodes_consuming( nested_tree, lambda x: True) node_count = tree_analysis.count(nested_tree) self.assertLen(all_nodes, node_count)
def test_returns_zero_no_tensorflow(self): no_tensorflow_comp = building_block_test_utils.create_nested_syntax_tree( ) variable_count = tree_analysis.count_tensorflow_variables_under( no_tensorflow_comp) self.assertEqual(variable_count, 0)
def test_check_computations_fails(self): computations = collections.OrderedDict( computation=building_block_test_utils.create_nested_syntax_tree()) with self.assertRaises(golden.MismatchedGoldenError): compiler_test_utils.check_computations( 'test_check_computations.expected', computations)