dask 2021.10.0

NotesParametersReturnsBackRef
invert(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])

Some inconsistencies with the Dask version may exist.

Compute bit-wise inversion, or bit-wise NOT, element-wise.

Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ~ .

For signed integer inputs, the two's complement is returned. In a two's-complement system negative numbers are represented by the two's complement of the absolute value. This is the most common method of representing signed integers on computers . A N-bit two's-complement system can represent every integer in the range $-2^{N-1}$ to $+2^{N-1}-1$ .

Notes

:None:None:`bitwise_not` is an alias for invert :

>>> np.bitwise_not is np.invert  # doctest: +SKIP
True

Parameters

x : array_like

Only integer and boolean types are handled.

out : ndarray, None, or tuple of ndarray and None, optional

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.

where : array_like, optional

This condition is broadcast over the input. At locations where the condition is True, the :None:None:`out` array will be set to the ufunc result. Elsewhere, the :None:None:`out` array will retain its original value. Note that if an uninitialized :None:None:`out` array is created via the default out=None , locations within it where the condition is False will remain uninitialized.

**kwargs :

For other keyword-only arguments, see the ufunc docs <ufuncs.kwargs> .

Returns

out : ndarray or scalar

Result. This is a scalar if x is a scalar.

This docstring was copied from numpy.invert.

See Also

binary_repr

Return the binary representation of the input number as a string.

bitwise_and
bitwise_or
bitwise_xor
logical_not

Examples

We've seen that 13 is represented by 00001101 . The invert or bit-wise NOT of 13 is then:

This example is valid syntax, but we were not able to check execution
>>> x = np.invert(np.array(13, dtype=np.uint8))  # doctest: +SKIP
... x # doctest: +SKIP 242
This example is valid syntax, but we were not able to check execution
>>> np.binary_repr(x, width=8)  # doctest: +SKIP
'11110010'

The result depends on the bit-width:

This example is valid syntax, but we were not able to check execution
>>> x = np.invert(np.array(13, dtype=np.uint16))  # doctest: +SKIP
... x # doctest: +SKIP 65522
This example is valid syntax, but we were not able to check execution
>>> np.binary_repr(x, width=16)  # doctest: +SKIP
'1111111111110010'

When using signed integer types the result is the two's complement of the result for the unsigned type:

This example is valid syntax, but we were not able to check execution
>>> np.invert(np.array([13], dtype=np.int8))  # doctest: +SKIP
array([-14], dtype=int8)
This example is valid syntax, but we were not able to check execution
>>> np.binary_repr(-14, width=8)  # doctest: +SKIP
'11110010'

Booleans are accepted as well:

This example is valid syntax, but we were not able to check execution
>>> np.invert(np.array([True, False]))  # doctest: +SKIP
array([False,  True])

The ~ operator can be used as a shorthand for np.invert on ndarrays.

This example is valid syntax, but we were not able to check execution
>>> x1 = np.array([True, False])  # doctest: +SKIP
... ~x1 # doctest: +SKIP array([False, True])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.ufunc.invert

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/ufunc.py#None
type: <class 'dask.array.ufunc.ufunc'>
Commit: