Numpy: views vs copy by slicing
The accepted answer by John Zwinck is actually false (I just figured this out the hard way!). The problem in the question is a combination of doing “l-value indexing” with numpy’s fancy indexing. The following doc explains exactly this case https://scipy-cookbook.readthedocs.io/items/ViewsVsCopies.html in the section “But fancy indexing does seem to return views sometimes, doesn’t it?” … Read more