The numarray module provides, in addition to the functions which are needed to create the objects above, a set of powerful functions to manipulate arrays, select subsets of arrays based on the contents of other arrays, and other array-processing operations.
>>> data = arange(10) # analogous to builtin range() >>> print data [0 1 2 3 4 5 6 7 8 9] >>> print where(greater(data, 5), -1, data) [ 0 1 2 3 4 5 -1 -1 -1 -1] # selection facility >>> data = resize(array([0,1]), (9, 9)) # or just: data=resize([0,1], (9,9)) >>> print data [[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 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 0 1 0] [1 0 1 0 1 0 1 0 1] [0 1 0 1 0 1 0 1 0]]
Send comments to the NumArray community.