diff options
-rw-r--r-- | doc/source/reference/c-api/array.rst | 11 | ||||
-rw-r--r-- | numpy/core/src/multiarray/arrayobject.c | 16 |
2 files changed, 19 insertions, 8 deletions
diff --git a/doc/source/reference/c-api/array.rst b/doc/source/reference/c-api/array.rst index fb8acffe6..d2e873802 100644 --- a/doc/source/reference/c-api/array.rst +++ b/doc/source/reference/c-api/array.rst @@ -1623,6 +1623,17 @@ For all of these macros *arr* must be an instance of a (subclass of) calculations in NumPy that rely on the state of these flags do not repeat the calculation to update them. +.. c:function:: int PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name) + + 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 error messages. + It can be something like "assignment destination", "output array", + or even just "array". Array method alternative API ---------------------------- diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index b0c49aafe..a96ab31b9 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -621,15 +621,15 @@ array_might_be_written(PyArrayObject *obj) /*NUMPY_API * - * This function does nothing if obj is writeable, and 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. + * 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 error - * messages. Something like "assignment destination", "output array", or even - * just "array". + * *name* is a name for the array, used to give better error messages. + * It can be something like "assignment destination", "output array", + * or even just "array". */ NPY_NO_EXPORT int PyArray_FailUnlessWriteable(PyArrayObject *obj, const char *name) |