diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/methods.c | 2 | ||||
-rw-r--r-- | numpy/core/src/multiarray/scalartypes.c.src | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 13 |
3 files changed, 16 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index b60d179fb..efa97dd65 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -1070,7 +1070,7 @@ array_copy(PyArrayObject *self, PyObject *args, PyObject *kwds) /* Separate from array_copy to make __copy__ preserve Fortran contiguity. */ static PyObject * -array_copy_keeporder(PyArrayObject *self, PyObject *args, PyObject *kwds) +array_copy_keeporder(PyArrayObject *self, PyObject *args) { if (!PyArg_ParseTuple(args, ":__copy__")) { return NULL; diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 26a445529..5618e2d19 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -1529,7 +1529,7 @@ gentype_wraparray(PyObject *NPY_UNUSED(scalar), PyObject *args) */ /**begin repeat * - * #name = tolist, item, __deepcopy__, + * #name = tolist, item, __deepcopy__, __copy__, * swapaxes, conj, conjugate, nonzero, * fill, transpose, newbyteorder# */ @@ -1913,7 +1913,7 @@ static PyMethodDef gentype_methods[] = { /* for the copy module */ {"__copy__", - (PyCFunction)gentype_copy, + (PyCFunction)gentype___copy__, METH_VARARGS, NULL}, {"__deepcopy__", (PyCFunction)gentype___deepcopy__, diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index 664a0c383..a3c94e312 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -2247,5 +2247,18 @@ class TestRegression(object): else: assert_(t.__hash__ != None) + def test_scalar_copy(self): + scalar_types = set(np.sctypeDict.values()) + values = { + np.void: b"a", + np.bytes_: b"a", + np.unicode_: "a", + np.datetime64: "2017-08-25", + } + for sctype in scalar_types: + item = sctype(values.get(sctype, 1)) + item2 = copy.copy(item) + assert_equal(item, item2) + if __name__ == "__main__": run_module_suite() |