[SciPy-dev] Suppressing of numpy __mul__, __div__ etc
Thu Dec 17 15:27:27 CST 2009
I develop another symbolic-over-numpy package called theano, and
somehow we avoid this problem.
In : import theano
In : import numpy
In : numpy.ones(4) * theano.tensor.dmatrix()
In : theano.tensor.dmatrix() * theano.tensor.dmatrix()
In : theano.tensor.dmatrix() * numpy.ones(4)
The dmatrix() function returns an instance of the TensorVariable class
defined in this file:
I think the only thing we added for numpy was __array_priority__ =
1000, which has already been suggested here. I'm confused by why this
thread goes on.
2009/12/17 Dmitrey <firstname.lastname@example.org>:
> От кого: Sebastian Walter <email@example.com>
> 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.
> Since I'm not a numpy developer, I cannot give you irrefutable answer, but I
> guess it is much more useful for numpy users that are mostly engineering
> programmers, not researchers of a data type with a ring structure.
> Also, this is not only up to polynomials - as it has been mentioned, this
> issue is important for stacking with SAGE data types, oofuns etc, where
> users certainly want to get same type instead of an ndarray.
> SciPy-Dev mailing list
More information about the SciPy-Dev