[Numpy-discussion] shape, size

Daniel Holth dholth at fastmail.fm
Fri Jan 30 13:23:06 CST 2004


In python, if na is a numarray:

>>> na
array([[0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
       [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]])

I can type

>>> nb = na[:,:4]
>>> nb
array([[0, 1, 0, 1],
       [1, 0, 1, 0]])

>>> nb[0][0]=17

>>> na
array([[17,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0],
       [ 1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1,  0,  1]])

nb and na share data.

How do you write nb = na[:,:4] in a C extension module?

Thanks,

Daniel Holth





More information about the Numpy-discussion mailing list