| 2053 | } |
| 2054 | |
| 2055 | static PyObject * |
| 2056 | array_empty(PyObject *NPY_UNUSED(ignored), |
| 2057 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 2058 | { |
| 2059 | PyArray_Descr *typecode = NULL; |
| 2060 | PyArray_Dims shape = {NULL, 0}; |
| 2061 | NPY_ORDER order = NPY_CORDER; |
| 2062 | npy_bool is_f_order; |
| 2063 | PyArrayObject *ret = NULL; |
| 2064 | PyObject *like = Py_None; |
| 2065 | NPY_PREPARE_ARGPARSER; |
| 2066 | |
| 2067 | if (npy_parse_arguments("empty", args, len_args, kwnames, |
| 2068 | "shape", &PyArray_IntpConverter, &shape, |
| 2069 | "|dtype", &PyArray_DescrConverter, &typecode, |
| 2070 | "|order", &PyArray_OrderConverter, &order, |
| 2071 | "$like", NULL, &like, |
| 2072 | NULL, NULL, NULL) < 0) { |
| 2073 | goto fail; |
| 2074 | } |
| 2075 | |
| 2076 | if (like != Py_None) { |
| 2077 | PyObject *deferred = array_implement_c_array_function_creation( |
| 2078 | "empty", like, NULL, NULL, args, len_args, kwnames); |
| 2079 | if (deferred != Py_NotImplemented) { |
| 2080 | Py_XDECREF(typecode); |
| 2081 | npy_free_cache_dim_obj(shape); |
| 2082 | return deferred; |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | switch (order) { |
| 2087 | case NPY_CORDER: |
| 2088 | is_f_order = NPY_FALSE; |
| 2089 | break; |
| 2090 | case NPY_FORTRANORDER: |
| 2091 | is_f_order = NPY_TRUE; |
| 2092 | break; |
| 2093 | default: |
| 2094 | PyErr_SetString(PyExc_ValueError, |
| 2095 | "only 'C' or 'F' order is permitted"); |
| 2096 | goto fail; |
| 2097 | } |
| 2098 | |
| 2099 | ret = (PyArrayObject *)PyArray_Empty(shape.len, shape.ptr, |
| 2100 | typecode, is_f_order); |
| 2101 | |
| 2102 | npy_free_cache_dim_obj(shape); |
| 2103 | return (PyObject *)ret; |
| 2104 | |
| 2105 | fail: |
| 2106 | Py_XDECREF(typecode); |
| 2107 | npy_free_cache_dim_obj(shape); |
| 2108 | return NULL; |
| 2109 | } |
| 2110 | |
| 2111 | static PyObject * |
| 2112 | array_empty_like(PyObject *NPY_UNUSED(ignored), |
nothing calls this directly
no test coverage detected