srcs = ["framework/tensor_shape.py"],
srcs_version = "PY2AND3",
deps = [
+ ":dtypes",
":util",
"//tensorflow/core:protos_all_py",
],
from __future__ import print_function
from tensorflow.core.framework import tensor_shape_pb2
+from tensorflow.python.framework import dtypes
from tensorflow.python.util import compat
from tensorflow.python.util.tf_export import tf_export
"""Creates a new Dimension with the given value."""
if value is None:
self._value = None
+ elif isinstance(value, dtypes.DType):
+ raise TypeError("Cannot convert %s to Dimension" % value)
else:
self._value = int(value)
if (not isinstance(value, compat.bytes_or_text_types) and
from __future__ import print_function
from tensorflow.core.framework import tensor_shape_pb2
+from tensorflow.python.framework import dtypes
from tensorflow.python.framework import tensor_shape
from tensorflow.python.framework import test_util
from tensorflow.python.platform import googletest
self.assertEqual(str(tensor_shape.Dimension(7)), "7")
self.assertEqual(str(tensor_shape.Dimension(None)), "?")
+ def testUnsupportedType(self):
+ with self.assertRaises(TypeError):
+ tensor_shape.Dimension(dtypes.string)
+
def testMod(self):
four = tensor_shape.Dimension(4)
nine = tensor_shape.Dimension(9)