Hi all,

Given an array V that is a view of a base B, I was wondering if it is possible
to find a (string) index such that `V = B[index]`

For example:

```
B = np.arange(8*8).reshape(8,8)
V = B[::2,::2]

index = find_view(B,V)
print(index)
"::2,::2"

print(np.allclose(V, eval("B[%s]" % index)))
True
```


I wrote a solution at 
https://gist.github.com/rougier/b8c2256434b3a4a4271260cd4cc6cbc7 
(not very thoroughly tested) but maybe there are better ways to do that (like a 
magic numpy call ?)


(no use-case at all, only for teaching)


Nicolas

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
https://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to