예제 #1
0
def test_relational_simplification_patterns_numerically():
    from sympy.core import Wild
    from sympy.logic.boolalg import simplify_patterns_and, \
        simplify_patterns_or, simplify_patterns_xor
    a = Wild('a')
    b = Wild('b')
    c = Wild('c')
    symb = [a, b, c]
    patternlists = [
        simplify_patterns_and(),
        simplify_patterns_or(),
        simplify_patterns_xor()
    ]
    for patternlist in patternlists:
        for pattern in patternlist:
            original = pattern[0]
            simplified = pattern[1]
            valuelist = list(set(list(combinations(list(range(-2, 2)) * 3,
                                                   3))))
            for values in valuelist:
                sublist = dict(zip(symb, values))
                originalvalue = original.subs(sublist)
                simplifiedvalue = simplified.subs(sublist)
                assert originalvalue == simplifiedvalue, "Original: {}\nand"\
                    " simplified: {}\ndo not evaluate to the same value for"\
                    "{}".format(original, simplified, sublist)
예제 #2
0
def test_relational_simplification_patterns_numerically():
    from sympy.core import Wild
    from sympy.logic.boolalg import simplify_patterns_and, \
        simplify_patterns_or, simplify_patterns_xor
    a = Wild('a')
    b = Wild('b')
    c = Wild('c')
    symb = [a, b, c]
    patternlists = [simplify_patterns_and(), simplify_patterns_or(),
                    simplify_patterns_xor()]
    for patternlist in patternlists:
        for pattern in patternlist:
            original = pattern[0]
            simplified = pattern[1]
            valuelist = list(set(list(combinations(list(range(-2, 2))*3, 3))))
            for values in valuelist:
                sublist = dict(zip(symb, values))
                originalvalue = original.subs(sublist)
                simplifiedvalue = simplified.subs(sublist)
                assert originalvalue == simplifiedvalue, "Original: {}\nand"\
                    " simplified: {}\ndo not evaluate to the same value for"\
                    "{}".format(original, simplified, sublist)