[NumPy-Tickets] [NumPy] #1982: In-place arithmetic operations: wrong calculation order?
NumPy Trac
numpy-tickets@scipy....
Fri Nov 18 12:23:38 CST 2011
#1982: In-place arithmetic operations: wrong calculation order?
------------------------+---------------------------------------------------
Reporter: ling | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.0
Keywords: |
------------------------+---------------------------------------------------
In-place operation like "subtract(b[:-1], b[1:], b[:-1])" used to work
fine in Numpy 1.4.1, but sometimes fails with Numpy 1.6.0. See the
example below (the problematic output is Out[6]):
{{{
In [1]: import numpy; numpy.__version__
Out[1]: '1.6.0'
In [2]: a = numpy.arange(12).reshape((3, 4))
In [3]: b = a[::-1].copy(); numpy.subtract(b[:-1], b[1:])
Out[3]:
array([[4, 4, 4, 4],
[4, 4, 4, 4]])
In [4]: numpy.subtract(b[:-1], b[1:], b[:-1])
Out[4]:
array([[4, 4, 4, 4],
[4, 4, 4, 4]])
In [5]: b = a[::-1]; numpy.subtract(b[:-1], b[1:])
Out[5]:
array([[4, 4, 4, 4],
[4, 4, 4, 4]])
In [6]: numpy.subtract(b[:-1], b[1:], b[:-1])
Out[6]:
array([[4, 5, 6, 7],
[4, 4, 4, 4]])
}}}
Similar problem happens to other in-place operations (e.g., multiply,
divide).
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1982>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list