Re: [Numpy-discussion] adding booleans

2013-06-08 Thread josef . pktd
On Sat, Jun 8, 2013 at 7:54 AM, Robert Kern wrote: > On Sat, Jun 8, 2013 at 12:40 PM, wrote: >> Question about namespace >> >> why is there bool and bool_ ? >> > np.bool(True) + np.bool(True) >> 2 > np.bool_(True) + np.bool_(True) >> True >> > type(np.bool(True)) >> > type(np.bo

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread josef . pktd
On Sat, Jun 8, 2013 at 5:18 AM, Sebastian Berg wrote: > On Sat, 2013-06-08 at 00:48 +0100, Nathaniel Smith wrote: >> On 7 Jun 2013 21:58, wrote: >> > >> > Interesting observation, (while lurking on a pull request) >> > >> > >>> np.add.reduce(np.arange(5)<3) >> > 3 >> > >>> np.add((np.arange(5)<3)

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread Robert Kern
On Sat, Jun 8, 2013 at 12:40 PM, wrote: > Question about namespace > > why is there bool and bool_ ? > np.bool(True) + np.bool(True) > 2 np.bool_(True) + np.bool_(True) > True > type(np.bool(True)) > type(np.bool_(True)) > > > I didn't pay attention to the trailing underline

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread josef . pktd
Question about namespace why is there bool and bool_ ? >>> np.bool(True) + np.bool(True) 2 >>> np.bool_(True) + np.bool_(True) True >>> type(np.bool(True)) >>> type(np.bool_(True)) I didn't pay attention to the trailing underline in Pauli's original example Josef

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread Sebastian Berg
On Fri, 2013-06-07 at 20:29 -0400, josef.p...@gmail.com wrote: > On Fri, Jun 7, 2013 at 8:08 PM, wrote: > > On Fri, Jun 7, 2013 at 7:48 PM, Nathaniel Smith wrote: > >> On 7 Jun 2013 21:58, wrote: > >>> > >>> Interesting observation, (while lurking on a pull request) > >>> > >>> >>> np.add.reduc

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread Pauli Virtanen
08.06.2013 02:48, Nathaniel Smith kirjoitti: [clip] > ...yeah weird. My gut reaction is that it's a bug. Addition on bools > should either be an error, undefined but doable via an implicit upcast > to int (analogous to calling np.sin on an int array triggering an upcast > to float), or xor (i.e., a

Re: [Numpy-discussion] adding booleans

2013-06-08 Thread Sebastian Berg
On Sat, 2013-06-08 at 00:48 +0100, Nathaniel Smith wrote: > On 7 Jun 2013 21:58, wrote: > > > > Interesting observation, (while lurking on a pull request) > > > > >>> np.add.reduce(np.arange(5)<3) > > 3 > > >>> np.add((np.arange(5)<3), (np.arange(5)<3)) > > array([ True, True, True, False, False

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
On Fri, Jun 7, 2013 at 8:08 PM, wrote: > On Fri, Jun 7, 2013 at 7:48 PM, Nathaniel Smith wrote: >> On 7 Jun 2013 21:58, wrote: >>> >>> Interesting observation, (while lurking on a pull request) >>> >>> >>> np.add.reduce(np.arange(5)<3) >>> 3 >>> >>> np.add((np.arange(5)<3), (np.arange(5)<3)) >>

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
On Fri, Jun 7, 2013 at 7:48 PM, Nathaniel Smith wrote: > On 7 Jun 2013 21:58, wrote: >> >> Interesting observation, (while lurking on a pull request) >> >> >>> np.add.reduce(np.arange(5)<3) >> 3 >> >>> np.add((np.arange(5)<3), (np.arange(5)<3)) >> array([ True, True, True, False, False], dtype=

Re: [Numpy-discussion] adding booleans

2013-06-07 Thread Nathaniel Smith
On 7 Jun 2013 21:58, wrote: > > Interesting observation, (while lurking on a pull request) > > >>> np.add.reduce(np.arange(5)<3) > 3 > >>> np.add((np.arange(5)<3), (np.arange(5)<3)) > array([ True, True, True, False, False], dtype=bool) > > > I often use summing of an array of boolean but didn't

[Numpy-discussion] adding booleans

2013-06-07 Thread josef . pktd
Interesting observation, (while lurking on a pull request) >>> np.add.reduce(np.arange(5)<3) 3 >>> np.add((np.arange(5)<3), (np.arange(5)<3)) array([ True, True, True, False, False], dtype=bool) I often use summing of an array of boolean but didn't know the second behavior Josef _