blob: b96a3c8a8fa44640d497d318a8380c52cf282dba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#ifndef _NPY_ARRAY_METHODS_H_
#define _NPY_ARRAY_METHODS_H_
#include "npy_import.h"
extern NPY_NO_EXPORT PyMethodDef array_methods[];
NPY_NO_EXPORT const char *
npy_casting_to_string(NPY_CASTING casting);
/* Pathlib support */
static inline PyObject *
NpyPath_PathlikeToFspath(PyObject *file)
{
static PyObject *os_PathLike = NULL;
static PyObject *os_fspath = NULL;
npy_cache_import("numpy.compat", "os_PathLike", &os_PathLike);
if (os_PathLike == NULL) {
return NULL;
}
npy_cache_import("numpy.compat", "os_fspath", &os_fspath);
if (os_fspath == NULL) {
return NULL;
}
if (!PyObject_IsInstance(file, os_PathLike)) {
return file;
}
return PyObject_CallFunctionObjArgs(os_fspath, file, NULL);
}
#endif
|