def test_tensor_undefined_output(self): with self.assertRaisesRegex( ValueError, "must also be initialized in the if.*'s'"): self._basic_cond(lambda: special_values.Undefined('s'), lambda: 1) with self.assertRaisesRegex( ValueError, "must also be initialized in the else.*'s'"): self._basic_cond(lambda: 1, lambda: special_values.Undefined('s'))
def test_undefined(self): undefined_symbol = special_values.Undefined('name') self.assertEqual(undefined_symbol.symbol_name, 'name') undefined_symbol2 = special_values.Undefined('name') self.assertNotEqual(undefined_symbol, undefined_symbol2) self.assertTrue(special_values.is_undefined(undefined_symbol)) self.assertTrue(special_values.is_undefined(undefined_symbol2))
def test_undefined_operations(self): undefined_symbol = special_values.Undefined('name') self.assertTrue(special_values.is_undefined(undefined_symbol.foo)) self.assertTrue(special_values.is_undefined(undefined_symbol[0])) self.assertFalse( special_values.is_undefined(undefined_symbol.__class__))
def test_tensor_illegal_input(self): with self.assertRaisesRegex(ValueError, '"s" may not be None'): self._basic_loop(None, lambda i, s: s) with self.assertRaisesRegex(ValueError, '"s" must be defined'): self._basic_loop(special_values.Undefined(''), lambda i, s: s)