1. Pypy
  2. Untitled project
  3. pypy

Commits

Brian Kearns  committed 84c4bc0

test/fix promote_to_largest wrt 32bit, though demonstrates another problem

  • Participants
  • Parent commits 69886da
  • Branches default

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_ufuncs.py

View file
  • Ignore whitespace
         promote_bools=False, promote_to_largest=False):
     if promote_to_largest:
         if dt.kind == NPY_GENBOOLLTR or dt.kind == NPY_SIGNEDLTR:
-            return interp_dtype.get_dtype_cache(space).w_int64dtype
+            if dt.get_size() * 8 < LONG_BIT:
+                return interp_dtype.get_dtype_cache(space).w_longdtype
         elif dt.kind == NPY_UNSIGNEDLTR:
-            return interp_dtype.get_dtype_cache(space).w_uint64dtype
-        elif dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR:
-            return dt
+            if dt.get_size() * 8 < LONG_BIT:
+                return interp_dtype.get_dtype_cache(space).w_ulongdtype
         else:
-            assert False
+            assert dt.kind == NPY_FLOATINGLTR or dt.kind == NPY_COMPLEXLTR
+        return dt
     if promote_bools and (dt.kind == NPY_GENBOOLLTR):
         return interp_dtype.get_dtype_cache(space).w_int8dtype
     if promote_to_float:

File pypy/module/micronumpy/test/test_numarray.py

View file
  • Ignore whitespace
         a = array(range(1, 6))
         assert a.prod() == 120.0
         assert a[:4].prod() == 24.0
-        a = array([True, False])
-        assert a.prod() == 0
-        assert type(a.prod()) is int_
-        a = array([True, False], dtype='uint')
-        assert a.prod() == 0
-        assert type(a.prod()) is dtype('uint').type
+        for dt in ['bool', 'int8', 'uint8', 'int16', 'uint16']:
+            a = array([True, False], dtype=dt)
+            assert a.prod() == 0
+            assert a.prod().dtype is dtype('uint' if dt[0] == 'u' else 'int')
+        for dt in ['l', 'L', 'q', 'Q', 'e', 'f', 'd', 'F', 'D']:
+            a = array([True, False], dtype=dt)
+            assert a.prod() == 0
+            assert a.prod().dtype is dtype(dt)
 
     def test_max(self):
         from numpypy import array, zeros