Skip to content

Commit

Permalink
Merge pull request #7772 from chainer/revert-6414-type-check-bool
Browse files Browse the repository at this point in the history
Revert "Allow bool evaluation in `type_check`"
  • Loading branch information
niboshi committed Jul 17, 2019
2 parents 26c7b20 + 54c631f commit 6eb84e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 0 additions & 6 deletions chainer/utils/type_check.py
Expand Up @@ -482,12 +482,6 @@ def expect(self):
'{0} {1} {2}'.format(self.lhs, self.exp, self.rhs),
'{0} {1} {2}'.format(left, self.inv, right))

def __bool__(self):
return self.eval()

def __nonzero__(self):
return self.__bool__()


class InvalidType(Exception):
"""Raised when types of data for forward/backward are invalid.
Expand Down
10 changes: 4 additions & 6 deletions tests/chainer_tests/utils_tests/test_type_check.py
Expand Up @@ -290,20 +290,18 @@ def f(x, y):

def test_eval(self):
self.assertTrue(self.op1.eval())
self.assertFalse(self.op2.eval())

def test_expect(self):
self.op1.expect()
with self.assertRaises(T.InvalidType):
self.op2.expect()

def test_bool(self):
self.assertTrue(bool(self.op1))
self.assertFalse(bool(self.op2))
with self.assertRaises(RuntimeError):
bool(self.op1)

def test_bool_operator(self):
self.assertFalse(not self.op1)
self.assertTrue(not self.op2)
with self.assertRaises(RuntimeError):
not self.op1


class TestLazyGetItem(unittest.TestCase):
Expand Down

0 comments on commit 6eb84e3

Please sign in to comment.