File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -196,9 +196,13 @@ def __setitem__(
196196 self .data [key ] = value
197197
198198 def __bool__ (self ):
199- # TODO: more complete implementation
200- if self .shape == (1 ,) or self .shape == ():
201- return bool (self .data )
199+ if self .shape == () or self .size == 1 :
200+ return bool (self .data .flat [0 ])
201+ # todo: add complete implementation later
202+ raise ValueError (
203+ "The truth value of a View with more than one element is ambiguous. "
204+ "Use a.any() or a.all()"
205+ )
202206
203207 def __len__ (self ) -> int :
204208 """
@@ -542,11 +546,7 @@ def __eq__(self, other):
542546 return equal (self , new_other )
543547
544548 def __hash__ (self ):
545- try :
546- hash_value = hash (self .array )
547- except TypeError :
548- hash_value = hash (self .array .data .tobytes ())
549- return hash_value
549+ return id (self )
550550
551551 def __index__ (self ) -> int :
552552 return int (self .data [0 ])
@@ -720,8 +720,7 @@ def __mul__(self, other):
720720 return result
721721
722722 def __hash__ (self ):
723- hash_value = hash (self .array )
724- return hash_value
723+ return id (self )
725724
726725
727726def from_numpy (
You can’t perform that action at this time.
0 commit comments