def convert_time_units(times, time_unit, target_time_unit):
    """Convert a time array from time_unit to target_time_unit

    Args:
        times (np.ndarray): array of time values in units time_unit
        time_unit (str): time unit, one of TIME_UNITS
        target_time_unit (str): new time unit, one of TIME_UNITS

    Raises:
        ValueError: If time units are not convertable

    Returns:
        np.ndarray: times in units target_time_unit
    """
    if time_unit == "ticks" and target_time_unit == "ticks":
        return times

    def _to_seconds(times, time_unit):
        """Convert times in time_unit to seconds"""
        if time_unit == "s":
            return times
        if time_unit == "ms":
            return times / 1000.0
        raise NotImplementedError

    def _from_seconds(times_sec, target_time_unit):
        """Convert times in seconds to target_time_unit"""
        if target_time_unit == "s":
            return times_sec
        if target_time_unit == "ms":
            return times_sec * 1000.0
        raise NotImplementedError

    try:
        return _from_seconds(_to_seconds(times, time_unit), target_time_unit)
    except NotImplementedError:
        raise NotImplementedError(
            "Conversion of time in units {} to {} is not supported".format(
                time_unit, target_time_unit
            )
        )