[Numpy-discussion] np.array execution path
Sebastian Berg
sebastian@sipsolutions....
Sat Sep 22 16:24:13 CDT 2012
In case you are interested, the second (real odditiy), is caused by
ISFORTRAN and IS_F_CONTIGUOUS mixup, I have found three occurances where
I think ISFORTRAN should be replaced by the latter. Check also:
https://github.com/seberg/numpy/commit/4d2713ce8f2107d225fe291f5da6c6a75436647e
Sebastian
On Sat, 2012-09-22 at 13:12 -0500, Travis Oliphant wrote:
> Check to see if this expression is true
>
> no is o
>
> In the first case no and o are the same object
>
>
> Travis
>
> --
> Travis Oliphant
> (on a mobile)
> 512-826-7480
>
>
> On Sep 22, 2012, at 1:01 PM, Sebastian Berg <sebastian@sipsolutions.net> wrote:
>
> > Hi,
> >
> > I have a bit of trouble figuring this out. I would have expected
> > np.asarray(array) to go through ctors, PyArray_NewFromArray, but it
> > seems to me it does not, so which execution path is exactly taken here?
> > The reason I am asking is that I want to figure out this behavior/bug,
> > and I really am not sure which function is responsible:
> >
> > In [69]: o = np.ones(3)
> >
> > In [70]: no = np.asarray(o, order='C')
> >
> > In [71]: no[:] = 10
> >
> > In [72]: o # OK, o was changed in place:
> > Out[72]: array([ 10., 10., 10.])
> >
> > In [73]: no.flags # But no claims to own its data!
> > Out[73]:
> > C_CONTIGUOUS : True
> > F_CONTIGUOUS : True
> > OWNDATA : True
> > WRITEABLE : True
> > ALIGNED : True
> > UPDATEIFCOPY : False
> >
> > In [74]: no = np.asarray(o, order='F')
> >
> > In [75]: no[:] = 11
> >
> > In [76]: o # Here asarray actually returned a real copy!
> > Out[76]: array([ 10., 10., 10.])
> >
> >
> > Thanks,
> >
> > Sebastian
> >
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list