[SciPy-dev] Suppressing of numpy __mul__, __div__ etc

Dmitrey tmp50 at ukr.net
Thu Dec 17 10:37:21 EST 2009


От кого: Sebastian Walter <sebastian.walter at gmail.com>  
  could you elaborate on why someone would  
want to do an `array * polynomial` operation and not expect it to  
be an array of polynomial as result?    
this has been already mentioned in the thread  
http://permalink.gmane.org/gmane.comp.python.scientific.devel/12445  
In [1]: from numpy.polynomial import Polynomial as poly  
  
In [2]: p = poly([0,1])  
  
In [3]: ones(2) * p  
Out[3]: array([poly([ 0.  1.], [-1.  1.]), poly([ 0.  1.], [-1.  1.])], dtype=object)  
  
In [4]: p * ones(2)  
Out[4]: Polynomial([ 0.,  1.,  1.], [-1.,  1.])  
  
  you would simply add  
  
class oofun:  
iscontainer = True  
  
to your oofun implementation and you would get exactly what you want....I guess "iscontainer" is a bad choice for the field, but if numpy developers decide to use this one, let it be, it doesn't matter for me sufficiently.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20091217/221d97e9/attachment.html>


More information about the SciPy-Dev mailing list