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

Function PyArray_ToFileObject

numpy/core/src/multiarray/methods.c:628–648  ·  view source on GitHub ↗

Like PyArray_ToFile but takes the file as a python object */

Source from the content-addressed store, hash-verified

626
627/* Like PyArray_ToFile but takes the file as a python object */
628static int
629PyArray_ToFileObject(PyArrayObject *self, PyObject *file, char *sep, char *format)
630{
631 npy_off_t orig_pos = 0;
632 FILE *fd = npy_PyFile_Dup2(file, "wb", &orig_pos);
633
634 if (fd == NULL) {
635 return -1;
636 }
637
638 int write_ret = PyArray_ToFile(self, fd, sep, format);
639 PyObject *err_type, *err_value, *err_traceback;
640 PyErr_Fetch(&err_type, &err_value, &err_traceback);
641 int close_ret = npy_PyFile_DupClose2(file, fd, orig_pos);
642 npy_PyErr_ChainExceptions(err_type, err_value, err_traceback);
643
644 if (write_ret || close_ret) {
645 return -1;
646 }
647 return 0;
648}
649
650/* This should grow an order= keyword to be consistent
651 */

Callers 1

array_tofileFunction · 0.85

Calls 4

npy_PyFile_Dup2Function · 0.85
PyArray_ToFileFunction · 0.85
npy_PyFile_DupClose2Function · 0.85

Tested by

no test coverage detected