MCPcopy Create free account
hub / github.com/numpy/numpy / PyArray_FailUnlessWriteable

Function PyArray_FailUnlessWriteable

numpy/core/src/multiarray/arrayobject.c:636–647  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

634 * or even just "array".
635 */
636NPY_NO_EXPORT int
637PyArray_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 */

Callers 15

array_flat_setFunction · 0.85
PyArray_SetFieldFunction · 0.85
PyArray_ByteswapFunction · 0.85
array_setscalarFunction · 0.85
_array_from_array_likeFunction · 0.85
PyArray_CopyAsFlatFunction · 0.85
PyArray_AssignRawScalarFunction · 0.85
array_getbufferFunction · 0.85
PyArray_PutToFunction · 0.85
PyArray_PutMaskFunction · 0.85
PyArray_SortFunction · 0.85

Calls 1

array_might_be_writtenFunction · 0.85

Tested by

no test coverage detected