[Numpy-discussion] is it a bug?
Fri Mar 13 05:13:27 CDT 2009
Travis E. Oliphant wrote:
> firstname.lastname@example.org wrote:
Travis, thanks for the excellent explanation! It clears something which
I think is related to this, I've been wanting to ask on the ml for some
Now here's the case.
I often have 4d arrays that are actually related sets of satellite
imagery, and have the form of [date, band, y, x]. These can get pretty
large, so I like to prevent too much broadcasting or reshape-copy-ing
when indexing to save some memory. However, I regularly have to apply
some boolean index of [date, y, x] to each of the band dimensions (think
of the bool mask as a threshold base on just one of the bands).
Currently I usually loop over all band indices, e.g.
for b in data.shape:
data[:, b, :, :][mask] = 0
Would there be a way to do this in a more numpy-like fashion that is
More information about the Numpy-discussion