def atleast_kd(array, k):
    """
    https://stackoverflow.com/questions/42516569/numpy-add-variable-number-of-dimensions-to-an-array
    """
    new_shape = array.shape + (1,) * (k - array.ndim)
    return array.reshape(new_shape)
