File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -1023,6 +1023,15 @@ def to_equality_constraint(
10231023 return AllDifferentConstraint ()
10241024 return ValueError (f"Not possible: comparator should be '==' or '!=', is { comparator } " )
10251025 return None
1026+
1027+ # remove functionally duplicate restrictions (preserves order and whitespace)
1028+ if all (isinstance (r , str ) for r in restrictions ):
1029+ # clean the restriction strings to functional equivalence
1030+ restrictions_cleaned = [r .replace (' ' , '' ) for r in restrictions ]
1031+ restrictions_cleaned_unique = list (dict .fromkeys (restrictions_cleaned )) # dict preserves order
1032+ # get the indices of the unique restrictions, use these to build a new list of restrictions
1033+ restrictions_unique_indices = [restrictions_cleaned .index (r ) for r in restrictions_cleaned_unique ]
1034+ restrictions = [restrictions [i ] for i in restrictions_unique_indices ]
10261035
10271036 # create the parsed restrictions
10281037 if monolithic is False :
You can’t perform that action at this time.
0 commit comments