summaryrefslogtreecommitdiff
path: root/numpy/add_newdocs.py
diff options
context:
space:
mode:
authorhpaulj <hpj3@myuw.net>2014-01-07 11:39:49 -0800
committerCharles Harris <charlesr.harris@gmail.com>2014-01-10 11:12:45 -0700
commitb1b0ea8030cad32d6fce2e6e6b5068e54bd6b7a7 (patch)
tree87fb69446f24699037400005baccce9b9b986806 /numpy/add_newdocs.py
parentd1dbf8e796ab6bcdc4f3b71252f3921ab2a62269 (diff)
downloadnumpy-b1b0ea8030cad32d6fce2e6e6b5068e54bd6b7a7.tar.gz
ENH: Remove unnecessary broadcasting notation restrictions in einsum.
In a case where 'ik,kj->ij' works, einsum would raise an error for 'ik,k...->i...' because the 'ik' did not have ellipsis In einsum.c.src prepare_op_axes() pass all 'broadcast' cases through the 'RIGHT' case (interation from the end). Since the BROADCAST variable is not longer needed, all instances of it have been removed from einsum.c.src test_einsum.py - adds a test_einsum_broadcast case.
Diffstat (limited to 'numpy/add_newdocs.py')
-rw-r--r--numpy/add_newdocs.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py
index 62ca6dca3..62e8898c9 100644
--- a/numpy/add_newdocs.py
+++ b/numpy/add_newdocs.py
@@ -2078,6 +2078,8 @@ add_newdoc('numpy.core', 'einsum',
array([ 30, 80, 130, 180, 230])
>>> np.dot(a, b)
array([ 30, 80, 130, 180, 230])
+ >>> np.einsum('...j,j', a, b)
+ array([ 30, 80, 130, 180, 230])
>>> np.einsum('ji', c)
array([[0, 3],
@@ -2147,6 +2149,18 @@ add_newdoc('numpy.core', 'einsum',
[ 4796., 5162.],
[ 4928., 5306.]])
+ >>> a = np.arange(6).reshape((3,2))
+ >>> b = np.arange(12).reshape((4,3))
+ >>> np.einsum('ki,jk->ij', a, b)
+ array([[10, 28, 46, 64],
+ [13, 40, 67, 94]])
+ >>> np.einsum('ki,...k->i...', a, b)
+ array([[10, 28, 46, 64],
+ [13, 40, 67, 94]])
+ >>> np.einsum('k...,jk', a, b)
+ array([[10, 28, 46, 64],
+ [13, 40, 67, 94]])
+
""")
add_newdoc('numpy.core', 'alterdot',