MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / conforms_partial_ordering

Function conforms_partial_ordering

lib/sqlalchemy/testing/util.py:104–115  ·  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

102
103
104def conforms_partial_ordering(tuples, sorted_elements):
105 """True if the given sorting conforms to the given partial ordering."""
106
107 deps = defaultdict(set)
108 for parent, child in tuples:
109 deps[parent].add(child)
110 for i, node in enumerate(sorted_elements):
111 for n in sorted_elements[i:]:
112 if node in deps[n]:
113 return False
114 else:
115 return True
116
117
118def all_partial_orderings(tuples, elements):

Callers 2

assert_sortMethod · 0.90

Calls 1

addMethod · 0.45

Tested by 2

assert_sortMethod · 0.72