📅  最后修改于: 2023-12-03 14:46:36.220000             🧑  作者: Mango
The numpy.logical_not() function is a part of the numpy module in Python. It returns an array containing the element-wise logical NOT of the input array. For a given element, if it is zero or False, the output would be True, else it would be False.
Syntax:
numpy.logical_not(array)
array
: A numpy array containing elements to be evaluated for logical NOT.import numpy as np
arr = np.array([True, False, 0, 1, 3, -1])
result = np.logical_not(arr)
print(result)
Output:
[False True True False False False]
In the above example, the input array arr
contains a mix of boolean, integer and float values. When passed through the np.logical_not() function, we get an array containing the logical NOT of each element in the input array.
True
, which when evaluated using logical NOT, results in False
.False
, which when evaluated using logical NOT, results in True
.0
, which when evaluated using logical NOT, results in True
.1
, which when evaluated using logical NOT, results in False
.3
, which when evaluated using logical NOT, results in False
.-1
, which when evaluated using logical NOT, results in False
.Therefore, the final output array returned by np.logical_not() contains [False True True False False False]
.