[NumPy-Tickets] [NumPy] #1885: einsum wrong result / crash
NumPy Trac
numpy-tickets@scipy....
Tue Jun 28 18:02:20 CDT 2011
#1885: einsum wrong result / crash
--------------------------+-------------------------------------------------
Reporter: royf | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 1.6.1
Component: numpy.core | Version: 1.6.0
Keywords: einsum,wrong |
--------------------------+-------------------------------------------------
numpy.einsum sometimes returns wrong results.
Consider the following example:
>>> p = numpy.array([.5, .5])
>>> q = numpy.array([[0.26894142, 1-0.26894142], [1-0.26894142,
0.26894142]])
>>> r = numpy.identity(2)
...
>>> p, q, r
(array([ 0.5, 0.5]), array([[ 0.26894142, 0.73105858],
[ 0.73105858, 0.26894142]]), array([[ 1., 0.],
[ 0., 1.]]))
>>> numpy.einsum('z,mz,zm->', p, q, r)
3.7305612660634556e+177
>>> numpy.einsum('z,mz,zm->', p, q, r)
0.26894141999999999
>>> numpy.einsum('z,mz,zm->', p, q, r)
3.7305612660634556e+177
>>> numpy.einsum('z,mz,zm->', p, q, r)
0.26894141999999999
>>> numpy.einsum('z,mz,zm->', p, q, r)
3.7305612660634556e+177
>>> numpy.einsum('z,mz,zm->', p, q, r)
0.26894141999999999
>>> numpy.einsum('z,mz,zm->', p, q, r)
0.26894141999999999
>>> numpy.einsum('z,mz,zm->', p, q, r)
0.13447070999999999
In other runs this same example crashes the process.
The correct answer is 0.26894142.
Interestingly, one of the answers returned is half the correct one.
This probably has to do with the specific value of p in the example.
My guess is it's something like an off-by-one bug.
I'd try to fix it myself,
but the code is a scary mess :(
Good luck!
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1885>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list