[pypy-commit] pypy ufuncapi: make untranslated tests pass

mattip noreply at buildbot.pypy.org
Wed Aug 13 00:01:13 CEST 2014


Author: mattip <matti.picus at gmail.com>
Branch: ufuncapi
Changeset: r72771:c12de969c24c
Date: 2014-08-09 22:54 +0300
http://bitbucket.org/pypy/pypy/changeset/c12de969c24c/

Log:	make untranslated tests pass

diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -112,10 +112,11 @@
             assert 'object' in str(e)
             # Use pypy specific extension for out_dtype
             adder_ufunc0 = frompyfunc(adder, 2, 1, dtypes=['match'])
-            adder_ufunc1 = frompyfunc([adder, adder], 2, 1, dtypes=['match'])
-            int_func22 = frompyfunc([int, int], 2, 2, signature='()->()',
+            adder_ufunc1 = frompyfunc([adder, adder], 2, 1, 
+                            dtypes=[int, int, int, float, float, float])
+            int_func22 = frompyfunc([int, int], 2, 2, signature='(i)->(i)',
                                     dtypes=['match'])
-            int_func12 = frompyfunc([int, int], 1, 2, signature='()->()',
+            int_func12 = frompyfunc([int], 1, 2, signature='(i)->(i)',
                                     dtypes=['match'])
             retype = dtype(int)
         assert isinstance(adder_ufunc1, ufunc)
@@ -139,7 +140,7 @@
             out_flat = out_array.flat
             for i in range(in_array.size):
                 out_flat[i] = in_flat[i] * 2
-        def double_times2(space, __args__):
+        def double_times2(in_array, out_array):
             assert in_array.dtype == float
             in_flat = in_array.flat
             out_flat = out_array.flat
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
@@ -562,10 +562,19 @@
         return loop.call_many_to_many(space, new_shape, self.funcs[index],
                                      res_dtype, inargs, outargs)
 
-    def type_resolver(self, space, index, outargs):
-        # Find a match for the inargs.dtype in self.dtypes, like
-        # linear_search_type_resolver in numy ufunc_type_resolutions.c
-        return 0
+    def type_resolver(self, space, inargs, outargs):
+         # Find a match for the inargs.dtype in self.dtypes, like
+         # linear_search_type_resolver in numy ufunc_type_resolutions.c
+        for i in range(0, len(self.dtypes), self.nargs):
+            if inargs[0].get_dtype() == self.dtypes[i]:
+                break
+        else:
+            if len(self.funcs) < 2:
+                return 0
+            raise oefmt(space.w_TypeError,
+                         'input dtype %s did not match any known dtypes',
+                                              str(inargs[0].get_dtype()))
+        return i / self.nargs
 
     def alloc_outargs(self, space, index, inargs, outargs):
         # Any None outarg should be allocated here
@@ -991,9 +1000,7 @@
             else:    
                 dtypes = [None]*len(_dtypes)
                 for i in range(len(dtypes)):
-                    print 'decoding',_dtypes[i]
                     dtypes[i] = descriptor.decode_w_dtype(space, _dtypes[i])
-                    print 'got',dtypes[i]
     else:
         raise oefmt(space.w_ValueError,
             'dtypes must be None or a list of dtypes')


More information about the pypy-commit mailing list