def _shape_to_3d(shape):
    """Return a shape with 3-dimensions, even if lower dimensional
    shape is provided.

    >>> _shape_to_3d([5])
    [5, 1, 1]

    >>> _shape_to_3d([5, 2])
    [5, 2, 1]

    >>> _shape_to_3d([5, 3, 1])
    [5, 3, 1]

    >>> try:
    ...     _shape_to_3d([5, 3, 3, 1])
    ... except ValueError:
    ...     pass

    """
    shape = list(shape)
    L = len(shape)

    if L > 3:
        raise ValueError("Shape cannot be higher than 3-dimensional.")

    shape += [1,]*(3 - L)

    return shape