[Numpy-discussion] how to assign to a "sub set" of an array
Timothy Hochberg
tim.hochberg at ieee.org
Wed Nov 14 11:59:00 EST 2007
On Nov 14, 2007 9:08 AM, Sebastian Haase <haase at msg.ucsf.edu> wrote:
> Hi,
> First here is some test I ran, where I think the last command shows a bug:
>
> >>> a = N.arange(4); a.shape=2,2; a
> [[0 1]
> [2 3]]
> >>> aa = N.array((a,a,a)); aa
> [[[0 1]
> [2 3]]
>
> [[0 1]
> [2 3]]
>
> [[0 1]
> [2 3]]]
> >>> N.nonzero(a==0)
> ([0], [0])
> >>> aa[N.nonzero(a==0)] = 5,5; aa
> [[[ 5 544434034]
> [ 2 3]]
>
> [[ 0 1]
> [ 2 3]]
>
> [[ 0 1]
> [ 2 3]]]
>
>
> What happend here ? The value 544434034 is different every time.....
I'm not seeing that here on WinXP with numpy 1.0.4.dev3462 ; can you tell me
what platform and version you are using?
>
> Background:
> I have a gray-scale 2D image (in this examples it's a 2x2 pixel image
> named 'a')
> I would like to show this image using grey-values EXCEPT I would like
> to show 0-values as blue.
> For use with pyOpenGL textures, I convert the image into an RGB image,
> in the example called 'aa', with shape 3,2,2.
>
> This is where I'm getting lost, and I tried assigning "something"
> (5,5) to aa "only at certain pixels"....
> Maybe someone can teach what the proper indexing-constuct, that I
> would need to do what I want.
>
> Did I find a bug ?
It looks like a bug, although it's possible it's been fixed. Or maybe it's a
new one and I need to update my version of numpy to see it...
>
>
> Thanks,
> Sebastian Haase
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
--
. __
. |-\
.
. tim.hochberg at ieee.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20071114/c317b609/attachment.html>
More information about the NumPy-Discussion
mailing list