| 2257 | } |
| 2258 | |
| 2259 | static PyObject * |
| 2260 | array_zeros(PyObject *NPY_UNUSED(ignored), |
| 2261 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 2262 | { |
| 2263 | PyArray_Descr *typecode = NULL; |
| 2264 | PyArray_Dims shape = {NULL, 0}; |
| 2265 | NPY_ORDER order = NPY_CORDER; |
| 2266 | npy_bool is_f_order = NPY_FALSE; |
| 2267 | PyArrayObject *ret = NULL; |
| 2268 | PyObject *like = Py_None; |
| 2269 | NPY_PREPARE_ARGPARSER; |
| 2270 | |
| 2271 | if (npy_parse_arguments("zeros", args, len_args, kwnames, |
| 2272 | "shape", &PyArray_IntpConverter, &shape, |
| 2273 | "|dtype", &PyArray_DescrConverter, &typecode, |
| 2274 | "|order", &PyArray_OrderConverter, &order, |
| 2275 | "$like", NULL, &like, |
| 2276 | NULL, NULL, NULL) < 0) { |
| 2277 | goto fail; |
| 2278 | } |
| 2279 | |
| 2280 | |
| 2281 | if (like != Py_None) { |
| 2282 | PyObject *deferred = array_implement_c_array_function_creation( |
| 2283 | "zeros", like, NULL, NULL, args, len_args, kwnames); |
| 2284 | if (deferred != Py_NotImplemented) { |
| 2285 | Py_XDECREF(typecode); |
| 2286 | npy_free_cache_dim_obj(shape); |
| 2287 | return deferred; |
| 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | switch (order) { |
| 2292 | case NPY_CORDER: |
| 2293 | is_f_order = NPY_FALSE; |
| 2294 | break; |
| 2295 | case NPY_FORTRANORDER: |
| 2296 | is_f_order = NPY_TRUE; |
| 2297 | break; |
| 2298 | default: |
| 2299 | PyErr_SetString(PyExc_ValueError, |
| 2300 | "only 'C' or 'F' order is permitted"); |
| 2301 | goto fail; |
| 2302 | } |
| 2303 | |
| 2304 | ret = (PyArrayObject *)PyArray_Zeros(shape.len, shape.ptr, |
| 2305 | typecode, (int) is_f_order); |
| 2306 | |
| 2307 | npy_free_cache_dim_obj(shape); |
| 2308 | return (PyObject *)ret; |
| 2309 | |
| 2310 | fail: |
| 2311 | Py_XDECREF(typecode); |
| 2312 | npy_free_cache_dim_obj(shape); |
| 2313 | return (PyObject *)ret; |
| 2314 | } |
| 2315 | |
| 2316 | static PyObject * |
nothing calls this directly
no test coverage detected