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

Function array_asfortranarray

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

Source from the content-addressed store, hash-verified

1967
1968
1969static PyObject *
1970array_asfortranarray(PyObject *NPY_UNUSED(ignored),
1971 PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
1972{
1973 PyObject *op;
1974 npy_dtype_info dt_info = {NULL, NULL};
1975 PyObject *like = Py_None;
1976 NPY_PREPARE_ARGPARSER;
1977
1978 if (len_args != 1 || (kwnames != NULL)) {
1979 if (npy_parse_arguments("asfortranarray", args, len_args, kwnames,
1980 "a", NULL, &op,
1981 "|dtype", &PyArray_DTypeOrDescrConverterOptional, &dt_info,
1982 "$like", NULL, &like,
1983 NULL, NULL, NULL) < 0) {
1984 Py_XDECREF(dt_info.descr);
1985 Py_XDECREF(dt_info.dtype);
1986 return NULL;
1987 }
1988 if (like != Py_None) {
1989 PyObject *deferred = array_implement_c_array_function_creation(
1990 "asfortranarray", like, NULL, NULL, args, len_args, kwnames);
1991 if (deferred != Py_NotImplemented) {
1992 Py_XDECREF(dt_info.descr);
1993 Py_XDECREF(dt_info.dtype);
1994 return deferred;
1995 }
1996 }
1997 }
1998 else {
1999 op = args[0];
2000 }
2001
2002 PyObject *res = _array_fromobject_generic(
2003 op, dt_info.descr, dt_info.dtype, NPY_FALSE, NPY_FORTRANORDER,
2004 NPY_FALSE, 1);
2005 Py_XDECREF(dt_info.descr);
2006 Py_XDECREF(dt_info.dtype);
2007 return res;
2008}
2009
2010
2011static PyObject *

Callers

nothing calls this directly

Tested by

no test coverage detected