| 1882 | } |
| 1883 | |
| 1884 | static PyObject * |
| 1885 | array_asanyarray(PyObject *NPY_UNUSED(ignored), |
| 1886 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 1887 | { |
| 1888 | PyObject *op; |
| 1889 | npy_dtype_info dt_info = {NULL, NULL}; |
| 1890 | NPY_ORDER order = NPY_KEEPORDER; |
| 1891 | PyObject *like = Py_None; |
| 1892 | NPY_PREPARE_ARGPARSER; |
| 1893 | |
| 1894 | if (len_args != 1 || (kwnames != NULL)) { |
| 1895 | if (npy_parse_arguments("asanyarray", args, len_args, kwnames, |
| 1896 | "a", NULL, &op, |
| 1897 | "|dtype", &PyArray_DTypeOrDescrConverterOptional, &dt_info, |
| 1898 | "|order", &PyArray_OrderConverter, &order, |
| 1899 | "$like", NULL, &like, |
| 1900 | NULL, NULL, NULL) < 0) { |
| 1901 | Py_XDECREF(dt_info.descr); |
| 1902 | Py_XDECREF(dt_info.dtype); |
| 1903 | return NULL; |
| 1904 | } |
| 1905 | if (like != Py_None) { |
| 1906 | PyObject *deferred = array_implement_c_array_function_creation( |
| 1907 | "asanyarray", like, NULL, NULL, args, len_args, kwnames); |
| 1908 | if (deferred != Py_NotImplemented) { |
| 1909 | Py_XDECREF(dt_info.descr); |
| 1910 | Py_XDECREF(dt_info.dtype); |
| 1911 | return deferred; |
| 1912 | } |
| 1913 | } |
| 1914 | } |
| 1915 | else { |
| 1916 | op = args[0]; |
| 1917 | } |
| 1918 | |
| 1919 | PyObject *res = _array_fromobject_generic( |
| 1920 | op, dt_info.descr, dt_info.dtype, NPY_FALSE, order, NPY_TRUE, 0); |
| 1921 | Py_XDECREF(dt_info.descr); |
| 1922 | Py_XDECREF(dt_info.dtype); |
| 1923 | return res; |
| 1924 | } |
| 1925 | |
| 1926 | |
| 1927 | static PyObject * |
nothing calls this directly
no test coverage detected