Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r67944:a6bcf5d26ccd Date: 2013-11-10 22:41 -0500 http://bitbucket.org/pypy/pypy/changeset/a6bcf5d26ccd/
Log: provide copy for numpy scalars diff --git a/pypy/module/micronumpy/interp_boxes.py b/pypy/module/micronumpy/interp_boxes.py --- a/pypy/module/micronumpy/interp_boxes.py +++ b/pypy/module/micronumpy/interp_boxes.py @@ -289,6 +289,9 @@ def descr_get_ndim(self, space): return space.wrap(0) + def descr_copy(self, space): + return self.convert_to(self.get_dtype(space)) + class W_BoolBox(W_GenericBox, PrimitiveBox): descr__new__, _get_dtype, descr_reduce = new_dtype_getter("bool") @@ -538,6 +541,7 @@ astype = interp2app(W_GenericBox.descr_astype), view = interp2app(W_GenericBox.descr_view), squeeze = interp2app(W_GenericBox.descr_self), + copy = interp2app(W_GenericBox.descr_copy), dtype = GetSetProperty(W_GenericBox.descr_get_dtype), itemsize = GetSetProperty(W_GenericBox.descr_get_itemsize), diff --git a/pypy/module/micronumpy/test/test_scalar.py b/pypy/module/micronumpy/test/test_scalar.py --- a/pypy/module/micronumpy/test/test_scalar.py +++ b/pypy/module/micronumpy/test/test_scalar.py @@ -65,6 +65,14 @@ assert type(a) is np.int32 assert a == 1 + def test_copy(self): + import numpy as np + a = np.int32(2) + b = a.copy() + assert type(b) is type(a) + assert b == a + assert b is not a + def test_squeeze(self): import numpy as np assert np.True_.squeeze() is np.True_ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit