[Numpy-discussion] Generically Creating Intermediate Data Compatible with Either ndarray or MasledArray Types
Tue Mar 11 14:10:47 CDT 2008
I have a function that I would like to work with both MaskedArray's
and ndarray's. The only blocker for this particular function is the
need to create some stand-in data that is appropriately either a
MaskedArray or an ndarray. Currently I have:
dummy = numpy.ones(data.shape, dtype=bool)
where data has a dtype of float. I've already discovered that
numpy.ones_like "does the right thing", but how do I do the equivalent
in conjunction with declaring a new dtype?
Said another way, how can a create arrays of the same class and
(possibly) shape as an existing array, but with a different dtype?
More information about the Numpy-discussion