[Numpy-discussion] buggy fortran array reshape ?

Pauli Virtanen pav@iki...
Wed Apr 22 13:37:47 CDT 2009


Wed, 22 Apr 2009 20:18:14 +0200, Fabrice Pardo wrote:
[clip]
> The reshape function is unpredictable and its behaviour is not
> documented.
> 
> It cannot be used safely.

It is documented and it can be used safely. The manual, however, has 
currently no section on views that would explain these issues in depth.

If you want to ensure no-copy, assign to shape:

a.shape = (6,)

> Another remark against reshape:
> OWNDATA flag is False, even if b is a copy !

Apparently, reshape first copies to a contiguous array and then reshapes. 
This could be simplified.

-- 
Pauli Virtanen



More information about the Numpy-discussion mailing list