def logical_xor(a, b, unsafe=False):
    """logical xor without the bloat of numpy.logical_xor
        could be substituted with numpy.logical_xor
        !important: if unsafe is set to True, a and b are not checked. This improves speed but is risky.
        expects integers [0,1] or bools
    """

    if not unsafe:
        sum = a*1+b*1
        if sum > 2 or sum < 0:
            raise Exception(
                "The parameters for logical_xor have to be booleans or integers in range [0,1]. got a: " + str(a) + ", b: " + str(b))
    return a ^ b