MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SetDifferentKeysError

Function SetDifferentKeysError

tensorflow/python/util/util.cc:621–643  ·  view source on GitHub ↗

Sets error using keys of 'dict1' and 'dict2'. 'dict1' and 'dict2' are assumed to be Python dictionaries.

Source from the content-addressed store, hash-verified

619// Sets error using keys of 'dict1' and 'dict2'.
620// 'dict1' and 'dict2' are assumed to be Python dictionaries.
621void SetDifferentKeysError(PyObject* dict1, PyObject* dict2, string* error_msg,
622 bool* is_type_error) {
623 Safe_PyObjectPtr k1(MappingKeys(dict1));
624 if (PyErr_Occurred() || k1.get() == nullptr) {
625 *error_msg =
626 ("The two dictionaries don't have the same set of keys. Failed to "
627 "fetch keys.");
628 return;
629 }
630 Safe_PyObjectPtr k2(MappingKeys(dict2));
631 if (PyErr_Occurred() || k2.get() == nullptr) {
632 *error_msg =
633 ("The two dictionaries don't have the same set of keys. Failed to "
634 "fetch keys.");
635 return;
636 }
637 *is_type_error = false;
638 *error_msg = tensorflow::strings::StrCat(
639 "The two dictionaries don't have the same set of keys. "
640 "First structure has keys ",
641 PyObjectToString(k1.get()), ", while second structure has keys ",
642 PyObjectToString(k2.get()));
643}
644
645// Returns true iff there were no "internal" errors. In other words,
646// errors that has nothing to do with structure checking.

Callers 1

Calls 4

MappingKeysFunction · 0.85
PyObjectToStringFunction · 0.70
StrCatFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected