MCPcopy Create free account
hub / github.com/numpy/numpy / array_empty_like

Function array_empty_like

numpy/core/src/multiarray/multiarraymodule.c:2111–2149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2109}
2110
2111static PyObject *
2112array_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
2145fail:
2146 Py_XDECREF(prototype);
2147 Py_XDECREF(dtype);
2148 return NULL;
2149}
2150
2151/*
2152 * This function is needed for supporting Pickles of

Callers

nothing calls this directly

Calls 2

npy_free_cache_dim_objFunction · 0.85

Tested by

no test coverage detected