Hi all, is the following behaviour correct
a = array(([True,True],[True,True])) b = array(([False,False],[False,False]))
a+b array([[ True, True], [ True, True]])
I have expected False. Nils
On 11/26/2009 8:20 AM, Nils Wagner wrote:
a = array(([True,True],[True,True])) b = array(([False,False],[False,False])) a+b
NumPy's boolean operations are very well behaved.
a = np.array(([True,True],[True,True])) a+a array([[ True, True], [ True, True]], dtype=bool)
Compare Python:
True + True 2
Ugh! Not fixing this in Python 3 was a big mistake, imo. Alan Isaac
It is obvious to me that True+False == True,. Why do you think it should be False? Nadav On Thu, 2009-11-26 at 14:20 +0100, Nils Wagner wrote:
Hi all,
is the following behaviour correct
a = array(([True,True],[True,True])) b = array(([False,False],[False,False]))
a+b array([[ True, True], [ True, True]])
I have expected False.
Nils _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should be False?
I would understand it is not obvious that '+' stands for logical 'or',
and '*' for logical 'and'...
--
Fabrice Silva
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should be False?
I would understand it is not obvious that '+' stands for logical 'or', and '*' for logical 'and'...
In Bool's algebra, this is the common convention. The reason being that only 'or' can correspond to the additive law of an algebra: its null element is absorbant for 'and'. In other words, if you map '+' and '*' to the opposite, you'll get suprising behaviors. Gaël
Le jeudi 26 novembre 2009 à 14:44 +0100, Gael Varoquaux a écrit :
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should be False?
I would understand it is not obvious that '+' stands for logical 'or', and '*' for logical 'and'...
In Bool's algebra, this is the common convention. The reason being that only 'or' can correspond to the additive law of an algebra: its null element is absorbant for 'and'.
In other words, if you map '+' and '*' to the opposite, you'll get suprising behaviors.
I fully agree with you. My point was to complete Nadav's comment with
potentially missing information, trying to figrue why Nils was expected
False...
--
Fabrice Silva
On Thu, 26 Nov 2009 15:14:04 +0100
Fabrice Silva
Le jeudi 26 novembre 2009 à 14:44 +0100, Gael Varoquaux a écrit :
On Thu, Nov 26, 2009 at 02:43:14PM +0100, Fabrice Silva wrote:
Le jeudi 26 novembre 2009 à 18:26 +0200, Nadav Horesh a écrit :
It is obvious to me that True+False == True,. Why do you think it should be False?
I would understand it is not obvious that '+' stands for logical 'or', and '*' for logical 'and'...
In Bool's algebra, this is the common convention. The reason being that only 'or' can correspond to the additive law of an algebra: its null element is absorbant for 'and'.
In other words, if you map '+' and '*' to the opposite, you'll get suprising behaviors.
I fully agree with you. My point was to complete Nadav's comment with potentially missing information, trying to figrue why Nils was expected False...
-- Fabrice Silva
LMA UPR CNRS 7051
Sorry, I mixed up '+' and '&'
a = array(([True,True],[True,True])) b = array(([False,False],[False,False])) a & b array([[False, False], [False, False]], dtype=bool)
Cheers, Nils
On Thu, Nov 26, 2009 at 7:35 PM, Nils Wagner
Sorry, I mixed up '+' and '&'
a = array(([True,True],[True,True])) b = array(([False,False],[False,False])) a & b array([[False, False], [False, False]], dtype=bool)
Cheers,
Nils
hey, this is a classical problem with + (sometimes pronounced 'and') and & (also pronounced 'and'). Happens to all of us sometimes. cu,
participants (6)
-
Alan G Isaac
-
Fabrice Silva
-
Gael Varoquaux
-
Nadav Horesh
-
Nils Wagner
-
René Dudfield