[SciPy-dev] Fancy indexing curiosity

Pearu Peterson pearu at scipy.org
Mon Jan 9 03:27:51 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)
> In [11]: import numpy
> In [12]: a1=numpy.array([])
> In [13]: a2=numpy.array([])
> In [14]: numpy.dot(a1,a2)
> Out[14]: 6917529027645027104
> In [15]: import numpy
> In [16]: a1=numpy.array([], dtype=numpy.int8)
> In [17]: a2=numpy.array([], dtype=numpy.int8)
> In [18]: numpy.dot(a1,a2)
> Out[18]: 0
> In [19]: numpy.dot(a1,a2)
> Out[19]: 48
> In [20]: numpy.dot(a1,a2)
> Out[20]: 0
> In [21]: numpy.dot(a1,a2)
> Out[21]: 32
>
> I have no idea, what dot(a1,a2) should return in this
> case, but the dot of empty slices happens in `scipy.linalg.signm`
> and is revealed by
>  FAIL: check_nils (scipy.linalg.matfuncs.test_matfuncs.test_signm)
> for full scipy.
>
> This is on an Itanium2, gcc 3.4.4, numpy, no linear algebra packages
> selected, numpy.__version__ '0.9.3.1857'
>
> I also see this on an Opteron - it could be a 64 Bit issue?

Here numpy.dot returns 0 on empty arrays. I think it should raise an 
exception (ValueError?) instead like ddot in scipy.linalg.blas.fblas does.

Pearu




More information about the Scipy-dev mailing list