コード例 #1
0
def sample_diff_set():
    from expressions.expressions import Symbol

    x = Symbol("x")
    y = Symbol("y")
    tests = [
        (2 * x + 1, "x", 1.5, 10, 2, "0.0 * x + 1.0 * 2 + 0.0"),
        (3 * x + y, "x", 1.5, 10, 3, "0.0 * x + 1.0 * 3 + 0.0"),
        (
            x * y + x / y,
            "y",
            3,
            2,
            2.25,
            "0.0 * y + 1.0 * x + (0.0 * y - x * 1.0) / y ^ 2",
        ),
        (
            2 * x**3 + x**2 * y,
            "x",
            2,
            3,
            36,
            "0.0 * x ^ 3 + 3 * x ^ (3 - 1) * 1.0 * 2 + 2 * x ^"
            " (2 - 1) * 1.0 * y + 0.0 * x ^ 2",
        ),
    ]
    return tests
コード例 #2
0
def sample_expr_set():
    x = Symbol('x')
    y = Symbol('y')
    tests = [(3 * x + 2**(y / 5) - 1, 1.5, 10, 7.5),
             (3 * x + 2**(y / 5) - 1, 2.5, 11, 11.09479341998814),
             (4 * x + x**2 * y + 3 * y + 2, 1.0, 2.5, 16),
             (4 * x + x**2 * y + 3 * y + 2, 1.1, 2.25, 15.8725)]
    return tests
コード例 #3
0
def sample_expr_set():
    from expressions.expressions import Symbol, Number
    x = Symbol('x')
    y = Symbol('y')
    tests = [(3 * x + 2**(y / 5) - 1, 1.5, 10, 7.5),
             (3 * x + 2**(y / 5) - 1, 2.5, 11, 11.09479341998814),
             (4 * x + x**2 * y + 3 * y + 2, 1.0, 2.5, 16),
             (4 * x + x**2 * y + 3 * y + 2, 1.1, 2.25, 15.8725)]
    return tests
def sample_string_set():
    x = Symbol("x")
    y = Symbol("y")
    print(x, y)
    tests = [
        (x + 1)**(y * x**3) + y**2 * x * (2 / y),
        (1 / x + 1 / y)**2 + (1 + 2 * x),
        4 * (x / y)**(0.5),
    ]
    print(tests)
    return tests
コード例 #5
0
def sample_diff_set():
    from expressions.expressions import Symbol
    x = Symbol('x')
    y = Symbol('y')
    tests = [(2 * x + 1, 'x', 1.5, 10, 2, '0.0 * x + 1.0 * 2 + 0.0'),
             (3 * x + y, 'x', 1.5, 10, 3, '0.0 * x + 1.0 * 3 + 0.0'),
             (x * y + x / y, 'y', 3, 2, 2.25,
              '0.0 * y + 1.0 * x + (0.0 * y - x * 1.0) / y ^ 2'),
             (2 * x**3 + x**2 * y, 'x', 2, 3, 36,
              '0.0 * x ^ 3 + 3 * x ^ (3 - 1) * 1.0 * 2 + 2 * x ^'
              ' (2 - 1) * 1.0 * y + 0.0 * x ^ 2')]
    return tests
コード例 #6
0
def sample_string_set():
    x = Symbol('x')
    y = Symbol('y')
    tests = [(x + 1)**(y * x**3) + y**2 * x * (2 / y),
             (1 / x + 1 / y)**2 + (1 + 2 * x), 4 * (x / y)**(0.5)]
    return tests
コード例 #7
0
def sample_operand_expr():
    o1 = Symbol('x')
    o2 = Symbol('y')
    o3 = Number(42)
    o4 = Number(1)
    return o1, o2, o3, o4