Python3 and intp error (related to ticket 99)

Hi, I was curious why there was a difference in number of known failures between Python2.6 and Python3.1 which is associated a test due to ticket 99: http://projects.scipy.org/numpy/ticket/99 While this ticket was closed, it fails with Python 3.1 as indicated by the message of the test output is: 'Ticket #99 ... KNOWNFAIL: numpy.intp('0xff', 16) not supported on Py3, as it does not inherit from Python int' I do understand that np.intp is integer size of a pointer. But it appears to be mainly used for access to C programs. The only Python numpy usage I saw was with the delete and insert function in 'numpy/lib/function_base.py'. Does this really need to be exposed in Python? If it does not, then could be removed for Numpy 2? Otherwise, at the very least np.intp must have the same behavior across Python versions. As per the ticket, since it is an integer type, should it have the same properties as a regular integer? Bruce $ python3.1 Python 3.1.2 (r312:79147, Mar 24 2010, 10:44:23) [GCC 4.4.3 20100127 (Red Hat 4.4.3-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy numpy.__version__ '1.5.0' numpy.intp('0xff', 16) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: function takes at most 1 argument (2 given) numpy.intp('0xff') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: setting an array element with a sequence.
Yet there is no problem with Python 2.6: $ python Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:31) [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
import numpy numpy.__version__ '1.5.0' numpy.intp('0xff', 16) 255

Tue, 31 Aug 2010 12:03:55 -0500, Bruce Southey wrote: [clip]
I do understand that np.intp is integer size of a pointer. But it appears to be mainly used for access to C programs. The only Python numpy usage I saw was with the delete and insert function in 'numpy/lib/function_base.py'.
Does this really need to be exposed in Python? If it does not, then could be removed for Numpy 2?
Yes, it needs to be exposed, since it can be used in data type definitions.
Otherwise, at the very least np.intp must have the same behavior across Python versions. As per the ticket, since it is an integer type, should it have the same properties as a regular integer?
This is not specific to intp, but applies to all Numpy integer types on Python 3, since they no longer inherit the constructor from the Python integer. I note that on Python 2, you cannot do
np.int16('0xff', 16)
either -- it's the same issue. It's also a minor issue, IMHO, as I doubt many people construct array scalars from strings, and even less do it in bases other than 10. The fix is to change array scalar __new__, but this is not completely straightforward to do. Patches are welcome. -- Pauli Virtanen
participants (2)
-
Bruce Southey
-
Pauli Virtanen