* General assignment with python indexing objects. */
| 1775 | * General assignment with python indexing objects. |
| 1776 | */ |
| 1777 | static int |
| 1778 | array_assign_subscript(PyArrayObject *self, PyObject *ind, PyObject *op) |
| 1779 | { |
| 1780 | int index_type; |
| 1781 | int index_num; |
| 1782 | int i, ndim, fancy_ndim; |
| 1783 | PyArray_Descr *descr = PyArray_DESCR(self); |
| 1784 | PyArrayObject *view = NULL; |
| 1785 | PyArrayObject *tmp_arr = NULL; |
| 1786 | npy_index_info indices[NPY_MAXDIMS * 2 + 1]; |
| 1787 | |
| 1788 | PyArrayMapIterObject *mit = NULL; |
| 1789 | |
| 1790 | /* When a subspace is used, casting is done manually. */ |
| 1791 | NPY_cast_info cast_info = {.func = NULL}; |
| 1792 | |
| 1793 | if (op == NULL) { |
| 1794 | PyErr_SetString(PyExc_ValueError, |
| 1795 | "cannot delete array elements"); |
| 1796 | return -1; |
| 1797 | } |
| 1798 | if (PyArray_FailUnlessWriteable(self, "assignment destination") < 0) { |
| 1799 | return -1; |
| 1800 | } |
| 1801 | |
| 1802 | /* field access */ |
| 1803 | if (PyDataType_HASFIELDS(PyArray_DESCR(self))){ |
| 1804 | PyArrayObject *view; |
| 1805 | int ret = _get_field_view(self, ind, &view); |
| 1806 | if (ret == 0){ |
| 1807 | if (view == NULL) { |
| 1808 | return -1; |
| 1809 | } |
| 1810 | if (PyArray_CopyObject(view, op) < 0) { |
| 1811 | Py_DECREF(view); |
| 1812 | return -1; |
| 1813 | } |
| 1814 | Py_DECREF(view); |
| 1815 | return 0; |
| 1816 | } |
| 1817 | } |
| 1818 | |
| 1819 | /* Prepare the indices */ |
| 1820 | index_type = prepare_index(self, ind, indices, &index_num, |
| 1821 | &ndim, &fancy_ndim, 1); |
| 1822 | |
| 1823 | if (index_type < 0) { |
| 1824 | return -1; |
| 1825 | } |
| 1826 | |
| 1827 | /* Full integer index */ |
| 1828 | if (index_type == HAS_INTEGER) { |
| 1829 | char *item; |
| 1830 | if (get_item_pointer(self, &item, indices, index_num) < 0) { |
| 1831 | return -1; |
| 1832 | } |
| 1833 | if (PyArray_Pack(PyArray_DESCR(self), item, op) < 0) { |
| 1834 | return -1; |
nothing calls this directly
no test coverage detected