summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSista Seetaram <hanumaseetaram@gmail.com>2021-10-06 07:55:28 +0530
committerSista Seetaram <hanumaseetaram@gmail.com>2021-10-06 07:55:28 +0530
commit13765686623a28c3cb25c86b6b4c0867ff27fd32 (patch)
treebe147542a075a20cc3b9c4af19dca996cf450bf5
parentfb2509ca6398e414a538c239e253395d554bf742 (diff)
downloadnumpy-13765686623a28c3cb25c86b6b4c0867ff27fd32.tar.gz
DOC:add an example to show flag writeable cleared upon copy
-rw-r--r--numpy/lib/function_base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 3ca566f73..a15687e3a 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -779,6 +779,14 @@ def copy(a, order='K', subok=False):
>>> x[0] == z[0]
False
+ Note that, np.copy clears previously set WRITEABLE=False flag.
+
+ >>> a = np.array([1,2,3])
+ >>> a.flags["WRITEABLE"] = False
+ >>> b = np.copy(a)
+ >>> b[0] = 3
+ array([3, 2, 3])
+
Note that np.copy is a shallow copy and will not copy object
elements within arrays. This is mainly important for arrays
containing Python objects. The new array will contain the