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

Function array_ascontiguousarray

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

Source from the content-addressed store, hash-verified

1925
1926
1927static PyObject *
1928array_ascontiguousarray(PyObject *NPY_UNUSED(ignored),
1929 PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
1930{
1931 PyObject *op;
1932 npy_dtype_info dt_info = {NULL, NULL};
1933 PyObject *like = Py_None;
1934 NPY_PREPARE_ARGPARSER;
1935
1936 if (len_args != 1 || (kwnames != NULL)) {
1937 if (npy_parse_arguments("ascontiguousarray", args, len_args, kwnames,
1938 "a", NULL, &op,
1939 "|dtype", &PyArray_DTypeOrDescrConverterOptional, &dt_info,
1940 "$like", NULL, &like,
1941 NULL, NULL, NULL) < 0) {
1942 Py_XDECREF(dt_info.descr);
1943 Py_XDECREF(dt_info.dtype);
1944 return NULL;
1945 }
1946 if (like != Py_None) {
1947 PyObject *deferred = array_implement_c_array_function_creation(
1948 "ascontiguousarray", like, NULL, NULL, args, len_args, kwnames);
1949 if (deferred != Py_NotImplemented) {
1950 Py_XDECREF(dt_info.descr);
1951 Py_XDECREF(dt_info.dtype);
1952 return deferred;
1953 }
1954 }
1955 }
1956 else {
1957 op = args[0];
1958 }
1959
1960 PyObject *res = _array_fromobject_generic(
1961 op, dt_info.descr, dt_info.dtype, NPY_FALSE, NPY_CORDER, NPY_FALSE,
1962 1);
1963 Py_XDECREF(dt_info.descr);
1964 Py_XDECREF(dt_info.dtype);
1965 return res;
1966}
1967
1968
1969static PyObject *

Callers

nothing calls this directly

Tested by

no test coverage detected