from typing import List


def pad_to_length(sentence: List, length: int, pad_ix: int) -> List:
    """
    Forces np_arr to length by either truncation (if longer) or zero-padding (if shorter)
    :param pad_ix:
    :param np_arr:
    :param length: Length to pad to
    :return: a new numpy array with the data from np_arr padded to be of length length. If length is less than the
    length of the base array, truncates instead.
    """
    result = [pad_ix] * length
    result[0:len(sentence)] = sentence
    return result