w3resource

NumPy Logic functions: logical_not() function

numpy.logical_not() function

The allclose() function is used to returns the truth value of NOT x element-wise.

Syntax:

numpy.logical_not(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'logical_not'>

Version: 1.15.0

Parameter:

Name Description Required /
Optional
x Logical NOT is applied to the elements of x.
array_like
Required
out A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to.
If not provided or None, a freshly-allocated array is returned.
A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
ndarray, None, or tuple of ndarray and None
Optional
where Values of True indicate to calculate the ufunc at that position,
values of False indicate to leave the value in the output alone.
array_like
Optional
**kwargs For other keyword-only arguments Required

Returns:
y : bool or ndarray of bool - Boolean result with the same shape as x of the NOT operation on elements of x.
This is a scalar if x is a scalar.

NumPy.logical_not() method Example-1:

>>> import numpy as np
>>> np.logical_not(5)

Output:

False

NumPy.logical_not() method Example-2:

>>> import numpy as np
>>> np.logical_not([True, False, 0, 2])

Output:

array([False,  True,  True, False])

NumPy.logical_not() method Example-3:

>>> import numpy as np
>>> x = np.arange(6)
>>> np.logical_not(x < 4)

Output:

array([False, False, False, False,  True,  True])

Python - NumPy Code Editor:

Previous: logical_or() function
Next: logical_xor() function



Follow us on Facebook and Twitter for latest update.