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 <[email protected]> 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 > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
