Numpy `logical_or` for more than two arguments

后端 未结 7 970
庸人自扰
庸人自扰 2020-11-22 09:33

Numpy\'s logical_or function takes no more than two arrays to compare. How can I find the union of more than two arrays? (The same question could be asked wit

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 10:09

    In case someone still need this - Say you have three Boolean arrays a, b, c with the same shape, this gives and element-wise:

    a * b * c
    

    this gives or:

    a + b + c
    

    Is this what you want? Stacking a lot of logical_and or logical_or is not practical.

提交回复
热议问题