1. Pypy
  2. Untitled project
  3. pypy

Commits

Maciej Fijalkowski  committed 6e49d0a

repeat as a method

  • Participants
  • Parent commits 5da12de
  • Branches default

Comments (0)

Files changed (2)

File pypy/module/micronumpy/interp_numarray.py

View file
     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
     tolist = interp2app(BaseArray.descr_tolist),
     take = interp2app(BaseArray.descr_take),
     compress = interp2app(BaseArray.descr_compress),
+    repeat = interp2app(BaseArray.descr_repeat),
 )
 
 

File pypy/module/micronumpy/test/test_numarray.py

View file
         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):