| 82 | } |
| 83 | |
| 84 | bool PyObject_CheckLong(PyObject* obj) { |
| 85 | if ((PyLong_Check(obj) && !PyBool_Check(obj)) || // NOLINT |
| 86 | PyObject_CheckVarType(obj) || // NOLINT |
| 87 | PyObject_CheckDataType(obj) || // NOLINT |
| 88 | (PyObject_CheckTensor(obj) && |
| 89 | reinterpret_cast<TensorObject*>(obj)->tensor.numel() == 1)) { |
| 90 | return true; |
| 91 | } |
| 92 | std::string type_name = |
| 93 | std::string(reinterpret_cast<PyTypeObject*>(obj->ob_type)->tp_name); |
| 94 | if (type_name.find("numpy.int") != std::string::npos) { |
| 95 | return true; |
| 96 | } |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | int32_t PyObject_ToInt32(PyObject* obj) { |
| 101 | int64_t res = 0; |
no test coverage detected