From 5f41846b4435b4c8e5773fdc0674842dea9a57c2 Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Sat, 25 Jun 2011 15:52:46 -0500 Subject: NEP: c-masked-array: Add example to clarify some masking semantics --- doc/neps/c-masked-array.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'doc/neps') 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 -- cgit v1.2.1