/
conversion_utils.h
64 lines (50 loc) · 1.84 KB
/
conversion_utils.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _NPY_PRIVATE_CONVERSION_UTILS_H_
#define _NPY_PRIVATE_CONVERSION_UTILS_H_
NPY_NO_EXPORT int
PyArray_IntpConverter(PyObject *obj, PyArray_Dims *seq);
NPY_NO_EXPORT int
PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf);
NPY_NO_EXPORT int
PyArray_BoolConverter(PyObject *object, Bool *val);
NPY_NO_EXPORT int
PyArray_ByteorderConverter(PyObject *obj, char *endian);
NPY_NO_EXPORT int
PyArray_SortkindConverter(PyObject *obj, NPY_SORTKIND *sortkind);
NPY_NO_EXPORT int
PyArray_SearchsideConverter(PyObject *obj, void *addr);
NPY_NO_EXPORT int
PyArray_PyIntAsInt(PyObject *o);
NPY_NO_EXPORT intp
PyArray_PyIntAsIntp(PyObject *o);
NPY_NO_EXPORT int
PyArray_IntpFromSequence(PyObject *seq, intp *vals, int maxvals);
NPY_NO_EXPORT int
PyArray_TypestrConvert(int itemsize, int gentype);
NPY_NO_EXPORT PyObject *
PyArray_IntTupleFromIntp(int len, intp *vals);
/*
* Converts an axis parameter into an ndim-length C-array of
* boolean flags, True for each axis specified.
*
* If obj is None, everything is set to True. If obj is a tuple,
* each axis within the tuple is set to True. If obj is an integer,
* just that axis is set to True.
*/
NPY_NO_EXPORT int
PyArray_ConvertMultiAxis(PyObject *axis_in, int ndim, npy_bool *out_axis_flags);
/**
* WARNING: This flag is a bad idea, but was the only way to both
* 1) Support unpickling legacy pickles with object types.
* 2) Deprecate (and later disable) usage of O4 and O8
*
* The key problem is that the pickled representation unpickles by
* directly calling the dtype constructor, which has no way of knowing
* that it is in an unpickle context instead of a normal context without
* evil global state like we create here.
*/
#ifdef NPY_ENABLE_SEPARATE_COMPILATION
extern NPY_NO_EXPORT int evil_global_disable_warn_O4O8_flag;
#else
NPY_NO_EXPORT int evil_global_disable_warn_O4O8_flag;
#endif
#endif