Skip to content

Commit

Permalink
fix association naming during grow (close #105)
Browse files Browse the repository at this point in the history
  • Loading branch information
laowantong committed Dec 7, 2023
1 parent c422b07 commit a1ac28f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions mocodo/rewrite/_grow.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def run(source, subargs=None, params=None, **kargs):
while max_tries > 0:
random.shuffle(arities)
# Slightly push the non binary arities towards the end (one iteration of bubble sort).
# Reason: the non binary arities are tougher to place when there a not many entities yet
# Reason: the non binary arities are tougher to place when there are not many entities yet
for i in range(len(arities) - 1):
if arities[i] != 2 and arities[i + 1] == 2:
(arities[i], arities[i + 1]) = (arities[i + 1], arities[i])
Expand Down Expand Up @@ -175,8 +175,8 @@ def run(source, subargs=None, params=None, **kargs):
associations.append(new_association)
counter += 1
for i in range(settings["n"] - settings["doubles"], settings["n"]):
old_refs = biased_choice(ref_pool)
arity = len(set(old_refs))
refs = biased_choice(ref_pool)
arity = len(set(refs))
new_association = f"{association_bases[arity]} {counter}_"
cards = calculate_cards(card_schemes[i], refs)
clauses.append(", ".join([new_association] + [f"{card} {ref}" for (card, ref) in zip(cards, refs)]))
Expand Down
2 changes: 1 addition & 1 deletion test/test_rewrite_grow.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_default(self):
Binary 15_, 11 Entity 14_, 01 Entity 10_
Entity 16_: id 16 1, attr 16 2
Binary 17_, 0N Entity 16_, 1N Entity 14_
Binary 18_, 1N Entity 16_, 01 Entity 14_
Binary 18_, 1N Entity 14_, 01 Entity 10_
""".replace(" ", "")
self.assertEqual(actual.strip(), expected.strip())

Expand Down

0 comments on commit a1ac28f

Please sign in to comment.