[pypy-commit] pypy numpy-record-dtypes: export few more types and check their __mro__

fijal noreply at buildbot.pypy.org
Mon Feb 6 12:28:11 CET 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: numpy-record-dtypes
Changeset: r52132:25d165290ecd
Date: 2012-02-06 13:27 +0200
http://bitbucket.org/pypy/pypy/changeset/25d165290ecd/

Log:	export few more types and check their __mro__

diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -43,9 +43,12 @@
         'signedinteger': 'interp_boxes.W_SignedIntegerBox',
         'unsignedinteger': 'interp_boxes.W_UnsignedIntegerBox',
         'bool_': 'interp_boxes.W_BoolBox',
+        'bool8': 'interp_boxes.W_BoolBox',
         'int8': 'interp_boxes.W_Int8Box',
+        'byte': 'interp_boxes.W_Int8Box',
         'uint8': 'interp_boxes.W_UInt8Box',
         'int16': 'interp_boxes.W_Int16Box',
+        'short': 'interp_boxes.W_Int16Box',
         'uint16': 'interp_boxes.W_UInt16Box',
         'int32': 'interp_boxes.W_Int32Box',
         'uint32': 'interp_boxes.W_UInt32Box',
@@ -57,6 +60,9 @@
         'float_': 'interp_boxes.W_Float64Box',
         'float32': 'interp_boxes.W_Float32Box',
         'float64': 'interp_boxes.W_Float64Box',
+        #'str_': 'interp_boxes.W_StringBox',
+        #'unicode_': 'interp_boxes.W_UnicodeBox',
+        #'void': 'interp_boxes.W_VoidBox',
     }
 
     # ufuncs
diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py
--- a/pypy/module/micronumpy/interp_dtype.py
+++ b/pypy/module/micronumpy/interp_dtype.py
@@ -13,6 +13,7 @@
 SIGNEDLTR = "i"
 BOOLLTR = "b"
 FLOATINGLTR = "f"
+VOID = 'V'
 
 
 VOID_STORAGE = lltype.Array(lltype.Char, hints={'nolength': True, 'render_as_void': True})
@@ -69,6 +70,8 @@
             for dtype in cache.builtin_dtypes:
                 if dtype.name == name or dtype.char == name or name in dtype.aliases:
                     return dtype
+        elif space.isinstance_w(w_dtype, space.w_list):
+            xxx
         else:
             for dtype in cache.builtin_dtypes:
                 if w_dtype in dtype.alternate_constructors:
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -188,10 +188,11 @@
         raises(TypeError, numpy.number, 0)
         raises(TypeError, numpy.integer, 0)
         exc = raises(TypeError, numpy.signedinteger, 0)
-        assert str(exc.value) == "cannot create 'signedinteger' instances"
+        assert 'cannot create' in str(exc.value)
+        assert 'signedinteger' in str(exc.value)
         exc = raises(TypeError, numpy.unsignedinteger, 0)
-        assert str(exc.value) == "cannot create 'unsignedinteger' instances"
-
+        assert 'cannot create' in str(exc.value)
+        assert 'unsignedinteger' in str(exc.value)
         raises(TypeError, numpy.floating, 0)
         raises(TypeError, numpy.inexact, 0)
 
@@ -401,3 +402,19 @@
         else:
             assert issubclass(int64, int)
             assert int_ is int64
+
+    def test_various_types(self):
+        import _numpypy as numpy
+        
+        assert numpy.int16 is numpy.short
+        assert numpy.int8 is numpy.byte
+        assert numpy.bool_ is numpy.bool8
+
+    def test_mro(self):
+        import _numpypy as numpy
+        
+        assert numpy.int16.__mro__ == (numpy.int16, numpy.signedinteger,
+                                       numpy.integer, numpy.number,
+                                       numpy.generic, object)
+        assert numpy.bool_.__mro__ == (numpy.bool_, numpy.generic, object)
+        #assert numpy.str_.__mro__ == 


More information about the pypy-commit mailing list