[SciPy-User] problems with numpy array assignment

Gabriele Brambilla gb.gabrielebrambilla at gmail.com
Tue Mar 4 16:37:35 EST 2014


Yes, thank you. I read the last 4 emails all together so you have not
confused me.
I understand that I should pay attention to this aspect: I was used to pass
all the things by value...

Thanks

Gabriele

2014-03-04 16:01 GMT-05:00 Jonathan T. Niehof <jniehof at lanl.gov>:

> There is a difference in that Python list slicing usually *does* return
> copies, vs. views for numpy arrays:
>  >>> a = [1,2,3]
>  >>> b = a[1:]
>  >>> b[0] = 99
>  >>> a
> [1, 2, 3]
>
> but:
>  >>> a = numpy.array([1, 2, 3])
>  >>> b = a[1:]
>  >>> b[0] = 99
>  >>> a
> array([ 1, 99,  3])
>
> Gabriele, I hope we're being illuminating here rather than more
> obscure...these can be irritating points.
>
> --
> Jonathan Niehof
> ISR-3 Space Data Systems
> Los Alamos National Laboratory
> MS-D466
> Los Alamos, NM 87545
>
> Phone: 505-667-9595
> email: jniehof at lanl.gov
>
> Correspondence /
> Technical data or Software Publicly Available
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20140304/e6c23d12/attachment.html>


More information about the SciPy-User mailing list