Author: Philip Jenvey <pjen...@underboss.org> Branch: py3k Changeset: r68488:a2ebaff30cc5 Date: 2013-12-19 13:20 -0800 http://bitbucket.org/pypy/pypy/changeset/a2ebaff30cc5/
Log: merge default diff --git a/lib-python/2.7/ctypes/__init__.py b/lib-python/2.7/ctypes/__init__.py --- a/lib-python/2.7/ctypes/__init__.py +++ b/lib-python/2.7/ctypes/__init__.py @@ -371,10 +371,9 @@ self._handle = handle def __repr__(self): - return "<%s '%s', handle %r at %x>" % \ - (self.__class__.__name__, self._name, - (self._handle), - id(self) & (_sys.maxint*2 + 1)) + return "<%s '%s', handle %r at 0x%x>" % ( + self.__class__.__name__, self._name, self._handle, + id(self) & (_sys.maxint * 2 + 1)) def __getattr__(self, name): 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 @@ -1,4 +1,3 @@ -import sys from pypy.interpreter.baseobjspace import W_Root from pypy.interpreter.error import OperationError, operationerrfmt from pypy.interpreter.gateway import interp2app, unwrap_spec 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 @@ -1400,16 +1400,18 @@ assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all() def test_prod(self): - from numpypy import array, int_, dtype + from numpypy import array, dtype 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 == 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 == dtype(dt) def test_max(self): from numpypy import array, zeros _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit