pynbody.util.intersect_slices

pynbody.util.intersect_slices#

pynbody.util.intersect_slices(s1, s2, array_length=None)[source]#

Given two python slices s1 and s2, return a new slice which will extract the data of an array d which is in both d[s1] and d[s2].

Note that it may not be possible to do this without information on the length of the array referred to, hence all slices with end-relative indexes are first converted into begin-relative indexes. This means that the slice returned may be specific to the length specified.