[Numpy-discussion] A couple more Numeric incompatibilitiesand a possible bug
Todd Miller
jmiller at stsci.edu
Sun Mar 28 17:19:27 EST 2004
On Sun, 2004-03-28 at 19:46, Gary Ruben wrote:
> > I'm guessing, but I think you would like to see:
> >
> > >>> abs(-1.)
> > 1.0
> > >>> abs(1)
> > 1
>
> Hi Todd,
>
> Sorry if I wasn't clear. Yes, that's what I was expecting to see. Thanks for logging it and thanks for the explanation of why it's happening.
>
> I'd also like to restate the other issues in the email to which that one referred, which haven't been commented on. The cos function result
>
> >>> cos(1)
> 0.54030227661132813
>
> gives a different result to cos(1.)
> Is this just because of numarray's stated departures from the way type coercion is done in Numeric? My guess is that numarray is casting the integer to a rank-0 Float32 array which is then coerced back to the native Python float type, which presumably is a float64 on the Windows platform.
This sounds correct. (Thanks for explaining it!)
> Do others think precision is being lost unnecessarily?
No. Do you have any suggestions?
> Finally, has anyone got any comment about whether the __repr__ versus __str__ display of object array members is the expected behaviour?
>
Yes. The basic look is exactly what I wanted:
>>> a = numarray.objects.fromlist(range(10))
>>> str(a)
'[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
>>> repr(a)
'ObjectArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])'
But I'm open to suggestions and recognize that the handling of
spaces/item sizing is weak (although it's not pronounced in this simple
example). Do people want something else?
Regards,
Todd
--
Todd Miller <jmiller at stsci.edu>
More information about the NumPy-Discussion
mailing list