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 ...
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
short answer: YES
Ref:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.invert.html
Notice:
and