[Scipy-svn] r6755 - trunk/scipy/interpolate

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Sep 11 20:59:16 EDT 2010


Author: ptvirtan
Date: 2010-09-11 19:59:16 -0500 (Sat, 11 Sep 2010)
New Revision: 6755

Modified:
   trunk/scipy/interpolate/rbf.py
Log:
3K: interpolate: make Rbf._init_function introspection Py3 compatible

Modified: trunk/scipy/interpolate/rbf.py
===================================================================
--- trunk/scipy/interpolate/rbf.py	2010-09-12 00:59:03 UTC (rev 6754)
+++ trunk/scipy/interpolate/rbf.py	2010-09-12 00:59:16 UTC (rev 6755)
@@ -141,9 +141,9 @@
                    ", ".join(functionlist)               
            self._function = getattr(self, "_h_"+self.function)
         elif callable(self.function):
-            import new
             allow_one = False
-            if hasattr(self.function, 'func_code'):
+            if hasattr(self.function, 'func_code') or \
+                   hasattr(self.function, '__code__'):
                 val = self.function
                 allow_one = True
             elif hasattr(self.function, "im_func"):
@@ -157,7 +157,12 @@
             if allow_one and argcount == 1:
                 self._function = self.function
             elif argcount == 2:
-                self._function = new.instancemethod(self.function, self, Rbf)
+                if sys.version_info[0] >= 3:
+                    self._function = function.__get__(self, Rbf)
+                else:
+                    import new
+                    self._function = new.instancemethod(self.function, self,
+                                                        Rbf)
             else:
                 raise ValueError, "Function argument must take 1 or 2 arguments."
                 




More information about the Scipy-svn mailing list