I noticed today that the documentation for np.transpose states, for the return value, that "A view is returned whenever possible."
Is there really any situation where swapping axes around could trigger the need to copy data, or will a view always be returned no matter what? I can't think of any such situation, and was planning on relying on that for some code: basically, I have an output array, which I would like to be contiguous. So I preallocate it with the right shape, then take a view of it moving a certain axis to the end to make computations easier, run all my computations on the modified view, then return the original array, not the view. If I started with an array with the axis at the end, and then transposed it, I would need to make a copy to make it contiguous, which is what I am trying to avoid. Is this a bad practice? Is that precaution in the documentation real? Should I check that my view's base is the original array and trigger a copy, or is it an unnecessary check? Thanks in advance, Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
