Add bool support for Dimension.

PiperOrigin-RevId: 349447392
Change-Id: I1fa3879db4f9fc8e760299d91700e62c9657b0d6
This commit is contained in:
A. Unique TensorFlower 2020-12-29 11:24:51 -08:00 committed by TensorFlower Gardener
parent a6e88c78a8
commit 0366e4d699
2 changed files with 0 additions and 12 deletions

View File

@ -234,10 +234,6 @@ class Dimension(object):
return None
return self._value != other.value
def __bool__(self):
"""Equivalent to `bool(self.value)`."""
return bool(self._value)
def __int__(self):
return self._value

View File

@ -195,14 +195,6 @@ class DimensionTest(test_util.TensorFlowTestCase):
with self.assertRaises(TypeError):
tensor_shape.Dimension(dtypes.string)
def testBool(self):
one = tensor_shape.Dimension(1)
zero = tensor_shape.Dimension(0)
has_none = tensor_shape.Dimension(None)
self.assertTrue(one)
self.assertFalse(zero)
self.assertFalse(has_none)
def testMod(self):
four = tensor_shape.Dimension(4)
nine = tensor_shape.Dimension(9)