def items(): """Iterate through AND'ed items.""" for upoint in boolfunc.iter_upoints(inputs): ab = self.urestrict(upoint).pcdata[0] cd = other.urestrict(upoint).pcdata[0] # a & c, b | d yield ((ab & cd) & 2) | ((ab | cd) & 1)
def items(): """Iterate through XOR'ed items.""" # pylint: disable=C0103 for upoint in boolfunc.iter_upoints(inputs): ab = self.urestrict(upoint).pcdata[0] cd = other.urestrict(upoint).pcdata[0] # a & d | b & c, a & c | b & d a, b, c, d = ab >> 1, ab & 1, cd >> 1, cd & 1 yield ((a & d | b & c) << 1) | (a & c | b & d)
def test_iter_upoints(): assert list(iter_upoints([a, b])) == [({aa, bb}, set()), ({bb}, {aa}), ({aa}, {bb}), (set(), {aa, bb})]