Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-14 Thread Stefan van der Walt
On Mon, Jul 09, 2007 at 12:32:02PM -0700, Timothy Hochberg wrote: > I gave this a try. Since so much code is auto-generated, it can be difficult > to > figure out what's going on in the core matrix stuff. Still, it seems like the > solution is almost absurdly easy, consisting of changing only thre

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Alan Isaac
On Tue, 10 Jul 2007, Timothy Hochberg wrote: > 1. > +,- are arithmetic operators and return ints not booleans > 2. > *,** are arithmetic operators on scalars and arrays and return ints as above. > 3. > &,|,^ are the logical operators and return booleans. > 4. > *,** are defined on matrices

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Charles R Harris
On 7/10/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: [CHOP: lots of examples] It looks like bool_s could use some general rejiggering. Let me put forth a concrete proposal that's based on matching bool_ behaviour to that of Python's bools. There is another route that could be taken where bo

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Timothy Hochberg
[CHOP: lots of examples] It looks like bool_s could use some general rejiggering. Let me put forth a concrete proposal that's based on matching bool_ behaviour to that of Python's bools. There is another route that could be taken where bool_ and bool are completely decoupled, but I'll skip over t

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Gael Varoquaux
On Tue, Jul 10, 2007 at 11:31:35AM -0400, Alan G Isaac wrote: > Do you agree that the first (!!!) answer is a bug? > (The basis is apparently performed as follows: > integer array subtraction is first performed, and > then nonzero ints are converted to True. But this > gives the wrong answer and m

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Alan G Isaac
Hi Gael, More important is the following. On Tue, 10 Jul 2007, Alan G Isaac apparently wrote: N.array([False])-N.array([True]) > array([True], dtype=bool) N.array([False])+(-N.array([True])) > array([False], dtype=bool) > The second answer is the right one, in this context. > I

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Gael Varoquaux
On Tue, Jul 10, 2007 at 10:36:55AM -0400, Alan G Isaac wrote: > I found Gael's presentation rather puzzling for two reasons. > 1. It appears to contain a `+` vs. `*` confusion. > See http://en.wikipedia.org/wiki/Two-element_Boolean_algebra Damn it. I used math conventions, for "+" and "*" (in mat

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Alan G Isaac
On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote: > 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? > I don't care about this that much though, so I'll let it drop. So

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Alan G Isaac
I found Gael's presentation rather puzzling for two reasons. 1. It appears to contain a `+` vs. `*` confusion. See http://en.wikipedia.org/wiki/Two-element_Boolean_algebra 2. MUCH more importantly: In implementations of TWO, we interpret `-` as unary complementation (not e.g. as additive inverse

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Charles R Harris
On 7/10/07, Gael Varoquaux <[EMAIL PROTECTED]> wrote: On Tue, Jul 10, 2007 at 02:39:28PM +0200, Sebastian Haase wrote: > When you talk about algebra - one might have to restrict one self to '|' and '&' > -- not use '+' and '-' > E.g.: > True - True = False # right !? > # but if: > True+True

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Gael Varoquaux
On Tue, Jul 10, 2007 at 02:39:28PM +0200, Sebastian Haase wrote: > When you talk about algebra - one might have to restrict one self to '|' and > '&' > -- not use '+' and '-' > E.g.: > True - True = False # right !? > # but if: > True+True = True. > # then > True+True -False = Tr

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Matthieu Brucher
When you talk about algebra - one might have to restrict one self to '|' and '&' -- not use '+' and '-' E.g.: True - True = False # right !? Not exactly because - True = + True So True - True = True + True = True You have to stay in the algebra the whole time. # but if: True+True

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-10 Thread Sebastian Haase
On 7/10/07, Matthieu Brucher <[EMAIL PROTECTED]> wrote: > > Hi, > > > > > > > > On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote: > > > > Why not simply use & and | instead of + and *? > > > > > > A couple reasons, none determinative. > > > 1. numpy is right a Python is wrong it this case > >

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-09 Thread Matthieu Brucher
Hi, On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote: > > Why not simply use & and | instead of + and *? > > A couple reasons, none determinative. > 1. numpy is right a Python is wrong it this case I don't think I agree with this. Once you've decided to make Boolean a subclass of Int, th

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-09 Thread Timothy Hochberg
On 7/9/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote: > Why not simply use & and | instead of + and *? A couple reasons, none determinative. 1. numpy is right a Python is wrong it this case I don't think I agree with this. Once you've decid

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-09 Thread Alan G Isaac
On Mon, 9 Jul 2007, Timothy Hochberg apparently wrote: > Why not simply use & and | instead of + and *? A couple reasons, none determinative. 1. numpy is right a Python is wrong it this case (but granted, I would usually go with Python is such cases) 2. consistency with Boolean matrices

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-09 Thread Timothy Hochberg
On 7/7/07, Alan G Isaac <[EMAIL PROTECTED]> wrote: On Sat, 7 Jul 2007, Charles R Harris apparently wrote: > In [60]: a > Out[60]: array([ True, True, True, True], dtype=bool) > In [61]: a + a > Out[61]: array([ True, True, True, True], dtype=bool) Yea! Behaves like a boolean array. And fo

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-09 Thread Timothy Hochberg
On 7/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > > On 7/6/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Timothy Hochberg wrote: > > > > I'm working on getting some old code working with numpy and I > noticed > > that bool_ is not

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-07 Thread Alan G Isaac
On Sat, 7 Jul 2007, Charles R Harris apparently wrote: > In [60]: a > Out[60]: array([ True, True, True, True], dtype=bool) > In [61]: a + a > Out[61]: array([ True, True, True, True], dtype=bool) Yea! Behaves like a boolean array. And for multiplication to. And in boolean matrices, pow

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-07 Thread Charles R Harris
On 7/7/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: On 7/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > > > > > > > On 7/6/07, *Travis Oliphant* <[EMAIL PROTECTED] > > > wrote: > > Here is a link to PEP 285 wher

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-07 Thread Timothy Hochberg
On 7/7/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > > On 7/6/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Timothy Hochberg wrote: > > > > I'm working on getting some old code working with numpy and I > noticed > > that bool_ is not

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-07 Thread Travis Oliphant
> > > On 7/6/07, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Timothy Hochberg wrote: > > > > I'm working on getting some old code working with numpy and I > noticed > > that bool_ is not a subclass of int. Given that python's bool > > subc

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-07 Thread Timothy Hochberg
On 7/6/07, Travis Oliphant <[EMAIL PROTECTED]> wrote: Timothy Hochberg wrote: > > I'm working on getting some old code working with numpy and I noticed > that bool_ is not a subclass of int. Given that python's bool > subclasses into and that the other scalar types are subclasses of > their resp

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-06 Thread Travis Oliphant
Timothy Hochberg wrote: > > I'm working on getting some old code working with numpy and I noticed > that bool_ is not a subclass of int. Given that python's bool > subclasses into and that the other scalar types are subclasses of > their respective counterparts it seems at first glance that > n

Re: [Numpy-discussion] Should bool_ subclass int?

2007-07-06 Thread Robert Kern
Timothy Hochberg wrote: > > I'm working on getting some old code working with numpy and I noticed > that bool_ is not a subclass of int. Given that python's bool subclasses > into and that the other scalar types are subclasses of their respective > counterparts it seems at first glance that numpy.

[Numpy-discussion] Should bool_ subclass int?

2007-07-06 Thread Timothy Hochberg
I'm working on getting some old code working with numpy and I noticed that bool_ is not a subclass of int. Given that python's bool subclasses into and that the other scalar types are subclasses of their respective counterparts it seems at first glance that numpy.bool_ should subclass python's boo