Commits

Justin Peel  committed de8306f

Fixed two dtype defs and find_result_dtype and added more tests

  • Participants
  • Parent commits 313d75d
  • Branches numpy-dtype

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_dtype.py

 
 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)
         # 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
 

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

         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)