We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 61fe479 commit 57b4310Copy full SHA for 57b4310
1 file changed
pygpu/gpuarray.pyx
@@ -1657,6 +1657,16 @@ cdef class GpuArray:
1657
"""
1658
return pygpu_as_ndarray(self)
1659
1660
+ def __bool__(self):
1661
+ if self.ga.nd == 0:
1662
+ return True
1663
+ if self.ga.nd == 1:
1664
+ if self.ga.dimensions[0] == 0:
1665
+ return False
1666
+ if self.ga.dimensions[0] == 1:
1667
+ return bool(numpy.asarray(self))
1668
+ raise ValueError('The truth value of a multi-element array is ambiguous')
1669
+
1670
def _empty_like_me(self, dtype=None, order='C'):
1671
1672
_empty_like_me(dtype=None, order='C')
0 commit comments