[SciPy-dev] Fancy indexing curiosity

Alan G Isaac aisaac at american.edu
Mon Jan 9 07:55:09 CST 2006


> On Mon, 9 Jan 2006, Arnd Baecker wrote: 
>> In [7]: import numpy 
>> In [8]: a1=numpy.array([], dtype=numpy.complex128) 
>> In [9]: a2=numpy.array([], dtype=numpy.complex128) 
>> In [10]: numpy.dot(a1,a2) 
>> Out[10]: (2.6815615888703731e+154+2.6815615859888243e+154j) 

On Mon, 9 Jan 2006, (CST) Pearu Peterson apparently wrote: 
> I have commited a patch to numpy svn so that 
>    numpy.core.multiarray.dot([],[]) -> 0 
> Note that currently 
>     numpy.core.multiarray.dot([],2) -> [] 
> for instance. Is this desired behaviour? 


Is there is a hurry to fix this situation without a clear 
statement of the underlying principle?  Maybe I just 
overlook the principle? 

This seems right: 
numpy.core.multiarray.dot([],2) -> [] 
It is a natural corner case for a scalar product, which 
'dot' already supports.  The principle is that scalar 
multiplication returns the array of the same dimensions 
containing scalar multiple of each element of the original array. 

This seems quite wrong: 
numpy.core.multiarray.dot([],[]) -> 0 
I expect an exception. 
Otherwise two empty arrays are judged orthogonal, 
which seems extremely odd. 
(Not as odd as the previous behavior, of course.) 
If returning 0 is the right thing to do, 
what is the reason for this being right? 

fwiw,
Alan Isaaac




More information about the Scipy-dev mailing list