def mask_x_by_z(x, z):
    """
    Given two arrays x and z of equal length, return a list of the
    values from x excluding any where the corresponding value of z is
    0.

    :param x: Output values are taken from this array
    :type x: :class:`~numpy.ndarray`
    :param z: x[i] is excluded from the output if z[i] == 0
    :type z: :class:`~numpy.ndarray`
    """

    assert len(x) == len(z)

    return [xi for xi, zi in zip(x, z) if zi != 0]