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

Function array_array

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

Source from the content-addressed store, hash-verified

1791
1792
1793static PyObject *
1794array_array(PyObject *NPY_UNUSED(ignored),
1795 PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
1796{
1797 PyObject *op;
1798 npy_bool subok = NPY_FALSE;
1799 _PyArray_CopyMode copy = NPY_COPY_ALWAYS;
1800 int ndmin = 0;
1801 npy_dtype_info dt_info = {NULL, NULL};
1802 NPY_ORDER order = NPY_KEEPORDER;
1803 PyObject *like = Py_None;
1804 NPY_PREPARE_ARGPARSER;
1805
1806 if (len_args != 1 || (kwnames != NULL)) {
1807 if (npy_parse_arguments("array", args, len_args, kwnames,
1808 "object", NULL, &op,
1809 "|dtype", &PyArray_DTypeOrDescrConverterOptional, &dt_info,
1810 "$copy", &PyArray_CopyConverter, &copy,
1811 "$order", &PyArray_OrderConverter, &order,
1812 "$subok", &PyArray_BoolConverter, &subok,
1813 "$ndmin", &PyArray_PythonPyIntFromInt, &ndmin,
1814 "$like", NULL, &like,
1815 NULL, NULL, NULL) < 0) {
1816 Py_XDECREF(dt_info.descr);
1817 Py_XDECREF(dt_info.dtype);
1818 return NULL;
1819 }
1820 if (like != Py_None) {
1821 PyObject *deferred = array_implement_c_array_function_creation(
1822 "array", like, NULL, NULL, args, len_args, kwnames);
1823 if (deferred != Py_NotImplemented) {
1824 Py_XDECREF(dt_info.descr);
1825 Py_XDECREF(dt_info.dtype);
1826 return deferred;
1827 }
1828 }
1829 }
1830 else {
1831 /* Fast path for symmetry (we copy by default which is slow) */
1832 op = args[0];
1833 }
1834
1835 PyObject *res = _array_fromobject_generic(
1836 op, dt_info.descr, dt_info.dtype, copy, order, subok, ndmin);
1837 Py_XDECREF(dt_info.descr);
1838 Py_XDECREF(dt_info.dtype);
1839 return res;
1840}
1841
1842static PyObject *
1843array_asarray(PyObject *NPY_UNUSED(ignored),

Callers

nothing calls this directly

Tested by

no test coverage detected