MCPcopy
hub / github.com/dmlc/dgl / check_all_same_schema_for_keys

Function check_all_same_schema_for_keys

python/dgl/utils/checks.py:215–239  ·  view source on GitHub ↗

Check the list of schemas are the same on the given keys.

(schemas, keys, name)

Source from the content-addressed store, hash-verified

213
214
215def check_all_same_schema_for_keys(schemas, keys, name):
216 """Check the list of schemas are the same on the given keys."""
217 if len(schemas) == 0:
218 return
219
220 head = None
221 keys = set(keys)
222 for i, schema in enumerate(schemas):
223 if not keys.issubset(schema.keys()):
224 raise DGLError(
225 "Expect all graphs to have keys {} on {}, "
226 "but graph {} got keys {}.".format(keys, name, i, schema.keys())
227 )
228
229 if head is None:
230 head = {k: schema[k] for k in keys}
231 else:
232 target = {k: schema[k] for k in keys}
233 if target != head:
234 raise DGLError(
235 "Expect all graphs to have the same schema for keys {} on {}, "
236 "but graph {} got \n\t{}\n which is different from\n\t{}.".format(
237 keys, name, i, target, head
238 )
239 )
240
241
242def check_valid_idtype(idtype):

Callers

nothing calls this directly

Calls 3

DGLErrorClass · 0.85
formatMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected