Author: Matti Picus <[email protected]>
Branch: str-dtype-improvement
Changeset: r62390:f793000f4f09
Date: 2013-03-17 18:52 +0200
http://bitbucket.org/pypy/pypy/changeset/f793000f4f09/

Log:    intrusively fix record field matching

diff --git a/pypy/module/micronumpy/interp_arrayops.py 
b/pypy/module/micronumpy/interp_arrayops.py
--- a/pypy/module/micronumpy/interp_arrayops.py
+++ b/pypy/module/micronumpy/interp_arrayops.py
@@ -116,6 +116,17 @@
                     "all the input arrays must have same number of 
dimensions"))
             elif i == _axis:
                 shape[i] += axis_size
+        a_dt = arr.get_dtype()
+        if dtype.is_record_type() and a_dt.is_record_type():
+            #Record types must match
+            for f in dtype.fields:
+                if f not in a_dt.fields or \
+                             dtype.fields[f] != a_dt.fields[f]:
+                    raise OperationError(space.w_TypeError, 
+                               space.wrap("record type mismatch"))
+        elif dtype.is_record_type() or a_dt.is_record_type():
+            raise OperationError(space.w_TypeError, 
+                        space.wrap("invalid type promotion"))
         dtype = interp_ufuncs.find_binop_result_dtype(space, dtype,
                                                       arr.get_dtype())
         if _axis < 0 or len(arr.get_shape()) <= _axis:
diff --git a/pypy/module/micronumpy/interp_boxes.py 
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -278,7 +278,7 @@
                              dtype.coerce(space, w_value))
 
     def convert_to(self, dtype):
-        # TODO actually perform the conversion, this requires a space arg
+        # if we reach here, the record fields are guarenteed to match.
         return self
 
 class W_CharacterBox(W_FlexibleBox):
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
@@ -438,7 +438,6 @@
         # For those operations that get here (concatenate, stack),
         # flexible types take precedence over numeric type
         if dt2.is_record_type():
-            #TODO record types require an exact match
             return dt2
         if dt1.is_str_or_unicode():
             if dt2.num == 18:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to