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

Method optimize_compare

numpy/core/tests/test_einsum.py:924–940  ·  view source on GitHub ↗
(self, subscripts, operands=None)

Source from the content-addressed store, hash-verified

922 assert res is a
923
924 def optimize_compare(self, subscripts, operands=None):
925 # Tests all paths of the optimization function against
926 # conventional einsum
927 if operands is None:
928 args = [subscripts]
929 terms = subscripts.split('->')[0].split(',')
930 for term in terms:
931 dims = [global_size_dict[x] for x in term]
932 args.append(np.random.rand(*dims))
933 else:
934 args = [subscripts] + operands
935
936 noopt = np.einsum(*args, optimize=False)
937 opt = np.einsum(*args, optimize='greedy')
938 assert_almost_equal(opt, noopt)
939 opt = np.einsum(*args, optimize='optimal')
940 assert_almost_equal(opt, noopt)
941
942 def test_hadamard_like_products(self):
943 # Hadamard outer products

Callers 9

test_complexMethod · 0.95
test_collapseMethod · 0.95
test_expandMethod · 0.95
test_edge_casesMethod · 0.95
test_inner_productMethod · 0.95
test_random_casesMethod · 0.95

Calls 2

assert_almost_equalFunction · 0.90
splitMethod · 0.45

Tested by

no test coverage detected