From ccc3411e89851fbb6270fa1ca8639c4825846957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Alexandre=20C=C3=B4t=C3=A9?= Date: Mon, 1 Jun 2020 13:41:17 -0400 Subject: [PATCH 1/2] Prevent overwriting the name of matching entities (e.g. container-key). --- textworld/generator/text_generation.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/textworld/generator/text_generation.py b/textworld/generator/text_generation.py index 46bc0cb6..f82e1c3e 100644 --- a/textworld/generator/text_generation.py +++ b/textworld/generator/text_generation.py @@ -22,6 +22,9 @@ def __getitem__(self, item): def assign_new_matching_names(obj1_infos, obj2_infos, grammar, exclude): + if obj1_infos.name is not None or obj2_infos.name is not None: + return False # One of the objects has already a name assigned to it. + tag = "#({}<->{})_match#".format(obj1_infos.type, obj2_infos.type) if not grammar.has_tag(tag): return False From 7b1b616716747ff2212abd3b152b2f815ae18990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Alexandre=20C=C3=B4t=C3=A9?= Date: Mon, 1 Jun 2020 14:10:36 -0400 Subject: [PATCH 2/2] Make flake8 3.8 happy. --- textworld/logic/tests/test_types.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/textworld/logic/tests/test_types.py b/textworld/logic/tests/test_types.py index d658e78e..15f9b5d3 100644 --- a/textworld/logic/tests/test_types.py +++ b/textworld/logic/tests/test_types.py @@ -75,11 +75,11 @@ def test_multi_closure(): pairs = list(hier.multi_ancestors((d, d))) expected = { - (b, d), (c, d), (d, b), (d, c), - (a, d), (b, b), (b, c), (c, b), (c, c), (d, a), + (b, d), (c, d), (d, b), (d, c), # noqa: E126 + (a, d), (b, b), (b, c), (c, b), (c, c), (d, a), # noqa: E131 (a, b), (a, c), (b, a), (c, a), - (a, a), - } # noqa: E131 + (a, a), # noqa: E131 + } assert len(pairs) == len(expected) assert set(pairs) == expected @@ -87,11 +87,11 @@ def test_multi_closure(): pairs = list(hier.multi_descendants((a, a))) expected = { - (a, b), (a, c), (b, a), (c, a), - (a, d), (b, b), (b, c), (c, b), (c, c), (d, a), + (a, b), (a, c), (b, a), (c, a), # noqa: E126 + (a, d), (b, b), (b, c), (c, b), (c, c), (d, a), # noqa: E131 (b, d), (c, d), (d, b), (d, c), - (d, d), - } # noqa: E131 + (d, d), # noqa: E131 + } assert len(pairs) == len(expected) assert set(pairs) == expected