import math


def rotate(v, axis, angle):
    """Rotate a vector about an axis through an angle

    Parameters
    ----------
    v : array with exactly 3 numeric entries
        The vector to be rotated.
    axis : one of 'x', 'z'
        The axis about which to rotate. Rotations about y are not
        supported since they are not needed!
    angle : float
        Angle of rotation, in radians.

    Returns
    -------
    u : array with exactly 3 numeric entries
        The rotated vector.

    """
    u = [0, 0, 0]
    if axis == 'x':
        u[0] = v[0]
        u[1] = v[1] * math.cos(angle) - v[2] * math.sin(angle)
        u[2] = v[1] * math.sin(angle) + v[2] * math.cos(angle)
    elif axis == 'z':
        u[0] = v[0] * math.cos(angle) - v[1] * math.sin(angle)
        u[1] = v[0] * math.sin(angle) + v[1] * math.cos(angle)
        u[2] = v[2]
    else:
        raise ValueError('Not supported.')

    return u