It is a bit unfortunate that slicing has a singularity. samples_to_trim = (some calculation yielding an integer >= 0) trimmed_vector = vector[:-samples_to_trim] if samples_to_trim != 0 else vector[:] A bit unfortunate that the case of samples_to_trim == 0 has to be handled differently. I don't really see any solution to this.