[Numpy-discussion] A matrix user in the land of arrays
Keith Goodman
kwgoodman@gmail....
Fri May 9 12:52:08 CDT 2008
The recently proposed changes to the matrix class was the final push I
needed to begin slowly porting my package from matrices to arrays. But
I'm already stuck in the first stage (all new modules must use
arrays).
Here's a toy example of iterating over columns of a matrix:
x is a nxm matrix
y is a nx1 matrix
for j in xrange(x.shape[1]):
idx = where(y > scalar)[0]
x[idx,j] = scalar
If x and y become 2d arrays, the code still works. But what confuses
me is how to generalize it to work for both 2d and 1d arrays.
More information about the Numpy-discussion
mailing list