[SciPy-dev] Adding to an array with __radd__()

Robert Cimrman cimrman3 at ntc.zcu.cz
Tue Nov 1 03:25:23 EST 2005


Travis Oliphant wrote:
> Ed Schofield wrote:
> 
> I think this is a result of the fact that arrays are now new style 
> numbers and the fact that array(B) created a perfectly nice object array.
> 
> I've committed a change that makes special cases this case so the 
> reflected operands will work if they are defined for something that 
> becomes an object array.

Is it possible, in principle, to call always the sparse matrix operator 
method when it enters an operation with a dense array?
(a .. dense array, b sparse -- a + b calls b.__radd__, b + a calls 
b.__add__)

The reason I would support this is, that IMHO the higher level object (a 
sparse matrix) knows well how to handle the lower level object (a dense 
array) in numeric operations, but not vice-versa -- there is already a 
number of sparse matrix formats, so the dense array object definitely 
cannot understand them all.

r.




More information about the SciPy-Dev mailing list