Commits

Maciej Fijalkowski committed 5e43d79 Merge

mere

  • Participants
  • Parent commits f6b8525, ee1b4ea

Comments (0)

Files changed (6)

File pypy/module/micronumpy/interp_iter.py

                 offset += self.strides[i]
                 break
             else:
+                if i == self.dim:
+                    first_line = True
                 indices[i] = 0
                 offset -= self.backstrides[i]
         else:

File pypy/module/micronumpy/interp_numarray.py

     descr_rmod = _binop_right_impl("mod")
 
     def _reduce_ufunc_impl(ufunc_name, promote_to_largest=False):
-        def impl(self, space, w_dim=None):
-            if space.is_w(w_dim, space.w_None):
-                w_dim = space.wrap(-1)
+        def impl(self, space, w_axis=None):
+            if space.is_w(w_axis, space.w_None):
+                w_axis = space.wrap(-1)
             return getattr(interp_ufuncs.get(space), ufunc_name).reduce(space,
-                                        self, True, promote_to_largest, w_dim)
+                                        self, True, promote_to_largest, w_axis)
         return func_with_new_name(impl, "reduce_%s_impl" % ufunc_name)
 
     descr_sum = _reduce_ufunc_impl("add")
             )
         return w_result
 
-    def descr_mean(self, space, w_dim=None):
-        if space.is_w(w_dim, space.w_None):
-            w_dim = space.wrap(-1)
+    def descr_mean(self, space, w_axis=None):
+        if space.is_w(w_axis, space.w_None):
+            w_axis = space.wrap(-1)
             w_denom = space.wrap(self.size)
         else:
-            dim = space.int_w(w_dim)
+            dim = space.int_w(w_axis)
             w_denom = space.wrap(self.shape[dim])
-        return space.div(self.descr_sum_promote(space, w_dim), w_denom)
+        return space.div(self.descr_sum_promote(space, w_axis), w_denom)
 
     def descr_var(self, space):
         # var = mean((values - mean(values)) ** 2)

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

         a = array(range(105)).reshape(3, 5, 7)
         b = mean(a, axis=0)
         b[0,0]==35.
+        assert a.mean(axis=0)[0, 0] == 35
         assert (b == array(range(35, 70), dtype=float).reshape(5, 7)).all()
         assert (mean(a, 2) == array(range(0, 15), dtype=float).reshape(3, 5) * 7 + 3).all()
 
         assert array([]).sum() == 0.0
         raises(ValueError, 'array([]).max()')
         assert (a.sum(0) == [30, 35, 40]).all()
+        assert (a.sum(axis=0) == [30, 35, 40]).all()
         assert (a.sum(1) == [3, 12, 21, 30, 39]).all()
         assert (a.max(0) == [12, 13, 14]).all()
         assert (a.max(1) == [2, 5, 8, 11, 14]).all()
         assert ((a + a).T.sum(2).T == (a + a).sum(0)).all()
         assert (a.reshape(1,-1).sum(0) == range(105)).all()
         assert (a.reshape(1,-1).sum(1) == 5460)
+        assert (array([[1,2],[3,4]]).prod(0) == [3, 8]).all()
+        assert (array([[1,2],[3,4]]).prod(1) == [2, 12]).all()
 
     def test_identity(self):
         from _numpypy import identity, array

File pypy/module/pypyjit/policy.py

                        'imp', 'sys', 'array', '_ffi', 'itertools', 'operator',
                        'posix', '_socket', '_sre', '_lsprof', '_weakref',
                        '__pypy__', 'cStringIO', '_collections', 'struct',
-                       'mmap', 'marshal']:
+                       'mmap', 'marshal', '_codecs']:
             if modname == 'pypyjit' and 'interp_resop' in rest:
                 return False
             return True

File pypy/rpython/lltypesystem/rclass.py

         ctype = inputconst(Void, self.object_type)
         cflags = inputconst(Void, flags)
         vlist = [ctype, cflags]
-        vptr = llops.genop('malloc', vlist,
+        cnonmovable = self.classdef.classdesc.read_attribute(
+            '_alloc_nonmovable_', Constant(False))
+        if cnonmovable.value:
+            opname = 'malloc_nonmovable'
+        else:
+            opname = 'malloc'
+        vptr = llops.genop(opname, vlist,
                            resulttype = Ptr(self.object_type))
         ctypeptr = inputconst(CLASSTYPE, self.rclass.getvtable())
         self.setfield(vptr, '__class__', ctypeptr, llops)

File pypy/rpython/test/test_rclass.py

             assert sorted([u]) == [6]                    # 32-bit types
             assert sorted([i, r, d, l]) == [2, 3, 4, 5]  # 64-bit types
 
+    def test_nonmovable(self):
+        for (nonmovable, opname) in [(True, 'malloc_nonmovable'),
+                                     (False, 'malloc')]:
+            class A(object):
+                _alloc_nonmovable_ = nonmovable
+            def f():
+                return A()
+            t, typer, graph = self.gengraph(f, [])
+            assert summary(graph) == {opname: 1,
+                                      'cast_pointer': 1,
+                                      'setfield': 1}
+
 
 class TestOOtype(BaseTestRclass, OORtypeMixin):