Author: mattip <matti.pi...@gmail.com>
Branch: ufunc-casting
Changeset: r80176:23e41a855538
Date: 2015-10-13 21:35 +0300
http://bitbucket.org/pypy/pypy/changeset/23e41a855538/

Log:    cleanup, fix translation

diff --git a/pypy/module/micronumpy/loop.py b/pypy/module/micronumpy/loop.py
--- a/pypy/module/micronumpy/loop.py
+++ b/pypy/module/micronumpy/loop.py
@@ -139,10 +139,10 @@
         test_iter, test_state = out_iters[0], out_states[0]
     while not test_iter.done(test_state):
         call_many_to_many_driver.jit_merge_point(shapelen=shapelen, func=func,
-                             in_dtypes=in_dtypes, out_dtypes=out_dtypes, 
nin=nin, nout=nout)
+                             in_dtypes=in_dtypes, out_dtypes=out_dtypes,
+                             nin=nin, nout=nout)
         for i in range(nin):
             vals[i] = in_dtypes[i].coerce(space, 
in_iters[i].getitem(in_states[i]))
-        print 'vals', vals
         w_arglist = space.newlist(vals)
         w_outvals = space.call_args(func, Arguments.frompacked(space, 
w_arglist))
         # w_outvals should be a tuple, but func can return a single value as 
well
@@ -156,7 +156,7 @@
             out_states[0] = out_iters[0].next(out_states[0])
         for i in range(nin):
             in_states[i] = in_iters[i].next(in_states[i])
-        test_iter.next(test_state)
+        test_state = test_iter.next(test_state)
     return space.newtuple([convert_to_array(space, o) for o in out_args])
 
 setslice_driver = jit.JitDriver(name='numpy_setslice',
diff --git a/pypy/module/micronumpy/ufuncs.py b/pypy/module/micronumpy/ufuncs.py
--- a/pypy/module/micronumpy/ufuncs.py
+++ b/pypy/module/micronumpy/ufuncs.py
@@ -820,12 +820,13 @@
         iter_shape, arg_shapes, matched_dims = self.verify_args(space, inargs, 
outargs)
         inargs, outargs, need_to_cast = self.alloc_args(space, inargs, 
outargs, dtypes,
                                           arg_shapes)
-        print 'call', self.external_loop, need_to_cast, dtypes, [a.get_dtype() 
for a in inargs], [a.get_dtype() for a in outargs]
         if not self.external_loop:
             inargs0 = inargs[0]
             outargs0 = outargs[0]
             assert isinstance(inargs0, W_NDimArray)
             assert isinstance(outargs0, W_NDimArray)
+            nin = self.nin
+            assert nin >= 0
             res_dtype = outargs0.get_dtype()
             new_shape = inargs0.get_shape()
             # XXX use _find_array_wrap and wrap outargs using __array_wrap__
@@ -834,12 +835,12 @@
                                          dtypes, [], inargs + outargs, [])
                 if len(outargs) < 2:
                     return outargs[0]
-                return outargs
+                return space.newtuple(outargs)
             if len(outargs) < 2:
                 return loop.call_many_to_one(space, new_shape, func,
-                         dtypes[:self.nin], dtypes[-1], inargs, outargs[0])
+                         dtypes[:nin], dtypes[-1], inargs, outargs[0])
             return loop.call_many_to_many(space, new_shape, func,
-                         dtypes[:self.nin], dtypes[self.nin:], inargs, outargs)
+                         dtypes[:nin], dtypes[nin:], inargs, outargs)
         w_casting = space.w_None
         w_op_dtypes = space.w_None
         for tf in need_to_cast:
@@ -1014,7 +1015,10 @@
             for i in range(0, len(_dtypes), self.nargs):
                 allok = _match_dtypes(space, dtypes, _dtypes, i, "safe")
                 if allok:
-                    dtypes = _dtypes[i:i+self.nargs]
+                    end = i + self.nargs
+                    assert i >= 0
+                    assert end >=0
+                    dtypes = _dtypes[i:end]
                     break
             else:
                 if len(self.funcs) > 1:
@@ -1152,7 +1156,7 @@
         # the current op (signalling it can handle ndarray's).
 
         # TODO parse and handle subok
-        # TODO handle flags, op_flags
+        # TODO handle more flags, op_flags
         #print 
'iter_shape',iter_shape,'arg_shapes',arg_shapes,'matched_dims',matched_dims
         return iter_shape, arg_shapes, matched_dims
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to