title: Use of __numpy_ufunc__()
body: <p>I'm trying to use the <code>__numpy_ufunc__()</code> method explained <a href="https://docs.scipy.org/doc/numpy-dev/reference/arrays.classes.html#numpy.class.__numpy_ufunc__" rel="nofollow noreferrer">here in the Numpy v1.11 docs</a>, to override the behavior of numpy ufuncs on a subclass of <code>ndarray</code>, but it never seems to get called.  Despite this use case being listed in the guide, I can't find any examples of anyone actually using <code>__numpy_ufunc__()</code>.  Has anyone tried this?  Here's a minimal example:</p>
  
  <pre><code># Check python version
  import sys
  print(sys.version)
  </code></pre>
  
  <p>3.5.1 |Continuum Analytics, Inc.| (default, Jun 15 2016, 15:32:45) </p>
  
  <p>[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)</p>
  
  <pre><code># Check numpy version
  import numpy as np
  print(np.__version__)
  </code></pre>
  
  <p>1.11.2</p>
  
  <pre><code># Subclass ndarray as discussed in 
  # https://docs.scipy.org/doc/numpy/user/basics.subclassing.html
  class Function(np.ndarray):
  
      # Create subclass object by view
      def __new__(cls):
          obj = np.asarray([1,2,3]).view(cls)
          return obj
  
      # I'm not even adding anything functionality yet
      def __array_finalize(self,obj): pass
  
      # Override ufuncs
      def __numpy_ufunc__(ufunc, method, i, inputs, **kwargs):
          print("In PF __numpy_ufunc__")
          # do other stuff here if I want to 
          # and probably need to return a value...
  
  # Create two Functions
  f1=Function()
  f2=Function()
  
  # Check that they are correctly initialized as Function objects
  # not just ndarrays
  print(type(f1),type(f2))
  </code></pre>
  
  <p>&langle;class '<strong>main</strong>.Function'&rangle; &langle;class '<strong>main</strong>.Function'&rangle;</p>
  
  <pre><code># Add using operator
  f1+f2
  </code></pre>
  
  <p>Function([2, 4, 6])</p>
  
  <pre><code># Add, explicitly demanding a numpy ufunc
  np.add(f1,f2)
  </code></pre>
  
  <p>Function([2, 4, 6])</p>
  
  <p>Clearly, the subclassing works, and it's using numpy to add arrays behind the scenes.  I'm using a new enough version of numpy to employ the <code>__numpy_ufunc__()</code> feature (according to that docs page, it's new in v1.11). But this code never prints out <code>"In PF __numpy_ufunc__"</code>.  What gives?</p>