| 2804 | } |
| 2805 | |
| 2806 | bool RaiseIfNotPySequence(PyObject* seq, const string& attr_name) { |
| 2807 | if (!PySequence_Check(seq)) { |
| 2808 | PyErr_SetString(PyExc_TypeError, |
| 2809 | Printf("expected a sequence for attr %s, got %s instead", |
| 2810 | attr_name.data(), seq->ob_type->tp_name) |
| 2811 | .data()); |
| 2812 | |
| 2813 | return false; |
| 2814 | } |
| 2815 | if (PyArray_Check(seq) && |
| 2816 | PyArray_NDIM(reinterpret_cast<PyArrayObject*>(seq)) != 1) { |
| 2817 | PyErr_SetString(PyExc_ValueError, |
| 2818 | Printf("expected a sequence for attr %s, got an ndarray " |
| 2819 | "with rank %d instead", |
| 2820 | attr_name.data(), |
| 2821 | PyArray_NDIM(reinterpret_cast<PyArrayObject*>(seq))) |
| 2822 | .data()); |
| 2823 | return false; |
| 2824 | } |
| 2825 | return true; |
| 2826 | } |
| 2827 | |
| 2828 | bool RunCallbacks( |
| 2829 | const FastPathOpExecInfo& op_exec_info, PyObject* args, |
no test coverage detected