Commits

Brian Kearns committed 4846add

fix numpy.dtype(intp/uintp).num on 64bit

Comments (0)

Files changed (2)

pypy/module/micronumpy/interp_dtype.py

         if ptr_size == 4:
             intp_box = interp_boxes.W_Int32Box
             intp_type = types.Int32()
+            intp_num = 5
             uintp_box = interp_boxes.W_UInt32Box
             uintp_type = types.UInt32()
+            uintp_num = 6
         elif ptr_size == 8:
             intp_box = interp_boxes.W_Int64Box
             intp_type = types.Int64()
+            intp_num = 7
             uintp_box = interp_boxes.W_UInt64Box
             uintp_type = types.UInt64()
+            uintp_num = 8
         else:
             raise ValueError('unknown point size %d' % ptr_size)
         self.w_intpdtype = W_Dtype(
             intp_type,
-            num=5,
+            num=intp_num,
             kind=INTPLTR,
             name='intp',
             char=INTPLTR,
         )    
         self.w_uintpdtype = W_Dtype(
             uintp_type,
-            num=6,
+            num=uintp_num,
             kind=UINTPLTR,
             name='uintp',
             char=UINTPLTR,

pypy/module/micronumpy/test/test_dtypes.py

 from pypy.interpreter.gateway import interp2app
 
 class AppTestDtypes(BaseNumpyAppTest):
+    def setup_class(cls):
+        BaseNumpyAppTest.setup_class.im_func(cls)
+        if option.runappdirect:
+            import platform
+            bits, linkage = platform.architecture()
+            ptr_size = int(bits[:-3]) // 8
+        else:
+            from rpython.rtyper.lltypesystem import rffi
+            ptr_size = rffi.sizeof(rffi.CCHARP)
+        cls.w_ptr_size = cls.space.wrap(ptr_size)
+
     def test_dtype(self):
         from _numpypy import dtype
 
         from _numpypy import dtype
 
         assert dtype(bool).num == 0
-        assert dtype('intp').num == 5
-        assert dtype('uintp').num == 6
+        if self.ptr_size == 4:
+            assert dtype('intp').num == 5
+            assert dtype('uintp').num == 6
+        else:
+            assert dtype('intp').num == 7
+            assert dtype('uintp').num == 8
         assert dtype(int).num == 7
         assert dtype(long).num == 9
         assert dtype(float).num == 12
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.