[pypy-issue] [issue1160] numpypy.int missing and numpy.integer doesn't work

Peter tracker at bugs.pypy.org
Sat Jun 9 23:46:50 CEST 2012


New submission from Peter <p.j.a.cock at googlemail.com>:

Consider the following in C Python 2.6, running on 64 bit Max OS X, where I use several 
different aliases to create an array of 64 bit integers:

$ python
Python 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.__version__
'1.5.1'
>>> np.zeros([4,4], np.int)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>> np.zeros([4,4], np.int).dtype
dtype('int64')
>>> np.zeros([4,4], np.integer)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>> np.zeros([4,4], np.integer).dtype
dtype('int64')
>>> np.zeros([4,4], np.intp)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>> np.zeros([4,4], np.intp).dtype
dtype('int64')
>>> np.zeros([4,4], np.int64)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>> np.zeros([4,4], np.int64).dtype
dtype('int64')


All for datatypes work and (on this machine) give int64. Now using PyPy 1.9,

$ ~/Downloads/pypy-1.9/bin/pypy
Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:42:54)
[PyPy 1.9.0 with GCC 4.2.1] on darwin
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``Python 2.x est presque mort, vive
Python!''
>>>> import numpypy
>>>> import numpy as np
>>>> np.zeros([4,4], np.int)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'int'

Try using integer:

>>>> np.zeros([4,4], np.integer)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: data type not understood


However the following do work:


>>>> np.zeros([4,4], np.intp)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>>> np.zeros([4,4], np.intp).dtype
dtype('int64')
>>>> np.zeros([4,4], np.int64)
array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])
>>>> np.zeros([4,4], np.int64).dtype
dtype('int64')



Possibly related to issue 1023

----------
messages: 4394
nosy: peterjc, pypy-issue
priority: bug
release: 1.9
status: unread
title: numpypy.int missing and numpy.integer doesn't work

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1160>
________________________________________


More information about the pypy-issue mailing list