Iterate over x, yielding (index, value, entering), where * ``index``: a tuple of indices up to this point * ``value``: equal to ``x[index[0]][...][index[-1]]``. On the first iteration, is ``x`` itself * ``entering``: bool. The result of ``recurs
(self, x, index=())
| 131 | return f(x, **kwargs) |
| 132 | |
| 133 | def walk(self, x, index=()): |
| 134 | """ |
| 135 | Iterate over x, yielding (index, value, entering), where |
| 136 | |
| 137 | * ``index``: a tuple of indices up to this point |
| 138 | * ``value``: equal to ``x[index[0]][...][index[-1]]``. On the first iteration, is |
| 139 | ``x`` itself |
| 140 | * ``entering``: bool. The result of ``recurse_if(value)`` |
| 141 | """ |
| 142 | do_recurse = self.recurse_if(x) |
| 143 | yield index, x, do_recurse |
| 144 | |
| 145 | if not do_recurse: |
| 146 | return |
| 147 | for i, xi in enumerate(x): |
| 148 | # yield from ... |
| 149 | yield from self.walk(xi, index + (i,)) |
| 150 | |
| 151 | |
| 152 | # Implementation taken directly from numpy: |
no outgoing calls