Skip to content

Commit

Permalink
fix: use of ivy.Shape in conditions (#28224)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbarrett98 authored Feb 9, 2024
1 parent e845510 commit 47926c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions ivy_tests/test_ivy/test_misc/test_shape.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 47926c6

Please sign in to comment.