np.logical_xor
时间: 2023-09-24 10:12:23 浏览: 93
The numpy function `np.logical_xor` computes the element-wise exclusive OR (XOR) of two boolean arrays.
Syntax: `numpy.logical_xor(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'logical_xor')`
Parameters:
- `x1, x2`: Input arrays. They must have the same shape.
- `out`: Output array where the result is stored. It must have the same shape as the input arrays. If not provided, a new array is created.
- `where`: If true, perform the operation where the condition is true. If false, return the input array.
- `dtype`: The data type of the output array.
Returns: An array of boolean values representing the element-wise XOR of the input arrays.
Example:
```
import numpy as np
a = np.array([True, False, True])
b = np.array([False, True, True])
c = np.logical_xor(a, b)
print(c) # [ True True False]
```
阅读全文