<br><br><div><span class="gmail_quote">On 7/9/07, <b class="gmail_sendername">Alan G Isaac</b> <<a href="mailto:aisaac@american.edu">aisaac@american.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote:<br>> Why not simply use & and | instead of + and *?<br><br>A couple reasons, none determinative.<br>1. numpy is right a Python is wrong it this case</blockquote>
<div><br>I don't think I agree with this. Once you've decided to make Boolean a subclass of Int, then Python's behavior seems to be the most sensible. One could argue (and people did) about whether that was a good choice, but it's useful for a lot of practical applications. In any event, given that Boolean subclasses Int, I think the current behavior is probably for the best.
<br> </div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">   (but granted, I would usually go with Python is such cases)<br>2. consistency with Boolean matrices
</blockquote><div><br>OK. I sort of read past the fact that you were referring to matrices not arrays. This doesn't matter to me personally because I don't use the matrix class. I do do matrix algebra on occasion, but the matrix class has never been helpful for me. YMMV.
<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Elaboration on 2:<br>Boolean matrices currently behave as expected, with standard
<br>notation.  Related to this, they handle exponents correctly.<br><br>Suppose arrays are changed as you suggest.<br>Then either<br>- array behavior and matrix behavior are decoupled, or<br>- matrix behavior is completely broken for boolen matrices
<br><br>Alan Isaac<br><br>PS Examples of good behavior:<br><br>>>> x<br>matrix([[True, True],<br>        [True, False]], dtype=bool)<br>>>> y<br>matrix([[False, True],<br>        [True, False]], dtype=bool)
<br>>>> x*y<br>matrix([[True, True],<br>        [False, True]], dtype=bool)<br>>>> x**2<br>matrix([[True, True],<br>        [True, True]], dtype=bool)</blockquote><br>x*y and x**2 are already decoupled for arrays and matrices. What if x*y was simply defined to do a boolean matrix multiply when the arguments are boolean matrices?
<br></div><br>I don't care about this that much though, so I'll let it drop.<br clear="all"><br>-- <br>.  __<br>.   |-\<br>.<br>.  <a href="mailto:tim.hochberg@ieee.org">tim.hochberg@ieee.org</a>