diff --git a/ivy/__init__.py b/ivy/__init__.py index 52d73cf067b33..5e0cfbfd48cc6 100644 --- a/ivy/__init__.py +++ b/ivy/__init__.py @@ -294,7 +294,7 @@ def __rmul__(self, other): return self def __bool__(self): - return self._shape.__bool__() + return builtins.bool(self._shape) def __div__(self, other): return self._shape // other diff --git a/ivy_tests/test_ivy/test_misc/test_shape.py b/ivy_tests/test_ivy/test_misc/test_shape.py index f20c34bb3a386..6fe8a1e8c4355 100644 --- a/ivy_tests/test_ivy/test_misc/test_shape.py +++ b/ivy_tests/test_ivy/test_misc/test_shape.py @@ -1,6 +1,7 @@ from hypothesis import assume, strategies as st import numpy as np +import ivy import ivy_tests.test_ivy.helpers as helpers from ivy_tests.test_ivy.helpers import handle_method @@ -682,3 +683,13 @@ def test_shape__sub__( class_name=class_name, method_name=method_name, ) + + +def test_shape_in_conditions(): + shape = ivy.Shape((1, 2)) + condition_is_true = True if shape else False + assert condition_is_true + + shape = ivy.Shape(()) + condition_is_true = True if shape else False + assert not condition_is_true