Skip to content

Commit

Permalink
tests: cotenrga v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Sep 7, 2023
1 parent 22b9e97 commit e118c22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest
numpy
cotengra >= 0.3.1
cotengra >= 0.4.0
5 changes: 3 additions & 2 deletions tests/test_cotengrust.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def test_manual_cases(eq, which):
size_dict = get_rand_size_dict(inputs)
arrays = build_arrays(inputs, size_dict)
expected = np.einsum(eq, *arrays, optimize=True)

path = {
"greedy": ctgr.optimize_greedy,
"optimal": ctgr.optimize_optimal,
}[
which
](inputs, output, size_dict)
assert all(len(con) <= 2 for con in path)
tree = ctg.ContractionTree.from_path(inputs, output, size_dict, path=path)
assert_allclose(tree.contract(arrays), expected)

Expand All @@ -159,7 +159,7 @@ def test_basic_rand(seed, which):
}[
which
](inputs, output, size_dict)

assert all(len(con) <= 2 for con in path)
tree = ctg.ContractionTree.from_path(inputs, output, size_dict, path=path)
arrays = [np.random.randn(*s) for s in shapes]
assert_allclose(
Expand All @@ -179,6 +179,7 @@ def test_optimal_lattice_eq():
assert tree.contraction_cost() == 3628

path = ctgr.optimize_optimal(inputs, output, size_dict, minimize='size')
assert all(len(con) <= 2 for con in path)
tree = ctg.ContractionTree.from_path(
inputs, output, size_dict, path=path
)
Expand Down

0 comments on commit e118c22

Please sign in to comment.