def slice_combine(slice1, slice2, length):
    """
    returns a slice that is a combination of the two slices.
    As in 
      x[slice1][slice2]
    becomes
      combined_slice = slice_combine(slice1, slice2, len(x))
      x[combined_slice]
    :param slice1: The first slice
    :param slice2: The second slice
    :param length: The length of the first dimension of data being sliced. (eg len(x))
    """
slice1_step = slice1.step if slice1.step is not None else 1
slice2_step = slice2.step if slice2.step is not None else 1
step = slice1_step * slice2_step
slice1_indices = slice1.indices(length)
slice1_length = (abs(slice1_indices[1] - slice1_indices[0]) - 1) // abs(
    slice1_indices[2])
if (slice1_indices[1] - slice1_indices[0]) * slice1_step > 0:
    slice1_length += 1
else:
    return slice(0, 0, step)
slice2_indices = slice2.indices(slice1_length)
if not (slice2_indices[1] - slice2_indices[0]) * slice2_step > 0:
    return slice(0, 0, step)
start = slice1_indices[0] + slice2_indices[0] * slice1_step
stop = slice1_indices[0] + slice2_indices[1] * slice1_step
if start > stop:
    if stop < 0:
        stop = None
return slice(start, stop, step)
combining two slicing operations