From 5ae9046779a384eec7fc5897c6d7e3e458c7134d Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 30 Dec 2023 17:05:10 +0100 Subject: [PATCH] Create README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/ndindex/README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 numpy/ndindex/README.md diff --git a/numpy/ndindex/README.md b/numpy/ndindex/README.md new file mode 100644 index 0000000..0138bad --- /dev/null +++ b/numpy/ndindex/README.md @@ -0,0 +1,41 @@ +# ndindex +{:.no_toc} + + + +## Top + +Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + + +## [numpy.ndindex](https://numpy.org/doc/stable/reference/generated/numpy.ndindex.html) + +```python +class numpy.ndindex(*shape)[source] +``` + +> An N-dimensional iterator object to index arrays. +> +> Given the shape of an array, an ndindex instance iterates over the N-dimensional index of the array. At each iteration a tuple of indices is returned, the last dimension is iterated over first. + + +```python +import numpy as np + +for index in np.ndindex((3, 2, 1)): + print(index) +``` + +Output: + +```python +(0, 0, 0) +(0, 1, 0) +(1, 0, 0) +(1, 1, 0) +(2, 0, 0) +(2, 1, 0) +```