Author: Maciej Fijalkowski <fij...@gmail.com> Branch: Changeset: r54147:6e49d0a11647 Date: 2012-04-02 11:52 +0200 http://bitbucket.org/pypy/pypy/changeset/6e49d0a11647/
Log: repeat as a method 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 @@ -673,6 +673,10 @@ def compute_first_step(self, sig, frame): pass + @unwrap_spec(repeats=int) + def descr_repeat(self, space, repeats, w_axis=None): + return repeat(space, self, repeats, w_axis) + def convert_to_array(space, w_obj): if isinstance(w_obj, BaseArray): return w_obj @@ -1411,6 +1415,7 @@ tolist = interp2app(BaseArray.descr_tolist), take = interp2app(BaseArray.descr_take), compress = interp2app(BaseArray.descr_compress), + repeat = interp2app(BaseArray.descr_repeat), ) diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -1400,13 +1400,14 @@ assert array(3.0).nbytes == 8 def test_repeat(self): - from _numpypy import repeat + from _numpypy import repeat, array assert (repeat([[1, 2], [3, 4]], 3) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]).all() assert (repeat([[1, 2], [3, 4]], 2, axis=0) == [[1, 2], [1, 2], [3, 4], [3, 4]]).all() assert (repeat([[1, 2], [3, 4]], 2, axis=1) == [[1, 1, 2, 2], [3, 3, 4, 4]]).all() + assert (array([1, 2]).repeat(2) == array([1, 1, 2, 2])).all() class AppTestMultiDim(BaseNumpyAppTest): _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit