[Numpy-discussion] ufunc oddities

Robert Kern robert.kern@gmail....
Sat May 24 22:01:02 CDT 2008


On Sat, May 24, 2008 at 9:57 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
> How about
>
> In [14]: x += 5
>
> In [15]: x
> Out[15]: array([ True,  True], dtype=bool)

Output = bool.

> In [16]: x.tostring()
> Out[16]: '\x01\x01'
>
>
> In [17]: x + 5
> Out[17]: array([6, 6])

Output != bool.

> In [18]: (x + 5).dtype
> Out[18]: dtype('int32')
>
> In [19]: (x.astype(int8) + 5).dtype
> Out[19]: dtype('int8')
>
> I have to write tests for 64 of these buggers and some poor sod has to write
> the documentation. All these inconsistencies are going to drive both of us
> mad.

They aren't inconsistent in the slightest. They follow from a very simple rule.

-- 
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


More information about the Numpy-discussion mailing list