[Numpy-discussion] float64 / int comparison different from float / int comparison

Chris.Barker Chris.Barker at noaa.gov
Tue Nov 1 11:39:54 EDT 2011


On 10/31/11 6:38 PM, Stéfan van der Walt wrote:
> On Mon, Oct 31, 2011 at 6:25 PM, Matthew Brett<matthew.brett at gmail.com>  wrote:
>> Oh, dear, I'm suffering now:

>> In [12]: res>  2**31-1
>> Out[12]: array([False], dtype=bool)

> I'm seeing:
...

> Your result seems very strange, because the numpy scalars should
> perform exactly the same inside and outside an array.

I get what Stéfan  gets:

In [32]: res = np.array((2**31,), dtype=np.float32)

In [33]: res > 2**31-1
Out[33]: array([ True], dtype=bool)

In [34]: res[0] > 2**31-1
Out[34]: True

In [35]: res[0].dtype
Out[35]: dtype('float32')


In [36]: np.__version__
Out[36]: '1.6.1'

(OS-X, Intel, Python2.7)


Something is very odd with your build!

-Chris






-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list