broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    return {'pin-priority':(list(d['options'])), 'selection-priority':([x for x in d['options'] if x in d['selected']]+[x for x in d['options'] if x not in d['selected']]), 'unknown-last':(sorted(d['options'],key=lambda x:d['counts'][x] is None)), 'descending-count':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'stable-count-ties':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'pin-visible-only':([x for x in d['pinned'] if x in d['options']])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']})], 2: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 3: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 4: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 5: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    return {'pin-priority':([x for x in d['options'] if x in d['pinned']]), 'selection-priority':([x for x in d['options'] if x in d['selected']]+[x for x in d['options'] if x not in d['selected']]), 'unknown-last':(sorted(d['options'],key=lambda x:d['counts'][x] is None)), 'descending-count':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'stable-count-ties':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'pin-visible-only':([x for x in d['pinned'] if x in d['options']])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']})], 2: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 3: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 4: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 5: [({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Pinned facet choices lead without dropping unpinned values is violated by the widget projection.

Facet ordering uses pinned then selected priority, descending known counts, and stable server order for ties; unknown counts sort behind known counts. This example checks: Pinned facet choices lead without dropping unpinned values.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    return {'pin-priority':([x for x in d['options'] if x in d['pinned']]+[x for x in d['options'] if x not in d['pinned']]), 'selection-priority':(list(d['options'])), 'unknown-last':(sorted(d['options'],key=lambda x:d['counts'][x] is None)), 'descending-count':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'stable-count-ties':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'pin-visible-only':([x for x in d['pinned'] if x in d['options']])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 2: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 3: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']})], 4: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 5: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(d):
    return {'pin-priority':([x for x in d['options'] if x in d['pinned']]+[x for x in d['options'] if x not in d['pinned']]), 'selection-priority':(sorted(d['options'])), 'unknown-last':(sorted(d['options'],key=lambda x:d['counts'][x] is None)), 'descending-count':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'stable-count-ties':(sorted(d['options'],key=lambda x:-(d['counts'][x] if d['counts'][x] is not None else -1))), 'pin-visible-only':([x for x in d['pinned'] if x in d['options']])}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = {1: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 2: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []})], 3: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']})], 4: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']})], 5: [({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['b', 'c', 'a'], 'descending-count': ['b', 'c', 'a'], 'stable-count-ties': ['b', 'c', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'a', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['c', 'b', 'a'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': []}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'c', 'b'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': ['a', 'b']}), ({'options': ['c', 'b', 'a'], 'pinned': ['a', 'z', 'b'], 'selected': ['b', 'c'], 'counts': {'a': None, 'b': 0, 'c': 0}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['c', 'b', 'a'], 'unknown-last': ['c', 'b', 'a'], 'descending-count': ['c', 'b', 'a'], 'stable-count-ties': ['c', 'b', 'a'], 'pin-visible-only': ['a', 'b']}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['a'], 'counts': {'a': 2, 'b': 2, 'c': None}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['a', 'b', 'c'], 'unknown-last': ['b', 'a', 'c'], 'descending-count': ['b', 'a', 'c'], 'stable-count-ties': ['b', 'a', 'c'], 'pin-visible-only': []}), ({'options': ['b', 'a', 'c'], 'pinned': [], 'selected': ['b', 'c'], 'counts': {'a': 0, 'b': None, 'c': 3}}, {'pin-priority': ['b', 'a', 'c'], 'selection-priority': ['b', 'c', 'a'], 'unknown-last': ['a', 'c', 'b'], 'descending-count': ['c', 'a', 'b'], 'stable-count-ties': ['c', 'a', 'b'], 'pin-visible-only': []})]}
for index, (data, expected) in enumerate(fixtures[N]):
    check("contract fixture " + str(index), solve(data), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Selected-first facet presentation retains server order inside partitions is violated by the widget projection.

Facet ordering uses pinned then selected priority, descending known counts, and stable server order for ties; unknown counts sort behind known counts. This example checks: Selected-first facet presentation retains server order inside partitions.

split: open-access