pynbody.util.indexing_tricks.relative_slice#
- pynbody.util.indexing_tricks.relative_slice(s_relative_to, s)[source]#
Return a slice s_prime with the property that ar[s_relative_to][s_prime] == ar[s].
Clearly this will not be possible for arbitrarily chosen s_relative_to and s, but it should be possible for any
s = intersect_slices(s_relative_to, s_any)
, which is the use case envisioned here.If impossible, a ValueError is raised.
This code does not work with end-relative (i.e. negative) start or stop positions.