Skip to content

Commit

Permalink
BUG: core: fix wrong method flags for scalartypes.c.src:gentype_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Aug 25, 2017
1 parent cf618a5 commit 526a128
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/scalartypes.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ static PyMethodDef gentype_methods[] = {
/* for the copy module */
{"__copy__",
(PyCFunction)gentype_copy,
METH_VARARGS, NULL},
METH_VARARGS | METH_KEYWORDS, NULL},
{"__deepcopy__",
(PyCFunction)gentype___deepcopy__,
METH_VARARGS, NULL},
Expand Down
13 changes: 13 additions & 0 deletions numpy/core/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2247,5 +2247,18 @@ def test_correct_hash_dict(self):
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()

0 comments on commit 526a128

Please sign in to comment.