33int _init(PyObject* self, PyObject *args, PyObject *kwds) {
36 if (py_coeff ==
nullptr) {
37 PyErr_SetString(PyExc_TypeError,
38 "Failed to resolve self as PolynomialCoefficient in __init__");
43 if (py_coeff->
coeff !=
nullptr) {
44 delete py_coeff->
coeff;
45 py_coeff->
coeff =
nullptr;
52 static char *kwlist[] = {
const_cast<char*
>(
"index_by_vector"),
53 const_cast<char*
>(
"output_axis"),
54 const_cast<char*
>(
"coefficient_value"),
56 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"Oid", kwlist,
57 &py_index, &value_axis, &coefficient)) {
63 if (!PyList_Check(py_index)) {
64 PyErr_SetString(PyExc_TypeError,
65 "Failed to resolve index as a list");
68 size_t list_size = PyList_Size(py_index);
69 std::vector<int> index(list_size);
71 for (
size_t i = 0; i < list_size; ++i) {
72 PyObject* py_value = PyList_GetItem(py_index, i);
73 index[i] = int(PyLong_AsLong(py_value));
74 if (PyErr_Occurred() !=
nullptr) {
81 }
catch (std::exception& exc) {
82 PyErr_SetString(PyExc_RuntimeError, (&exc)->what());