30int _init(PyObject* self, PyObject *args, PyObject *kwds) {
33 if (py_coeff ==
nullptr) {
34 PyErr_SetString(PyExc_TypeError,
35 "Failed to resolve self as PolynomialCoefficient in __init__");
40 if (py_coeff->coeff !=
nullptr) {
41 delete py_coeff->coeff;
42 py_coeff->coeff =
nullptr;
49 static char *kwlist[] = {
const_cast<char*
>(
"index_by_vector"),
50 const_cast<char*
>(
"output_axis"),
51 const_cast<char*
>(
"coefficient_value"),
53 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"Oid", kwlist,
54 &py_index, &value_axis, &coefficient)) {
60 if (!PyList_Check(py_index)) {
61 PyErr_SetString(PyExc_TypeError,
62 "Failed to resolve index as a list");
65 size_t list_size = PyList_Size(py_index);
66 std::vector<int> index(list_size);
68 for (
size_t i = 0; i < list_size; ++i) {
69 PyObject* py_value = PyList_GetItem(py_index, i);
70 index[i] = int(PyLong_AsLong(py_value));
71 if (PyErr_Occurred() !=
nullptr) {
78 }
catch (std::exception& exc) {
79 PyErr_SetString(PyExc_RuntimeError, (&exc)->what());