def trim(peaks, troughs):
    """
    Trims the peaks and troughs arrays such that they have the same length.
    
    Args:
        peaks (numpy array): list of peak indices or times
        troughs (numpy array): list of trough indices or times

    Returns:
        peaks (numpy array): list of peak indices or times
        troughs (numpy array): list of trough indices or times
    """
    # common len:
    n = min(len(peaks), len(troughs))
    # align arrays:
    return peaks[:n], troughs[:n]