Skip to content

Commit

Permalink
TST: Add test for np.tensordot on 0d arrays (numpy#12152)
Browse files Browse the repository at this point in the history
Collapsing none of the axes on an array with no axes should be expected to work just fine.

Relates to numpygh-12130
  • Loading branch information
Rishabh Chakrabarti authored and eric-wieser committed Feb 24, 2019
1 parent cdd7ab2 commit 3a75d86
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions numpy/core/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2756,3 +2756,9 @@ def test_zero_dimension(self):
td = np.tensordot(a, b, (1, 0))
assert_array_equal(td, np.dot(a, b))
assert_array_equal(td, np.einsum('ij,jk', a, b))

def test_zero_dimensional(self):
# gh-12130
arr_0d = np.array(1)
ret = np.tensordot(arr_0d, arr_0d, ([], [])) # contracting no axes is well defined
assert_array_equal(ret, arr_0d)

0 comments on commit 3a75d86

Please sign in to comment.