From 2f1eb852a06605f977c388c9854ffdcb00296bd0 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 30 Dec 2023 19:23:26 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- numpy/ravel_unravel/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/numpy/ravel_unravel/README.md b/numpy/ravel_unravel/README.md index cbee57e..ae3b29e 100644 --- a/numpy/ravel_unravel/README.md +++ b/numpy/ravel_unravel/README.md @@ -55,6 +55,13 @@ numpy.unravel_index(indices, shape, order='C') > Converts a flat index or array of flat indices into a tuple of coordinate arrays. +```python +import numpy as np +idx = np.ravel_multi_index(([0, 1, 2], [0, 1, 1]), dims=(3, 2)) +print(idx) # -> [0 3 5] - +a, b = np.unravel_index(idx, shape=(3, 2)) +print(a) # -> [0 1 2] +print(b) # -> [0 1 1] +```