
Nov. 3, 2016
2:29 p.m.
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
3053
Age (days ago)
3053
Last active (days ago)
0 comments
1 participants
participants (1)
-
Nicolas P. Rougier