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

Sebastian Walter sebastian.walter at gmail.com
Thu Dec 17 11:13:26 EST 2009


2009/12/17 Dmitrey <tmp50 at ukr.net>:
> От кого: 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.])

let me rephrase then. I don't understand why p * ones(2) should give
Polynomial([ 0.,  1.,  1.], [-1.,  1.]).
A polynomial over the reals is a data type with a ring structure and
should therefore behave "similarly" to floats IMHO.

>
> 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.

I'm just making suggestions ;). I'm as much numpy dev as you are...
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
>



More information about the SciPy-Dev mailing list