[Numpy-discussion] improved NumPy support for boolean arrays?

josef.pktd@gmai... josef.pktd@gmai...
Wed Aug 5 15:09:25 CDT 2009


On Wed, Aug 5, 2009 at 4:04 PM, Robert Kern<robert.kern@gmail.com> wrote:
> On Wed, Aug 5, 2009 at 15:01, Dr. Phillip M.
> Feldman<pfeldman@verizon.net> wrote:
>>
>> Although I've used Matlab for many years and am quite new to Python, I'm
>> already convinced that the Python/NumPy combination is more powerful and
>> flexible than the Matlab base, and that it generally takes less Python code
>> to get the same job done. There is, however, at least one thing that is much
>> cleaner in Matlab-- operations on boolean arrays. If x and y are numpy
>> arrays of bools, I'd like to be able to create expressions like the
>> following:
>>
>> not x (to invert each element of x)
>
> ~x
>
>> x and y
>
> x & y
>
>> x or y
>
> x | y
>
>> x xor y
>
> x ^ y
>
>> (not x) or y
>
> (~x) | y

See also

logical_and, logical_or, logical_not, logical_xor

Josef



>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma that is made terrible by our own mad attempt to interpret it as
> though it had an underlying truth."
>  -- Umberto Eco
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list