| 1651 | } |
| 1652 | |
| 1653 | static int |
| 1654 | npyiter_index_set( |
| 1655 | NewNpyArrayIterObject *self, PyObject *value, void *NPY_UNUSED(ignored)) |
| 1656 | { |
| 1657 | if (value == NULL) { |
| 1658 | PyErr_SetString(PyExc_AttributeError, |
| 1659 | "Cannot delete nditer index"); |
| 1660 | return -1; |
| 1661 | } |
| 1662 | if (self->iter == NULL) { |
| 1663 | PyErr_SetString(PyExc_ValueError, |
| 1664 | "Iterator is invalid"); |
| 1665 | return -1; |
| 1666 | } |
| 1667 | |
| 1668 | if (NpyIter_HasIndex(self->iter)) { |
| 1669 | npy_intp ind; |
| 1670 | ind = PyLong_AsLong(value); |
| 1671 | if (error_converting(ind)) { |
| 1672 | return -1; |
| 1673 | } |
| 1674 | if (NpyIter_GotoIndex(self->iter, ind) != NPY_SUCCEED) { |
| 1675 | return -1; |
| 1676 | } |
| 1677 | self->started = 0; |
| 1678 | self->finished = 0; |
| 1679 | |
| 1680 | /* If there is nesting, the nested iterators should be reset */ |
| 1681 | if (npyiter_resetbasepointers(self) != NPY_SUCCEED) { |
| 1682 | return -1; |
| 1683 | } |
| 1684 | |
| 1685 | return 0; |
| 1686 | } |
| 1687 | else { |
| 1688 | PyErr_SetString(PyExc_ValueError, |
| 1689 | "Iterator does not have an index"); |
| 1690 | return -1; |
| 1691 | } |
| 1692 | } |
| 1693 | |
| 1694 | static PyObject * |
| 1695 | npyiter_iterindex_get(NewNpyArrayIterObject *self, void *NPY_UNUSED(ignored)) |
nothing calls this directly
no test coverage detected