[Numpy-discussion] Unexpected behavior with np.min_scalar_type

Kathleen M Tacina Kathleen.M.Tacina@nasa....
Tue Jan 24 09:29:16 CST 2012


I was experimenting with np.min_scalar_type to make sure it worked as
expected, and found some unexpected results for integers between 2**63
and 2**64-1.  I would have expected np.min_scalar_type(2**64-1) to
return uint64.  Instead, I get object.  Further experimenting showed
that the largest integer for which np.min_scalar_type will return uint64
is 2**63-1.  Is this expected behavior?

On python 2.7.2 on a 64-bit linux machine:
>>> import numpy as np
>>> np.version.full_version
'2.0.0.dev-55472ca'
>>> np.min_scalar_type(2**8-1)
dtype('uint8')
>>> np.min_scalar_type(2**16-1)
dtype('uint16')
>>> np.min_scalar_type(2**32-1)
dtype('uint32')
>>> np.min_scalar_type(2**64-1)
dtype('O')
>>> np.min_scalar_type(2**63-1)
dtype('uint64')
>>> np.min_scalar_type(2**63)
dtype('O')

I get the same results on a Windows XP  machine running python 2.7.2 and
numpy 1.6.1. 

Kathy          
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120124/68c4af44/attachment.html 


More information about the NumPy-Discussion mailing list