| 2109 | } |
| 2110 | |
| 2111 | static PyObject * |
| 2112 | array_empty_like(PyObject *NPY_UNUSED(ignored), |
| 2113 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 2114 | { |
| 2115 | PyArrayObject *prototype = NULL; |
| 2116 | PyArray_Descr *dtype = NULL; |
| 2117 | NPY_ORDER order = NPY_KEEPORDER; |
| 2118 | PyArrayObject *ret = NULL; |
| 2119 | int subok = 1; |
| 2120 | /* -1 is a special value meaning "not specified" */ |
| 2121 | PyArray_Dims shape = {NULL, -1}; |
| 2122 | |
| 2123 | NPY_PREPARE_ARGPARSER; |
| 2124 | |
| 2125 | if (npy_parse_arguments("empty_like", args, len_args, kwnames, |
| 2126 | "prototype", &PyArray_Converter, &prototype, |
| 2127 | "|dtype", &PyArray_DescrConverter2, &dtype, |
| 2128 | "|order", &PyArray_OrderConverter, &order, |
| 2129 | "|subok", &PyArray_PythonPyIntFromInt, &subok, |
| 2130 | "|shape", &PyArray_OptionalIntpConverter, &shape, |
| 2131 | NULL, NULL, NULL) < 0) { |
| 2132 | goto fail; |
| 2133 | } |
| 2134 | /* steals the reference to dtype if it's not NULL */ |
| 2135 | ret = (PyArrayObject *)PyArray_NewLikeArrayWithShape(prototype, order, dtype, |
| 2136 | shape.len, shape.ptr, subok); |
| 2137 | npy_free_cache_dim_obj(shape); |
| 2138 | if (!ret) { |
| 2139 | goto fail; |
| 2140 | } |
| 2141 | Py_DECREF(prototype); |
| 2142 | |
| 2143 | return (PyObject *)ret; |
| 2144 | |
| 2145 | fail: |
| 2146 | Py_XDECREF(prototype); |
| 2147 | Py_XDECREF(dtype); |
| 2148 | return NULL; |
| 2149 | } |
| 2150 | |
| 2151 | /* |
| 2152 | * This function is needed for supporting Pickles of |
nothing calls this directly
no test coverage detected