I have a given numpy array and a list containing several slice objects (alternatively containing (start, end) tuples). I want to remove the position of the slice object from the original array and get the second array with the remaining values.
Toy example:
myarray = np.arange(20) array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) mylist=(slice(2,4),slice(15,19))
Do something and the result should be
array([0, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
An array can be several hundred thousand, a list of slice objects can contain several thousand elements, and I often need to perform an operation, so speed is somewhat important.
Numpy removal doesn't accept fragment list, as far as I can see?
At the moment, I am generating an add-on to my list of slicer objects and slicing this, but generating the add-on is a somewhat inconvenient process in which I sort my list of slicers and then repeat it, creating the slicer objects of the padding as needed. I hope there is a more elegant way that I did not understand!