ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

前端 未结 6 2267
独厮守ぢ
独厮守ぢ 2020-11-21 04:59

I just discovered a logical bug in my code which was causing all sorts of problems. I was inadvertently doing a bitwise AND instead of a logical AND

6条回答
  •  粉色の甜心
    2020-11-21 05:32

    This typed error-message also shows while an if-statement comparison is done where there is an array and for example a bool or int. See for example:

    ... code snippet ...
    
    if dataset == bool:
        ....
    
    ... code snippet ...
    

    This clause has dataset as array and bool is euhm the "open door"... True or False.

    In case the function is wrapped within a try-statement you will receive with except Exception as error: the message without its error-type:

    The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

提交回复
热议问题