MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / conforms_partial_ordering

Function conforms_partial_ordering

lib/sqlalchemy/testing/util.py:145–156  ·  view source on GitHub ↗

True if the given sorting conforms to the given partial ordering.

(tuples, sorted_elements)

Source from the content-addressed store, hash-verified

143
144
145def conforms_partial_ordering(tuples, sorted_elements):
146 """True if the given sorting conforms to the given partial ordering."""
147
148 deps = defaultdict(set)
149 for parent, child in tuples:
150 deps[parent].add(child)
151 for i, node in enumerate(sorted_elements):
152 for n in sorted_elements[i:]:
153 if node in deps[n]:
154 return False
155 else:
156 return True
157
158
159def all_partial_orderings(tuples, elements):

Callers 2

assert_sortMethod · 0.90

Calls 1

addMethod · 0.45

Tested by 2

assert_sortMethod · 0.72