Categories
Python Answers

How to call Python Numpy logical_or for more than two arguments?

Spread the love

Sometimes, we want to call Python Numpy logical_or for more than two arguments.

In this article, we’ll look at how to call Python Numpy logical_or for more than two arguments.

How to call Python Numpy logical_or for more than two arguments?

To call Python Numpy logical_or for more than two arguments, we can call logical_or multiple times.

For instance, we write

x = np.array([True, True, False, False])
y = np.array([True, False, True, False])
z = np.array([False, False, False, False])
w = np.logical_or(np.logical_or(x, y), z)

to create 3 arrays x, y, and x with booleans inside.

Then we call logical_or with x and y to return the or result between the 2 arrays.

Then we call logical_or again with the returned result and z to do logical or on the returned array and z.

Conclusion

To call Python Numpy logical_or for more than two arguments, we can call logical_or multiple times.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *