NUMPY_API * * This function does nothing and returns 0 if *obj* is writeable. * It raises an exception and returns -1 if *obj* is not writeable. * It may also do other house-keeping, such as issuing warnings on * arrays which are transitioning to become views. Always call this * function at some point before writing to an array. * * *name* is a name for the array, used to give better
| 634 | * or even just "array". |
| 635 | */ |
| 636 | NPY_NO_EXPORT int |
| 637 | PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name) |
| 638 | { |
| 639 | if (!PyArray_ISWRITEABLE(obj)) { |
| 640 | PyErr_Format(PyExc_ValueError, "%s is read-only", name); |
| 641 | return -1; |
| 642 | } |
| 643 | if (array_might_be_written(obj) < 0) { |
| 644 | return -1; |
| 645 | } |
| 646 | return 0; |
| 647 | } |
| 648 | |
| 649 | |
| 650 | /* From umath/string_ufuncs.cpp/h */ |
no test coverage detected