Hi all,

So basically my requirement is pretty simple. I just wanted to know I could make use of the tilde operator (~) to invert a Numpy array consisting of boolean data. However, I am aware of the standard way to do it is to use the functions np.invert() and even np.logical_and().

Tilde seems to work but my concern here is that I am unable to find the plausible usage in any Numpy reference material, to be honest.

Note: I have seen that it does not work with scalars at all. Well this is what I mean, consider this example:

Example: bool(~True) -----> This returns True.

Appreciate all the help!Hi all,

So basically my requirement is pretty simple. I just wanted to know I could make use of the tilde operator (~) to invert a Numpy array consisting of boolean data. However, I am aware of the standard way to do it is to use the functions np.invert() and even np.logical_and().

Tilde seems to work but my concern here is that I am unable to find the plausible usage in any Numpy reference material, to be honest.

Note: I have seen that it does not work with scalars at all. Well this is what I mean, consider this example:

Example: bool(~True) -----> This returns True.

Appreciate all the help!

So basically my requirement is pretty simple. I just wanted to know I could make use of the tilde operator (~) to invert a Numpy array consisting of boolean data. However, I am aware of the standard way to do it is to use the functions np.invert() and even np.logical_and().

Tilde seems to work but my concern here is that I am unable to find the plausible usage in any Numpy reference material, to be honest.

Note: I have seen that it does not work with scalars at all. Well this is what I mean, consider this example:

Example: bool(~True) -----> This returns True.

Appreciate all the help!Hi all,

So basically my requirement is pretty simple. I just wanted to know I could make use of the tilde operator (~) to invert a Numpy array consisting of boolean data. However, I am aware of the standard way to do it is to use the functions np.invert() and even np.logical_and().

Tilde seems to work but my concern here is that I am unable to find the plausible usage in any Numpy reference material, to be honest.

Note: I have seen that it does not work with scalars at all. Well this is what I mean, consider this example:

Example: bool(~True) -----> This returns True.

Appreciate all the help!