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

Nathan Bell wnbell@gmail....
Sun Dec 13 16:19:55 CST 2009


On Sat, Dec 12, 2009 at 4:16 PM, Robert Kern <robert.kern@gmail.com> wrote:
>
> I think what he is asking for is an empty mixin class which other
> folks could subclass to mark their classes. It would say "Hey,
> ndarray! Let my __mul__, __rmul__, etc., take priority over yours,
> regardless of which of us comes first in the expression." Otherwise,
> ndarray will gladly consume pretty much any object on the other side
> of the operator because it will treat it as an object scalar.
>
> We could also define a standard attribute that could mark such classes
> instead of requiring a mixin subclass.
>

We could use this functionality in scipy.sparse too.  In particular,
it would be nice if asarray(some_sparse_matrix) just worked so we
could toss (presumably small) sparse matrices into functions expecting
ndarrays.

Like Dmitrey, we need to invoke sparse.__rmul__(dense) when
encountering dense * sparse.

-- 
Nathan Bell wnbell@gmail.com
http://www.wnbell.com/


More information about the SciPy-Dev mailing list