summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMark Wiebe <mwiebe@enthought.com>2011-06-25 15:52:46 -0500
committerMark Wiebe <mwiebe@enthought.com>2011-06-27 10:32:42 -0500
commit5f41846b4435b4c8e5773fdc0674842dea9a57c2 (patch)
treef556acfa07daf9e8c9f3bb48ff5cb8f5c1cd05c8 /doc
parent8d74430d2d98bf760a0db6d1044565623c406a69 (diff)
downloadnumpy-5f41846b4435b4c8e5773fdc0674842dea9a57c2.tar.gz
NEP: c-masked-array: Add example to clarify some masking semantics
Diffstat (limited to 'doc')
-rw-r--r--doc/neps/c-masked-array.rst14
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/neps/c-masked-array.rst b/doc/neps/c-masked-array.rst
index 7215b503f..d3cb346eb 100644
--- a/doc/neps/c-masked-array.rst
+++ b/doc/neps/c-masked-array.rst
@@ -108,7 +108,19 @@ whether a value is masked by saying "arr[0] is np.NA".
All operations which write to masked arrays will not affect the value
unless they also unmask that value. This allows the storage behind
masked elements to still be relied on if they are still accessible
-from another view which doesn't have them masked.
+from another view which doesn't have them masked. For example::
+
+ >>> a = np.array([1,2])
+ >>> b = a.view()
+ >>> b.flags.hasmask = True
+ >>> b
+ array([1,2], masked=True)
+ >>> b[0] = np.NA
+ >>> b
+ array([NA,2], masked=True)
+ >>> a
+ array([1,2])
+ >>> # The underlying value in 'a' was untouched
If np.NA or masked values are copied to an array without a mask, an
exception will be raised. Adding a validitymask to the target array