[Numpy-discussion] numpy.array(arr.flat) mutates arr if arr.flags.fortran: bug?
Zachary Pincus
zachary.pincus@yale....
Sat Mar 27 08:11:46 CDT 2010
> You should open a ticket for this.
http://projects.scipy.org/numpy/ticket/1439
On Mar 26, 2010, at 11:26 AM, Charles R Harris wrote:
>
>
> On Wed, Mar 24, 2010 at 1:13 PM, Zachary Pincus <zachary.pincus@yale.edu
> > wrote:
> Hello,
>
> I assume it is a bug that calling numpy.array() on a flatiter of a
> fortran-strided array that owns its own data causes that array to be
> rearranged somehow?
>
> Not sure what happens with a fancier-strided array that also owns its
> own data (because I'm not sure how to create one of those in python).
>
> This is from the latest svn version (2.0.0.dev8302) but was also
> present in a previous version too.
>
> Zach
>
>
> In [9]: a = numpy.array([[1,2],[3,4]]).copy('F')
>
> In [10]: a
> Out[10]:
> array([[1, 2],
> [3, 4]])
>
> In [11]: list(a.flat)
> Out[11]: [1, 2, 3, 4]
>
> In [12]: a # no problem
> Out[12]:
> array([[1, 2],
> [3, 4]])
>
> In [13]: numpy.array(a.flat)
> Out[13]: array([1, 2, 3, 4])
>
> In [14]: a # this ain't right!
> Out[14]:
> array([[1, 3],
> [2, 4]])
>
> In [15]: a = numpy.array([[1,2],[3,4]]).copy('C')
>
> In [16]: numpy.array(a.flat)
> Out[16]: array([1, 2, 3, 4])
>
> In [17]: a
> Out[17]:
> array([[1, 2],
> [3, 4]])
>
>
> You should open a ticket for this.
>
> Chuck
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list