[Numpy-discussion] Need **working** code example of 2-D arrays

Pierre GM pgmdevlist@gmail....
Mon Oct 13 00:48:38 CDT 2008


Linda,
If you're familiar with Matlab syntax, you may find this link interesting:
http://www.scipy.org/NumPy_for_Matlab_Users

Here another couple of useful links
http://www.scipy.org/Tentative_NumPy_Tutorial
http://www.scipy.org/Numpy_Functions_by_Category

For your specific example, if you want to create a (256,128) array of unsigned 
integers:

import numpy as np
a = np.zeros((256,128), dtype=np.uint32)

Note that if you intend to fill the array afterwards with other values, it 
might be more efficient to create an 'empty' array instead of an array full 
of zeros:

b=np.empty((256,128), dtype=uint32)



More information about the Numpy-discussion mailing list