[pypy-commit] pypy matrixmath-dot: bad merge

mattip noreply at buildbot.pypy.org
Mon Dec 5 22:42:05 CET 2011


Author: mattip
Branch: matrixmath-dot
Changeset: r50186:55f149559e25
Date: 2011-12-04 22:06 +0200
http://bitbucket.org/pypy/pypy/changeset/55f149559e25/

Log:	bad merge

diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -3,13 +3,16 @@
 It should not be imported by the module itself
 """
 
+import re
+
 from pypy.interpreter.baseobjspace import InternalSpaceCache, W_Root
-from pypy.module.micronumpy.interp_dtype import W_Float64Dtype, W_BoolDtype
+from pypy.module.micronumpy import interp_boxes
+from pypy.module.micronumpy.interp_dtype import get_dtype_cache
 from pypy.module.micronumpy.interp_numarray import (Scalar, BaseArray,
-     descr_new_array, scalar_w, NDimArray)
+     scalar_w, W_NDimArray, array)
 from pypy.module.micronumpy import interp_ufuncs
-from pypy.rlib.objectmodel import specialize
-import re
+from pypy.rlib.objectmodel import specialize, instantiate
+
 
 class BogusBytecode(Exception):
     pass
@@ -49,15 +52,12 @@
     def __init__(self):
         """NOT_RPYTHON"""
         self.fromcache = InternalSpaceCache(self).getorbuild
-        self.w_float64dtype = W_Float64Dtype(self)
 
     def issequence_w(self, w_obj):
-        return isinstance(w_obj, ListObject) or isinstance(w_obj, NDimArray)
+        return isinstance(w_obj, ListObject) or isinstance(w_obj, W_NDimArray)
 
     def isinstance_w(self, w_obj, w_tp):
-        if w_obj.tp == w_tp:
-            return True
-        return False
+        return w_obj.tp == w_tp
 
     def decode_index4(self, w_idx, size):
         if isinstance(w_idx, IntObject):
@@ -98,8 +98,10 @@
     fixedview = listview
 
     def float(self, w_obj):
-        assert isinstance(w_obj, FloatObject)
-        return w_obj
+        if isinstance(w_obj, FloatObject):
+            return w_obj
+        assert isinstance(w_obj, interp_boxes.W_GenericBox)
+        return self.float(w_obj.descr_float(self))
 
     def float_w(self, w_obj):
         assert isinstance(w_obj, FloatObject)
@@ -113,7 +115,10 @@
         raise NotImplementedError
 
     def int(self, w_obj):
-        return w_obj
+        if isinstance(w_obj, IntObject):
+            return w_obj
+        assert isinstance(w_obj, interp_boxes.W_GenericBox)
+        return self.int(w_obj.descr_int(self))
 
     def is_true(self, w_obj):
         assert isinstance(w_obj, BoolObject)
@@ -136,6 +141,9 @@
         assert isinstance(what, tp)
         return what
 
+    def allocate_instance(self, klass, w_subtype):
+        return instantiate(klass)
+
     def len_w(self, w_obj):
         if isinstance(w_obj, ListObject):
             return len(w_obj.items)
@@ -248,7 +256,7 @@
             w_rhs = self.rhs.execute(interp)
         if not isinstance(w_lhs, BaseArray):
             # scalar
-            dtype = interp.space.fromcache(W_Float64Dtype)
+            dtype = get_dtype_cache(interp.space).w_float64dtype
             w_lhs = scalar_w(interp.space, dtype, w_lhs)
         assert isinstance(w_lhs, BaseArray)
         if self.name == '+':
@@ -265,8 +273,9 @@
             w_res = w_lhs.descr_getitem(interp.space, w_rhs)
         else:
             raise NotImplementedError
-        if not isinstance(w_res, BaseArray):
-            dtype = interp.space.fromcache(W_Float64Dtype)
+        if (not isinstance(w_res, BaseArray) and
+            not isinstance(w_res, interp_boxes.W_GenericBox)):
+            dtype = get_dtype_cache(interp.space).w_float64dtype
             w_res = scalar_w(interp.space, dtype, w_res)
         return w_res
 
@@ -284,7 +293,7 @@
         return space.wrap(self.v)
 
     def execute(self, interp):
-        return FloatObject(self.v)
+        return interp.space.wrap(self.v)
 
 class RangeConstant(Node):
     def __init__(self, v):
@@ -292,10 +301,10 @@
 
     def execute(self, interp):
         w_list = interp.space.newlist(
-            [interp.space.wrap(float(i)) for i in range(self.v)])
-        dtype = interp.space.fromcache(W_Float64Dtype)
-        return descr_new_array(interp.space, None, w_list, w_dtype=dtype,
-                               w_order=None)
+            [interp.space.wrap(float(i)) for i in range(self.v)]
+        )
+        dtype = get_dtype_cache(interp.space).w_float64dtype
+        return array(interp.space, w_list, w_dtype=dtype, w_order=None)
 
     def __repr__(self):
         return 'Range(%s)' % self.v
@@ -316,9 +325,8 @@
 
     def execute(self, interp):
         w_list = self.wrap(interp.space)
-        dtype = interp.space.fromcache(W_Float64Dtype)
-        return descr_new_array(interp.space, None, w_list, w_dtype=dtype,
-                               w_order=None)
+        dtype = get_dtype_cache(interp.space).w_float64dtype
+        return array(interp.space, w_list, w_dtype=dtype, w_order=None)
 
     def __repr__(self):
         return "[" + ", ".join([repr(item) for item in self.items]) + "]"
@@ -398,9 +406,11 @@
         if isinstance(w_res, BaseArray):
             return w_res
         if isinstance(w_res, FloatObject):
-            dtype = interp.space.fromcache(W_Float64Dtype)
+            dtype = get_dtype_cache(interp.space).w_float64dtype
         elif isinstance(w_res, BoolObject):
-            dtype = interp.space.fromcache(W_BoolDtype)
+            dtype = get_dtype_cache(interp.space).w_booldtype
+        elif isinstance(w_res, interp_boxes.W_GenericBox):
+            dtype = w_res.get_dtype(interp.space)
         else:
             dtype = None
         return scalar_w(interp.space, dtype, w_res)
diff --git a/pypy/module/micronumpy/test/test_compile.py b/pypy/module/micronumpy/test/test_compile.py
--- a/pypy/module/micronumpy/test/test_compile.py
+++ b/pypy/module/micronumpy/test/test_compile.py
@@ -1,6 +1,8 @@
 
 import py
-from pypy.module.micronumpy.compile import *
+from pypy.module.micronumpy.compile import (numpy_compile, Assignment,
+    ArrayConstant, FloatConstant, Operator, Variable, RangeConstant, Execute,
+    FunctionCall, FakeSpace)
 
 class TestCompiler(object):
     def compile(self, code):
@@ -106,7 +108,7 @@
         c -> 3
         """
         interp = self.run(code)
