A discussion [1] is currently underway at GitHub which will benefit from a
larger forum.

In version 1.9, the diagonal() method was changed to return a read-only
(non-contiguous) view into the original array instead of a plain copy.
Also, it has been announced [2] that in 1.10 the view will become
read/write.

A concern has now been raised [3] that this change breaks backward
compatibility too much.

Consider the following code:

x = numy.eye(2)
d = x.diagonal()
d[0] = 2

In 1.8, this code runs without errors and results in [2, 1] stored in array
d.  In 1.9, this is an error.  With the current plan, in 1.10 this will
become valid again, but the result will be different: x[0,0] will be 2
while it is 1 in 1.8.

Two alternatives  are suggested for discussion:

1. Add copy=True flag to diagonal() method.
2. Roll back 1.9 change to diagonal() and introduce an additional
diagonal_view() method to return a view.



[1] https://github.com/numpy/numpy/pull/5409
[2] http://docs.scipy.org/doc/numpy/reference/generated/numpy.diagonal.html
[3] http://khinsen.wordpress.com/2014/09/12/the-state-of-numpy/
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to