summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2021-10-10 13:24:17 +0300
committerGitHub <noreply@github.com>2021-10-10 13:24:17 +0300
commit9eadd7a353711f3c53a7741995ae714e20c03ce0 (patch)
tree43c34ee16a1ba2f143c8147649034e62c4059ae8
parent1eff1c543a8f1e9d7ea29182b8c76db5a2efc3c2 (diff)
parentde4c233008e8d122ba6690ec39cf743fcb4115b7 (diff)
downloadnumpy-9eadd7a353711f3c53a7741995ae714e20c03ce0.tar.gz
Merge pull request #20047 from sistaseetaram/flag-writeable-upon-copy
DOC:add an example to show flag writeable cleared upon copy related to #20035
-rw-r--r--numpy/lib/function_base.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 3ca566f73..67563873b 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -779,6 +779,17 @@ 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.flags["WRITEABLE"]
+ True
+ >>> b[0] = 3
+ >>> b
+ 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