[SciPy-dev] Fancy indexing curiosity
Arnd Baecker
arnd.baecker at web.de
Mon Jan 9 04:11:38 CST 2006
On Sun, 8 Jan 2006, Travis Oliphant wrote:
> Travis Oliphant wrote:
>
> >Sasha wrote:
> >
> >>>>>x = array([1])
> >>>>>m = array([1], bool)
> >>>>>x[m] = ''
> >>>>>x
> >>>>>
> >>array([12998744])
> >>>>>x[m] = ''
> >>>>>x
> >>array([12998752])
> >>
> >>It looks like x gets the address of the '' object (note the number change).
> >>This "feature" is present in 0.9.2 release and in svn 0.9.3.1831
> >
> >Thanks for this corner case. Actually, it's getting whatever is in the
> >memory allocated.
> >
> >Try
> >
> >b = array('',x.dtype)
> >
> >b should be a size-0 array, (there is actually 1 elementsize of memory
> >allocated for it though).
> >
> >The mapping code is iterating over b and resetting b whenever it runs
> >out of elements of b (every time in this case), except the data pointed
> >to by the iterator is never valid so this should not be allowed....
> >
> >I suppose instead, creating an iterator from a size-0 array could raise
> >an error. This would be a great and simple place to catch this in the
> >code as well.
> >
> This now raises an error....
Is the above related to the following?
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?
Best, Arnd
> -Travis
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev
>
More information about the Scipy-dev
mailing list