From 1d64baaef53c53c4647d7c3da2ca1ebc94d20d92 Mon Sep 17 00:00:00 2001 From: Ashay Athalye Date: Mon, 30 Oct 2023 20:44:57 -0400 Subject: [PATCH] Change check for non-zero types. --- .../approaches/grammar_search_invention_approach.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/predicators/approaches/grammar_search_invention_approach.py b/predicators/approaches/grammar_search_invention_approach.py index 3b4e0c586a..2bca2dbf08 100644 --- a/predicators/approaches/grammar_search_invention_approach.py +++ b/predicators/approaches/grammar_search_invention_approach.py @@ -974,14 +974,11 @@ def _select_predicates_by_clustering( types_in_effects = [ set(a.predicate.types) for a in seg.add_effects ] - if len(types_in_effects) == 0 or len( - set.union(*types_in_effects)) == 0: - # If there are no add effects or if the object - # arguments for all add effects are empty (which would - # happen if the add effects only involved Forall - # predicates that have no object arguments, e.g. in - # repeated_nextto), then don't cluster further. - continue + # To cluster on type, there must be types. That is, there + # must be add effects in the segment and the object + # arguments for at least one add effect must be nonempty. + assert len(types_in_effects) > 0 and len( + set.union(*types_in_effects)) > 0 types = tuple(sorted(list(set.union(*types_in_effects)))) types_to_segments.setdefault(types, []).append(seg) logging.info(