diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-07-28 12:19:16 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:48 -0600 |
commit | 69e0ed8c58a284ddfd305f2b1ff17cb8d04dd432 (patch) | |
tree | 0c5ea20c1e8d4c104fd793a880f2b4877abfd2c0 /doc | |
parent | 30bb48840646c6905d127e6d4c90e78ce197db5d (diff) | |
download | numpy-69e0ed8c58a284ddfd305f2b1ff17cb8d04dd432.tar.gz |
ENH: missingdata: Rewrote boolean indexing to support NA masks
Note I haven't hooked it up to the arr[] operator yet...
Diffstat (limited to 'doc')
-rw-r--r-- | doc/neps/missing-data.rst | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/neps/missing-data.rst b/doc/neps/missing-data.rst index 038ea9370..e83bd2189 100644 --- a/doc/neps/missing-data.rst +++ b/doc/neps/missing-data.rst @@ -743,6 +743,38 @@ to be consistent with the result of np.sum([]):: >>> np.sum([]) 0.0 +Boolean Indexing +================ + +Indexing using a boolean array containing NAs does not have a consistent +interpretation according to the NA abstraction. For example:: + + >>> a = np.array([1, 2]) + >>> mask = np.array([np.NA, True], maskna=True) + >>> a[mask] + What should happen here? + +Since the NA represents a valid but unknown value, and it is a boolean, +it has two possible underlying values:: + + >>> a[np.array([True, True])] + array([1, 2]) + >>> a[np.array([False, True])] + array([2]) + +The thing which changes is the length of the output array, nothing which +itself can be substituted for NA. For this reason, at least initially, +NumPy will raise an exception for this case. + +Another possibility is to add an inconsistency, and follow the approach +R uses. That is, to produce the following:: + + >>> a[mask] + array([NA, 2], maskna=True) + +If, in user testing, this is found necessary for pragmatic reasons, +the feature should be added even though it is inconsistent. + PEP 3118 ======== |