def testRepr(self): for enum, name in types._TYPE_TO_STRING.iteritems(): dtype = types.DType(enum) self.assertEquals(repr(dtype), 'tf.' + name) dtype2 = eval(repr(dtype)) self.assertEquals(type(dtype2), types.DType) self.assertEquals(dtype, dtype2)
def testInvalid(self): with self.assertRaises(TypeError): types.DType(types_pb2.DT_INVALID) with self.assertRaises(TypeError): types.as_dtype(types_pb2.DT_INVALID)
def testAllTypesConstructible(self): for datatype_enum in types_pb2.DataType.values(): if datatype_enum == types_pb2.DT_INVALID: continue self.assertEqual( datatype_enum, types.DType(datatype_enum).as_datatype_enum)