iter_shape

sisl.utils.iter_shape(shape)[source]

Generator for iterating a shape by returning consecutive slices

Parameters:

shape (array_like) – the shape of the iterator

Yields:

tuple of int – a tuple of the same length as the input shape. The iterator is using the C-indexing.

Examples

>>> for slc in iter_shape([2, 1, 3]):
...    print(slc)
[0, 0, 0]
[0, 0, 1]
[0, 0, 2]
[1, 0, 0]
[1, 0, 1]
[1, 0, 2]