Author: Justin Peel <[email protected]>
Branch: numpy-dtype
Changeset: r46232:de8306f5870e
Date: 2011-08-03 00:42 -0600
http://bitbucket.org/pypy/pypy/changeset/de8306f5870e/
Log: Fixed two dtype defs and find_result_dtype and added more tests
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
@@ -125,9 +125,9 @@
Bool_dtype = Dtype(cast_bool, unwrap_bool, Bool_num, BOOLLTR)
Int8_dtype = Dtype(cast_int8, unwrap_int, Int8_num, SIGNEDLTR)
-UInt8_dtype = Dtype(cast_uint8, unwrap_int, UInt8_num, SIGNEDLTR)
+UInt8_dtype = Dtype(cast_uint8, unwrap_int, UInt8_num, UNSIGNEDLTR)
Int16_dtype = Dtype(cast_int16, unwrap_int, Int16_num, SIGNEDLTR)
-UInt16_dtype = Dtype(cast_uint16, unwrap_int, UInt16_num, SIGNEDLTR)
+UInt16_dtype = Dtype(cast_uint16, unwrap_int, UInt16_num, UNSIGNEDLTR)
Int32_dtype = Dtype(cast_int32, unwrap_int, Int32_num, SIGNEDLTR)
UInt32_dtype = Dtype(cast_uint32, unwrap_int, UInt32_num, UNSIGNEDLTR)
Long_dtype = Dtype(cast_long, unwrap_int, Long_num, SIGNEDLTR)
@@ -216,8 +216,8 @@
# dtype2 is uint32
return Int64_dtype
if kind_num1 == 1: # is an integer
- if num2 == Float32_num and num2 == UInt64_num or \
- (LONG_BIT == 64 and num2 == Long_num):
+ if num2 == Float32_num and (num1 == UInt64_num or num1 == Int64_num or
\
+ (LONG_BIT == 64 and (num1 == Long_num or num1 == ULong_num))):
return Float64_dtype
return dtype2
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
@@ -51,4 +51,13 @@
a = array([True], '?')
for i in xrange(N):
assert (a + array([0], types[i])).dtype is dtypes[i]
-# need more tests for binop result types
+
+ def test_binop_types(self):
+ from numpy import array, dtype
+ tests = (('b','B','h'), ('b','h','h'), ('b','H','i'), ('b','I','q'),
+ ('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','f','d'))
+ for d1, d2, dout in tests:
+ assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit