[pypy-commit] pypy default: remove unused iterator next_skip_x
bdkearns
noreply at buildbot.pypy.org
Thu Oct 9 05:59:49 CEST 2014
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r73851:0582c24e67be
Date: 2014-10-08 18:36 -0400
http://bitbucket.org/pypy/pypy/changeset/0582c24e67be/
Log: remove unused iterator next_skip_x
diff --git a/pypy/module/micronumpy/iterators.py b/pypy/module/micronumpy/iterators.py
--- a/pypy/module/micronumpy/iterators.py
+++ b/pypy/module/micronumpy/iterators.py
@@ -35,10 +35,6 @@
[x.strides[i] * (x.shape[i] - 1) for i in range(len(x.shape))]
we can go faster.
All the calculations happen in next()
-
-next_skip_x(steps) tries to do the iteration for a number of steps at once,
-but then we cannot guarantee that we only overflow one single shape
-dimension, perhaps we could overflow times in one big step.
"""
from rpython.rlib import jit
from pypy.module.micronumpy import support
@@ -140,30 +136,6 @@
return IterState(self, index, indices, offset)
@jit.unroll_safe
- def next_skip_x(self, state, step):
- assert state.iterator is self
- assert step >= 0
- if step == 0:
- return state
- index = state.index + step
- indices = state.indices
- offset = state.offset
- for i in xrange(self.ndim_m1, -1, -1):
- idx = indices[i]
- if idx < (self.shape_m1[i] + 1) - step:
- indices[i] = idx + step
- offset += self.strides[i] * step
- break
- else:
- rem_step = (idx + step) // (self.shape_m1[i] + 1)
- cur_step = step - rem_step * (self.shape_m1[i] + 1)
- indices[i] = idx + cur_step
- offset += self.strides[i] * cur_step
- step = rem_step
- assert step > 0
- return IterState(self, index, indices, offset)
-
- @jit.unroll_safe
def goto(self, index):
# XXX simplify if self.contiguous (offset = start + index * elsize)
offset = self.array.start
diff --git a/pypy/module/micronumpy/test/test_iterators.py b/pypy/module/micronumpy/test/test_iterators.py
--- a/pypy/module/micronumpy/test/test_iterators.py
+++ b/pypy/module/micronumpy/test/test_iterators.py
@@ -49,56 +49,6 @@
assert s.offset == 1
assert s.indices == [1,0]
- def test_iterator_step(self):
- #iteration in C order with #contiguous layout => strides[-1] is 1
- #skip less than the shape
- shape = [3, 5]
- strides = [5, 1]
- backstrides = [x * (y - 1) for x,y in zip(strides, shape)]
- assert backstrides == [10, 4]
- i = ArrayIter(MockArray, support.product(shape), shape,
- strides, backstrides)
- s = i.reset()
- s = i.next_skip_x(s, 2)
- s = i.next_skip_x(s, 2)
- s = i.next_skip_x(s, 2)
- assert s.offset == 6
- assert not i.done(s)
- assert s.indices == [1,1]
- #And for some big skips
- s = i.next_skip_x(s, 5)
- assert s.offset == 11
- assert s.indices == [2,1]
- s = i.next_skip_x(s, 5)
- # Note: the offset does not overflow but recycles,
- # this is good for broadcast
- assert s.offset == 1
- assert s.indices == [0,1]
- assert i.done(s)
-
- #Now what happens if the array is transposed? strides[-1] != 1
- # therefore layout is non-contiguous
- strides = [1, 3]
- backstrides = [x * (y - 1) for x,y in zip(strides, shape)]
- assert backstrides == [2, 12]
- i = ArrayIter(MockArray, support.product(shape), shape,
- strides, backstrides)
- s = i.reset()
- s = i.next_skip_x(s, 2)
- s = i.next_skip_x(s, 2)
- s = i.next_skip_x(s, 2)
- assert s.offset == 4
- assert s.indices == [1,1]
- assert not i.done(s)
- s = i.next_skip_x(s, 5)
- assert s.offset == 5
- assert s.indices == [2,1]
- assert not i.done(s)
- s = i.next_skip_x(s, 5)
- assert s.indices == [0,1]
- assert s.offset == 3
- assert i.done(s)
-
def test_iterator_goto(self):
shape = [3, 5]
strides = [1, 3]
More information about the pypy-commit
mailing list