Skip to content

Commit

Permalink
test the path optimizer arg check
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed May 12, 2020
1 parent 00096c4 commit a329e24
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions opt_einsum/tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ def test_custom_random_greedy():
assert path_info.largest_intermediate == optimizer.best['size']
assert path_info.opt_cost == optimizer.best['flops']

# check error if we try and reuse the optimizer on a different expression
eq, shapes = oe.helpers.rand_equation(10, 4, seed=41)
views = list(map(np.ones, shapes))
with pytest.raises(ValueError):
path, path_info = oe.contract_path(eq, *views, optimize=optimizer)


def test_custom_branchbound():
eq, shapes = oe.helpers.rand_equation(8, 4, seed=42)
Expand All @@ -320,6 +326,12 @@ def test_custom_branchbound():
assert path_info.largest_intermediate == optimizer.best['size']
assert path_info.opt_cost == optimizer.best['flops']

# check error if we try and reuse the optimizer on a different expression
eq, shapes = oe.helpers.rand_equation(8, 4, seed=41)
views = list(map(np.ones, shapes))
with pytest.raises(ValueError):
path, path_info = oe.contract_path(eq, *views, optimize=optimizer)


@pytest.mark.skipif(sys.version_info < (3, 2), reason="requires python3.2 or higher")
def test_parallel_random_greedy():
Expand Down

0 comments on commit a329e24

Please sign in to comment.