Skip to content

Commit

Permalink
TST: change assertion in reordering test
Browse files Browse the repository at this point in the history
Sifting can result in different variable orders,
depending on the order of iteration over
dictionaries and sets in Python, when testing the class
`dd.autoref.BDD`, hence the class `dd.bdd.BDD`.

Instead of asserting that the optimal variable
order is obtained, assert that the size of the BDD
is reduced.
  • Loading branch information
johnyf committed Aug 26, 2020
1 parent b2aa2ee commit 890d191
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,12 +680,19 @@ def test_reorder_without_args(self):
self._confirm_var_order(vrs, bdd)
expr = '(z1 /\ y1) \/ (z2 /\ y2) \/ (z3 /\ y3)'
u = bdd.add_expr(expr)
n_before = u.dag_size
bdd.reorder()
levels = {var: bdd.level_of_var(var) for var in vrs}
for i in range(1, 4):
a = levels['z{i}'.format(i=i)]
b = levels['y{i}'.format(i=i)]
assert abs(a - b) == 1, levels
n_after = u.dag_size
assert n_after < n_before, (n_after, n_before)
# optimal: n_after == 6
#
# assert that each pair zi, yi is of
# variables at adjacent levels
# levels = {var: bdd.level_of_var(var) for var in vrs}
# for i in range(1, 4):
# a = levels['z{i}'.format(i=i)]
# b = levels['y{i}'.format(i=i)]
# assert abs(a - b) == 1, levels

def _confirm_var_order(self, vrs, bdd):
for i, var in enumerate(vrs):
Expand Down

0 comments on commit 890d191

Please sign in to comment.