title: Can I create a Python Numpy ufunc from an unbound member method?
body: <p>I would like to use numpy.frompyfunc to generate an unbound ufunc from an unbound member method.  My concrete but failing attempts look like</p>
  
  <pre><code>class Foo(object):
      def f(x,y,z):
          return x + y + z
  
  Foo.g = numpy.frompyfunc(Foo.f,3,1)
  i = Foo()
  i.g(5,6,7)
  </code></pre>
  
  <p>where the last line fails with
  "TypeError: unbound method f() must be called with Foo instance as first argument (got int instance instead)". That error makes sense to me as Foo.f is unbound.</p>
  
  <p>Despite it being deprecated, I thought I'd give new.instancemethod a shot:</p>
  
  <pre><code>import new
  Foo.h = new.instancemethod(numpy.frompyfunc(Foo.f,3,1),None,Foo)
  j = Foo()
  j.h(5,6,7)
  </code></pre>
  
  <p>where the last line now fails with "TypeError: return arrays must be of ArrayType" which I don't understand.</p>
  
  <p>My goal is to monkey patch Foo with ufunc-ready versions of its members.  They must be member methods as they depend on a Foo instance's state (though that dependency is not shown here).</p>
  
  <p>Any suggestions?</p>