Author: Timo Paulssen <timona...@perpetuum-immobile.de> Branch: numpy-dtype-alt Changeset: r46701:f76fa35d1021 Date: 2011-08-22 09:00 +0200 http://bitbucket.org/pypy/pypy/changeset/f76fa35d1021/
Log: array.copy() now copies the dtype, too - with test. diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py --- a/pypy/module/micronumpy/interp_numarray.py +++ b/pypy/module/micronumpy/interp_numarray.py @@ -218,7 +218,7 @@ raise NotImplementedError def descr_copy(self, space): - return space.call_function(space.gettypefor(BaseArray), self) + return space.call_function(space.gettypefor(BaseArray), self, self.find_dtype()) def descr_get_shape(self, space): return space.newtuple([self.descr_len(space)]) diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -34,3 +34,15 @@ assert a[0] is False for i in xrange(1, 4): assert a[i] is True + + def test_copy_array_with_dtype(self): + from numpy import array + a = array([0, 1, 2, 3], dtype=long) + assert isinstance(a[0], int) + b = a.copy() + assert isinstance(b[0], int) + + a = array([0, 1, 2, 3], dtype=bool) + assert isinstance(a[0], bool) + b = a.copy() + assert isinstance(b[0], bool) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit