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

Function SameNamedtuples

tensorflow/python/util/util.cc:961–980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959}
960
961PyObject* SameNamedtuples(PyObject* o1, PyObject* o2) {
962 Safe_PyObjectPtr f1 = make_safe(PyObject_GetAttrString(o1, "_fields"));
963 Safe_PyObjectPtr f2 = make_safe(PyObject_GetAttrString(o2, "_fields"));
964 if (f1 == nullptr || f2 == nullptr) {
965 PyErr_SetString(
966 PyExc_RuntimeError,
967 "Expected namedtuple-like objects (that have _fields attr)");
968 return nullptr;
969 }
970
971 if (PyObject_RichCompareBool(f1.get(), f2.get(), Py_NE)) {
972 Py_RETURN_FALSE;
973 }
974
975 if (GetClassName(o1).compare(GetClassName(o2)) == 0) {
976 Py_RETURN_TRUE;
977 } else {
978 Py_RETURN_FALSE;
979 }
980}
981
982PyObject* AssertSameStructure(PyObject* o1, PyObject* o2, bool check_types,
983 bool expand_composites) {

Callers 1

Calls 4

GetClassNameFunction · 0.70
make_safeFunction · 0.50
getMethod · 0.45
compareMethod · 0.45

Tested by

no test coverage detected