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