
I noticed that & (logical and) does support float dtype:
b = np.array([True, False]) f = np.array([1.0, 2.0]) i = np.array([1, 2])
b & b array([ True, False], dtype=bool) i & i array([1, 2]) i & f TypeError: unsupported operand type(s) for &: 'int' and 'float'
But this works:
np.logical_and(b, f) array([ True, False], dtype=bool)
and this gives a different result from i & i above:
np.logical_and(i, i) array([ True, True], dtype=bool)
Why are & and np.logical_and different? If I have a class (a labeled array, larry) any suggestions on whether I should use & or np.logical_and on the the underlying arrays for the __and__ method?

On Thu, Jan 28, 2010 at 10:31, Keith Goodman <kwgoodman@gmail.com> wrote:
I noticed that & (logical and) does support float dtype:
& is not logical_and(). It is bitwise_and(). -- 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

On Thu, Jan 28, 2010 at 8:39 AM, Robert Kern <robert.kern@gmail.com> wrote:
On Thu, Jan 28, 2010 at 10:31, Keith Goodman <kwgoodman@gmail.com> wrote:
I noticed that & (logical and) does support float dtype:
& is not logical_and(). It is bitwise_and().
That explains it. Thank you.
participants (2)
-
Keith Goodman
-
Robert Kern