Skip to content

Commit

Permalink
Fix random choice ofv coins
Browse files Browse the repository at this point in the history
  • Loading branch information
MassimoLauria committed Sep 30, 2020
1 parent 1a5fd66 commit db790e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cnfgen/clihelpers/simple_helpers.py
Expand Up @@ -173,10 +173,9 @@ def build_cnf(args):
n = args.n
if args.plant:
planted = {}
signs = random.choices([True, False], k=n)

for i in range(n):
planted["x_{0}".format(i + 1)] = signs[i]
planted["x_{0}".format(i + 1)] = random.choice([True, False])

return RandomKCNF(args.k,
args.n,
Expand Down
15 changes: 15 additions & 0 deletions tests/test_randomcnf.py
Expand Up @@ -65,6 +65,21 @@ def test_random_cnf_planted():
assert len(c) == 3


def test_random_cnf_planted_2():
planted = [{
"x_1": True,
"x_2": False,
"x_3": True,
"x_4": False,
"x_5": True,
"x_6": True
}]
F = RandomKCNF(3, 6, 10, planted_assignments=planted)
for c in F:
assert len(c) == 3
assert len(F) == 10


def test_randomkcnf_cnfgen():
cnfgen(["cnfgen", 'randkcnf', 4, 6, 10])

Expand Down

0 comments on commit db790e3

Please sign in to comment.