예제 #1
0
def x():
    return Variable("x")
예제 #2
0
def test__can_fold_numbers_in_product_regardless_of_position(x):
    assert 2 * x * 3 == Product(Number(6), Variable("x"))
예제 #3
0
파일: test_sum.py 프로젝트: zxul767/pyexpr
def test__can_do_implicit_numeric_cast_in_sum_expressions(x):
    assert 1 + x == Sum(Number(1), Variable("x"))
    assert x + 1 == Sum(Variable("x"), Number(1))
예제 #4
0
def y():
    return Variable("y")
예제 #5
0
def test__can_multiply_products_and_sums(x):
    assert (x + 1) * (2 + x) == Product(
        Sum(Number(1), Variable("x")), Sum(Number(2), Variable("x"))
    )
예제 #6
0
def test__can_do_implicit_cast_in_inequality_comparison():
    assert "x" != Variable("y")
    assert Variable("y") != "x"
예제 #7
0
def test__can_compare_for_inequality():
    assert Variable("x") != Variable("y")
예제 #8
0
def test__can_multiply_numbers_and_variables(x):
    assert Number(2) * x == Product(Number(2), Variable("x"))
    assert x * Number(2) == Product(Variable("x"), Number(2))
예제 #9
0
def test__can_multiply_two_distinct_variables():
    assert Variable("x") * Variable("y") == Product(Variable("x"),
                                                    Variable("y"))
예제 #10
0
def test__can_multiply_two_variables_with_implicit_cast():
    assert "x" * Variable("x") == Product(Variable("x"), Variable("x"))
    assert Variable("x") * "x" == Product(Variable("x"), Variable("x"))
예제 #11
0
def test__can_compare_for_equality():
    assert Variable("x") == Variable("x")
예제 #12
0
def test__can_sum_two_variables_with_implicit_cast():
    assert Variable("x") + "x" == Sum(Variable("x"), Variable("x"))
    assert "x" + Variable("x") == Sum(Variable("x"), Variable("x"))
예제 #13
0
def test__can_sum_two_distinct_variables():
    assert Variable("x") + Variable("y") == Sum(Variable("x"), Variable("y"))
예제 #14
0
def test__multiplying_by_one_is_no_op(x):
    assert 1 * x == Variable("x")
    assert x * 1 == Variable("x")
예제 #15
0
파일: test_sum.py 프로젝트: zxul767/pyexpr
def test_can_fold_numbers_in_sum_regardless_of_position(x):
    assert 2 + x + 3 == Sum(Number(5), Variable("x"))
예제 #16
0
def test__can_multiply_numbers_and_products(x):
    assert 2 * (x * 1) == Product(Variable("x"), Number(2))
    assert (x * 1) * 2 == Product(Variable("x"), Number(2))
예제 #17
0
파일: test_sum.py 프로젝트: zxul767/pyexpr
def test__adding_zero_is_no_op(x):
    assert 0 + x == Variable("x")
    assert x + 0 == Variable("x")
예제 #18
0
def test__can_multiply_numbers_and_sums(x):
    assert 2 * (x + 1) == Product(Number(2), Sum(Variable("x"), Number(1)))
    assert (x + 1) * 2 == Product(Number(2), Sum(Variable("x"), Number(1)))
예제 #19
0
파일: test_sum.py 프로젝트: zxul767/pyexpr
def test__can_sum_numbers_and_variables(x):
    assert Number(1) + x == Sum(Number(1), Variable("x"))
    assert x + Number(1) == Sum(Variable("x"), Number(1))
예제 #20
0
def test__can_do_implicit_numeric_cast_in_product_expressions(x):
    assert 2 * x == Product(Number(2), Variable("x"))
    assert x * 2 == Product(Variable("x"), Number(2))
예제 #21
0
def test__can_do_implicit_cast_in_equality_comparison():
    assert "x" == Variable("x")
    assert Variable("x") == "x"