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

Function array_copyto

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

Source from the content-addressed store, hash-verified

2009
2010
2011static PyObject *
2012array_copyto(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kwds)
2013{
2014 static char *kwlist[] = {"dst", "src", "casting", "where", NULL};
2015 PyObject *wheremask_in = NULL;
2016 PyArrayObject *dst = NULL, *src = NULL, *wheremask = NULL;
2017 NPY_CASTING casting = NPY_SAME_KIND_CASTING;
2018
2019 if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O&|O&O:copyto", kwlist,
2020 &PyArray_Type, &dst,
2021 &PyArray_Converter, &src,
2022 &PyArray_CastingConverter, &casting,
2023 &wheremask_in)) {
2024 goto fail;
2025 }
2026
2027 if (wheremask_in != NULL) {
2028 /* Get the boolean where mask */
2029 PyArray_Descr *dtype = PyArray_DescrFromType(NPY_BOOL);
2030 if (dtype == NULL) {
2031 goto fail;
2032 }
2033 wheremask = (PyArrayObject *)PyArray_FromAny(wheremask_in,
2034 dtype, 0, 0, 0, NULL);
2035 if (wheremask == NULL) {
2036 goto fail;
2037 }
2038 }
2039
2040 if (PyArray_AssignArray(dst, src, wheremask, casting) < 0) {
2041 goto fail;
2042 }
2043
2044 Py_XDECREF(src);
2045 Py_XDECREF(wheremask);
2046
2047 Py_RETURN_NONE;
2048
2049fail:
2050 Py_XDECREF(src);
2051 Py_XDECREF(wheremask);
2052 return NULL;
2053}
2054
2055static PyObject *
2056array_empty(PyObject *NPY_UNUSED(ignored),

Callers

nothing calls this directly

Calls 2

PyArray_FromAnyFunction · 0.85
PyArray_AssignArrayFunction · 0.85

Tested by

no test coverage detected