diff options
author | Ian Henriksen <insertinterestingnamehere@gmail.com> | 2015-01-01 14:35:51 -0700 |
---|---|---|
committer | Ian Henriksen <insertinterestingnamehere@gmail.com> | 2015-01-01 16:34:30 -0700 |
commit | 08cfe11e41c2879384a45f1e93ca265296bfd47e (patch) | |
tree | 0915803d00877629e80fb1a192a6196d33b9164c /numpy/add_newdocs.py | |
parent | 26a8ae33f7a8f218ab0f4cf0ba89566cadfe4d1f (diff) | |
download | numpy-08cfe11e41c2879384a45f1e93ca265296bfd47e.tar.gz |
DOC: Added a note about writeability of views from np.einsum to
the corresponding docstring.
Also added an example showing how to write to the diagonal of an array.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r-- | numpy/add_newdocs.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index a88a782b4..73efdb6a9 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -2063,6 +2063,14 @@ add_newdoc('numpy.core', 'einsum', ``einsum(op0, sublist0, op1, sublist1, ..., [sublistout])``. The examples below have corresponding `einsum` calls with the two parameter methods. + .. versionadded:: 1.10.0 + + Views returned from einsum are now writeable whenever the input array + is writeable. For example, ``np.einsum('ijk...->kji...', a)`` will now + have the same effect as ``np.swapaxes(a, 0, 2)`` and + ``np.einsum('ii->i', a)`` will return a writeable view of the diagonal + of a 2D array. + Examples -------- >>> a = np.arange(25).reshape(5,5) @@ -2172,6 +2180,14 @@ add_newdoc('numpy.core', 'einsum', array([[10, 28, 46, 64], [13, 40, 67, 94]]) + >>> # since version 1.10.0 + >>> a = np.zeros((3, 3)) + >>> np.einsum('ii->i', a)[:] = 1 + >>> a + array([[ 1., 0., 0.], + [ 0., 1., 0.], + [ 0., 0., 1.]]) + """) add_newdoc('numpy.core', 'vdot', |