MCPcopy Create free account
hub / github.com/numpy/numpy / test_vdot_uncontiguous

Method test_vdot_uncontiguous

numpy/core/tests/test_multiarray.py:6472–6492  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6470 assert_equal(np.vdot(b, b), res)
6471
6472 def test_vdot_uncontiguous(self):
6473 for size in [2, 1000]:
6474 # Different sizes match different branches in vdot.
6475 a = np.zeros((size, 2, 2))
6476 b = np.zeros((size, 2, 2))
6477 a[:, 0, 0] = np.arange(size)
6478 b[:, 0, 0] = np.arange(size) + 1
6479 # Make a and b uncontiguous:
6480 a = a[..., 0]
6481 b = b[..., 0]
6482
6483 assert_equal(np.vdot(a, b),
6484 np.vdot(a.flatten(), b.flatten()))
6485 assert_equal(np.vdot(a, b.copy()),
6486 np.vdot(a.flatten(), b.flatten()))
6487 assert_equal(np.vdot(a.copy(), b),
6488 np.vdot(a.flatten(), b.flatten()))
6489 assert_equal(np.vdot(a.copy('F'), b),
6490 np.vdot(a.flatten(), b.flatten()))
6491 assert_equal(np.vdot(a, b.copy('F')),
6492 np.vdot(a.flatten(), b.flatten()))
6493
6494
6495class TestDot:

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
flattenMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected