[pypy-commit] pypy unsigned-dtypes: fixed binop dtype promotion. fixed one tests. All regular tests working. Some jit tests not working.
justinpeel
noreply at buildbot.pypy.org
Thu Sep 1 22:51:47 CEST 2011
Author: Justin Peel <notmuchtotell at gmail.com>
Branch: unsigned-dtypes
Changeset: r47001:0cc5004488bd
Date: 2011-09-01 14:51 -0600
http://bitbucket.org/pypy/pypy/changeset/0cc5004488bd/
Log: fixed binop dtype promotion. fixed one tests. All regular tests
working. Some jit tests not working.
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
@@ -407,12 +407,14 @@
class W_Float32Dtype(W_Float64Dtype):
pass
W_Float32Dtype.num = 11
+W_Float32Dtype.name = "float32"
W_Float32Dtype.aliases = ["f"]
W_Float32Dtype.applevel_types = []
class W_Float96Dtype(W_Float64Dtype):
pass
W_Float96Dtype.num = 13
+W_Float96Dtype.name = "float96"
W_Float96Dtype.aliases = ["g"]
W_Float96Dtype.applevel_types = []
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
@@ -174,7 +174,7 @@
# Everything promotes to float, and bool promotes to everything.
if dt2.kind == interp_dtype.FLOATINGLTR or dt1.kind == interp_dtype.BOOLLTR:
if dt2.num == 11 and dt1.num_bytes >= 4:
- return interp_dtype.W_Float64Dtype
+ return space.fromcache(interp_dtype.W_Float64Dtype)
return dt2
# for now this means mixing signed and unsigned
@@ -185,13 +185,19 @@
dtypenum = dt2.num + 2
else:
dtypenum = dt2.num + 1
+ if dt2.num == 10:
+ dtypenum += 1
newdtype = interp_dtype.ALL_DTYPES[dtypenum]
if newdtype.num_bytes > dt2.num_bytes or newdtype.kind == interp_dtype.FLOATINGLTR:
- return newdtype
+ return space.fromcache(newdtype)
else:
# we only promoted to long on 32-bit or to longlong on 64-bit
- return interp_dtype.ALL_DTYPES[dtypenum + 2]
+ if LONG_BIT == 32:
+ dtypenum += 2
+ else:
+ dtypenum += 3
+ return space.fromcache(interp_dtype.ALL_DTYPES[dtypenum])
def find_unaryop_result_dtype(space, dt, promote_to_float=False,
promote_bools=False, promote_to_largest=False):
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
@@ -96,11 +96,10 @@
def test_bool_binop_types(self):
from numpy import array, dtype
types = ('?','b','B','h','H','i','I','l','L','q','Q','f','d','g')
- dtypes = [dtype(t) for t in types]
N = len(types)
a = array([True], '?')
- for i in xrange(N):
- assert (a + array([0], types[i])).dtype is dtypes[i]
+ for t in types:
+ assert (a + array([0], t)).dtype is dtype(t)
def test_binop_types(self):
from numpy import array, dtype
@@ -108,7 +107,7 @@
('b','Q','d'), ('B','H','H'), ('B','I','I'), ('B','Q','Q'),
('B','h','h'), ('h','H','i'), ('h','i','i'), ('H','i','i'),
('H','I','I'), ('i','I','q'), ('I','q','q'), ('q','Q','d'),
- ('i','f','f'), ('q','f','d'), ('q','d','d'), ('Q','f','d'))
+ ('i','f','d'), ('q','f','d'), ('q','d','d'), ('Q','f','d'))
for d1, d2, dout in tests:
assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
More information about the pypy-commit
mailing list