diff options
| author | Matti Picus <matti.picus@gmail.com> | 2021-10-10 13:24:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-10 13:24:17 +0300 |
| commit | 9eadd7a353711f3c53a7741995ae714e20c03ce0 (patch) | |
| tree | 43c34ee16a1ba2f143c8147649034e62c4059ae8 /numpy | |
| parent | 1eff1c543a8f1e9d7ea29182b8c76db5a2efc3c2 (diff) | |
| parent | de4c233008e8d122ba6690ec39cf743fcb4115b7 (diff) | |
| download | numpy-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
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/function_base.py | 11 |
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 |
