Understanding the working mechanis of python unary arithmetic operators.
hongyi.zhao at gmail.com
Sun Oct 3 09:55:02 EDT 2021
On Sunday, October 3, 2021 at 8:38:16 PM UTC+8, ju... at diegidio.name wrote:
> On Sunday, 3 October 2021 at 14:21:13 UTC+2, hongy... at gmail.com wrote:
> > On Sunday, October 3, 2021 at 6:31:05 PM UTC+8, ju... at diegidio.name wrote:
> > > Then you can guess that numpy overrides it and gives you *logical* negation of boolean values,
> > I try to dig through the numpy source code to pinning point the overriding/monkey patching/decorating code snippets, as follows:
> And you keep missing the point: look up numpy's *documentation* for that, not any source code.
I find the relevant explanation here :
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 ~.
The ~ operator can be used as a shorthand for np.invert on ndarrays.
x1 = np.array([True, False])
More information about the Python-list