-        assert interp.results[-1].value.val == 9
+        assert interp.results[-1].value == 9
 
     def test_array_getitem(self):
         code = """
@@ -115,7 +117,7 @@
         a + b -> 3
         """
         interp = self.run(code)
-        assert interp.results[0].value.val == 3 + 6
+        assert interp.results[0].value == 3 + 6
 
     def test_range_getitem(self):
         code = """
@@ -123,7 +125,7 @@
         r -> 3
         """
         interp = self.run(code)
-        assert interp.results[0].value.val == 6
+        assert interp.results[0].value == 6
 
     def test_sum(self):
         code = """
@@ -132,7 +134,7 @@
         r
         """
         interp = self.run(code)
-        assert interp.results[0].value.val == 15
+        assert interp.results[0].value.value == 15
 
     def test_array_write(self):
         code = """
@@ -141,7 +143,7 @@
         a -> 3
         """
         interp = self.run(code)
-        assert interp.results[0].value.val == 15
+        assert interp.results[0].value == 15
 
     def test_min(self):
         interp = self.run("""
@@ -150,7 +152,7 @@
         b = a + a
         min(b)
         """)
-        assert interp.results[0].value.val == -24
+        assert interp.results[0].value.value == -24
 
     def test_max(self):
         interp = self.run("""
@@ -159,7 +161,7 @@
         b = a + a
         max(b)
         """)
-        assert interp.results[0].value.val == 256
+        assert interp.results[0].value.value == 256
 
     def test_slice(self):
         interp = self.run("""
@@ -167,7 +169,7 @@
         b = a -> :
         b -> 3
         """)
-        assert interp.results[0].value.val == 4
+        assert interp.results[0].value == 4
 
     def test_slice_step(self):
         interp = self.run("""
@@ -175,7 +177,7 @@
         b = a -> ::2
         b -> 3
         """)
-        assert interp.results[0].value.val == 6
+        assert interp.results[0].value == 6
 
     def test_setslice(self):
         interp = self.run("""
@@ -185,7 +187,7 @@
         a[::3] = b
         a -> 3
         """)
-        assert interp.results[0].value.val == 5
+        assert interp.results[0].value == 5
 
 
     def test_slice2(self):
@@ -196,14 +198,14 @@
         b = s1 + s2
         b -> 3
         """)
-        assert interp.results[0].value.val == 15
+        assert interp.results[0].value == 15
 
     def test_multidim_getitem(self):
         interp = self.run("""
         a = [[1,2]]
         a -> 0 -> 1
         """)
-        assert interp.results[0].value.val == 2
+        assert interp.results[0].value == 2
 
     def test_multidim_getitem_2(self):
         interp = self.run("""
@@ -211,7 +213,7 @@
         b = a + a
         b -> 1 -> 1
         """)
-        assert interp.results[0].value.val == 8
+        assert interp.results[0].value == 8
 
     def test_set_slice(self):
         interp = self.run("""
@@ -220,7 +222,7 @@
         b[:] = a + a
         b -> 3
         """)
-        assert interp.results[0].value.val == 6
+        assert interp.results[0].value == 6
 
     def test_set_slice2(self):
         interp = self.run("""
@@ -231,7 +233,7 @@
         a[0:30:3] = c
         a -> 3
         """)
-        assert interp.results[0].value.val == 11        
+        assert interp.results[0].value == 11        
     def test_dot(self):
         interp = self.run("""
         a = [[1, 2], [3, 4]]
@@ -239,4 +241,4 @@
         c = dot(a, b)
         c -> 0 -> 0
         """)
-        assert interp.results[0].value.val == 19
+        assert interp.results[0].value == 19


More information about the pypy-commit mailing list