Author: Ronan Lamy <[email protected]>
Branch: fix-result-types
Changeset: r77551:0375c5f721be
Date: 2015-05-25 20:10 +0100
http://bitbucket.org/pypy/pypy/changeset/0375c5f721be/

Log:    fix 32-bit dtype tests and remove duplication with test_scalar.py

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
@@ -146,16 +146,18 @@
             assert dtype('uint32').num == 8
             assert dtype('int64').num == 9
             assert dtype('uint64').num == 10
+            assert dtype('intp').num == 5
+            assert dtype('uintp').num == 6
         else:
             assert dtype('int32').num == 5
             assert dtype('uint32').num == 6
             assert dtype('int64').num == 7
             assert dtype('uint64').num == 8
+            assert dtype('intp').num == 7
+            assert dtype('uintp').num == 8
         assert dtype(int).num == 7
         assert dtype('int').num == 7
         assert dtype('uint').num == 8
-        assert dtype('intp').num == 7
-        assert dtype('uintp').num == 8
         assert dtype(long).num == 9
         assert dtype(float).num == 12
         assert dtype('float').num == 12
@@ -850,36 +852,6 @@
             assert issubclass(int64, int)
             assert int_ is int64
 
-    def test_various_types(self):
-        import numpy
-
-        assert numpy.int16 is numpy.short
-        assert numpy.int8 is numpy.byte
-        assert numpy.bool_ is numpy.bool8
-        assert numpy.intp().dtype.num == 7
-        assert numpy.intp().dtype.char == 'l'
-        if self.ptr_size == 4:
-            assert numpy.intp().dtype.name == 'int32'
-            assert numpy.intp is numpy.int32
-            assert numpy.uintp is numpy.uint32
-        elif self.ptr_size == 8:
-            assert numpy.intp().dtype.name == 'int64'
-            assert numpy.intp is numpy.int64
-            assert numpy.uintp is numpy.uint64
-
-        assert issubclass(numpy.float64, numpy.floating)
-        assert issubclass(numpy.longfloat, numpy.floating)
-        assert not issubclass(numpy.float64, numpy.longfloat)
-        assert not issubclass(numpy.longfloat, numpy.float64)
-
-    def test_mro(self):
-        import 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)
-
     def test_operators(self):
         from operator import truediv
         from numpy import float64, int_, True_, False_
@@ -959,20 +931,22 @@
 
     def test_intp(self):
         from numpy import dtype
-        for s in ['p', 'int']:
-            assert dtype(s) is dtype('intp')
-        for s in ['P', 'uint']:
-            assert dtype(s) is dtype('uintp')
-        assert dtype('p').num == 7
-        assert dtype('P').num == 8
-        assert dtype('p').char == 'l'
-        assert dtype('P').char == 'L'
+        assert dtype('p') is dtype('intp')
+        assert dtype('P') is dtype('uintp')
         assert dtype('p').kind == 'i'
         assert dtype('P').kind == 'u'
         if self.ptr_size == 4:
+            assert dtype('p').num == 5
+            assert dtype('P').num == 6
+            assert dtype('p').char == 'i'
+            assert dtype('P').char == 'I'
             assert dtype('p').name == 'int32'
             assert dtype('P').name == 'uint32'
         else:
+            assert dtype('p').num == 7
+            assert dtype('P').num == 8
+            assert dtype('p').char == 'l'
+            assert dtype('P').char == 'L'
             assert dtype('p').name == 'int64'
             assert dtype('P').name == 'uint64'
 
diff --git a/pypy/module/micronumpy/test/test_scalar.py 
b/pypy/module/micronumpy/test/test_scalar.py
--- a/pypy/module/micronumpy/test/test_scalar.py
+++ b/pypy/module/micronumpy/test/test_scalar.py
@@ -20,6 +20,7 @@
             assert np.uintp is np.dtype('L').type
             assert np.int64 is np.dtype('l').type
             assert np.uint64 is np.dtype('L').type
+        assert np.int16 is np.short is np.dtype('h').type
         assert np.int_ is np.dtype('l').type
         assert np.uint is np.dtype('L').type
         assert np.dtype('intp') == np.dtype('int')
@@ -27,6 +28,20 @@
         assert np.dtype('i') is not np.dtype('l') is not np.dtype('q')
         assert np.dtype('I') is not np.dtype('L') is not np.dtype('Q')
 
+    def test_hierarchy(self):
+        import numpy
+        assert issubclass(numpy.float64, numpy.floating)
+        assert issubclass(numpy.longfloat, numpy.floating)
+        assert not issubclass(numpy.float64, numpy.longfloat)
+        assert not issubclass(numpy.longfloat, numpy.float64)
+
+    def test_mro(self):
+        import 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)
+
     def test_init(self):
         import numpy as np
         import math
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to