ValueError when checking if variable is None or numpy.array

后端 未结 3 1962
感动是毒
感动是毒 2020-12-07 17:13

I\'d like to check if variable is None or numpy.array. I\'ve implemented check_a function to do this.

def check_a(a):
    if not a:
        prin         


        
3条回答
  •  孤街浪徒
    2020-12-07 17:51

    If you are trying to do something very similar: a is not None, the same issue comes up. That is, Numpy complains that one must use a.any or a.all.

    A workaround is to do:

    if not (a is None):
        pass
    

    Not too pretty, but it does the job.

提交回复
热议问题