I want to trim a 1D numpy array by removing all elements from left and right that are a certain value (e.g. 255). It seems a bit silly to do all the extra work of
np.trim_zeros(arr - 255) + 255
Is there an equivalent trim
function which allows you to specify the values that trigger removal? Or can I perhaps roll my own by looking at the internals of trim_zeros
?