Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68481:84c4bc069470
Date: 2013-12-18 21:27 -0500
http://bitbucket.org/pypy/pypy/changeset/84c4bc069470/
Log: test/fix promote_to_largest wrt 32bit, though demonstrates another
problem
diff --git a/pypy/module/micronumpy/interp_ufuncs.py
b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -498,13 +498,14 @@
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:
diff --git a/pypy/module/micronumpy/test/test_numarray.py
b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -1404,12 +1404,14 @@
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
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit