Can I use ~A
to invert a numpy array of booleans, instead of the rather awkward functions np.logical_and()
and np.invert()
? Indeed, ~
seems to work fine, but I can't find it in any nympy reference manual, and - more alarmingly - it certainly does not work with scalars (e.g. bool(~True)
returns True
!), so I'm a little bit worried ...
Take the 2-minute tour
×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
|
|||||||||
|
short answer: YES Ref: http://docs.scipy.org/doc/numpy/reference/generated/numpy.invert.html Notice:
and
|
|||
|