[Numpy-discussion] use for missing (ignored) data?
Wed Mar 7 15:40:13 CST 2012
On Wednesday, March 7, 2012, Neal Becker <email@example.com> wrote:
> Charles R Harris wrote:
>> On Wed, Mar 7, 2012 at 1:05 PM, Neal Becker <firstname.lastname@example.org> wrote:
>>> I'm wondering what is the use for the ignored data feature?
>>> I can use:
>>> A[valid_A_indexes] = whatever
>>> to process only the 'non-ignored' portions of A. So at least some
>>> of ignored data are already supported without introducing a new type.
>>> w = A[valid_A_indexes]
>>> will copy A's data, and subsequent use of
>>> w[:] = something
>>> will not update A.
>>> Is this the reason for wanting the ignored data feature?
>> Suppose you are working with plotted data and want to turn points on/off
>> clicking on them interactively to see how that affects a fit. Why make
>> multiple copies, change sizes, destroy data, and all that nonsense? Just
>> have the click update the mask and redraw.
> But does
> some_func (A[valid_data_mask])
> actually perform a copy?
Yes! If it isn't sliced, or accessed by a scalar index, then you are given
a copy. Fancy indexing and Boolean indexing will not return a view.
Note that assignments to a Boolean-indexed array by a scalar is
A[valid_points] = 5
will do what you expect. But,
A[valid_points] += 5
may not, IIRC.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion