def SSE(dp, var, equ):
    if !checkDPFormat(dp):
        print "ERROR: invalid dotplot (dp) format in SSE"
        return -1
    if !calc.checkVarFormat(var):
        print "ERROR: invalid var format in SSE"
        return -2
    if 'x' not in equ:
        print "ERROR: must have x in equ. in SSE"
        return -3
    r = 0
    for i in dp:
        var["x"] = i[0]
        r += (i[1] - calc.solve(var, equ)) ** 2
    return r
Beispiel #2
0
def test_calc(expr: str, result: str):
    assert solve(expr) == result
Beispiel #3
0
def test_exception_not_found(expr: str):
    with pytest.raises(AssertionError):
        solve(expr)
Beispiel #4
0
def test_solve_5():
    assert solve([
        25, 4, '*', 3, '*', 10, '/', 5, 6, '*', 3, '/', 4, '*', '-', 10, 11,
        '*', 12, '*', 15, '/', '+'
    ]) == 78
Beispiel #5
0
def test_solve_4():
    assert solve([1, 2, '*', 3, '*', 4, '*', 5, '*']) == 120
Beispiel #6
0
def test_solve_3():
    assert solve([45, 5, '-']) == 40
Beispiel #7
0
def test_solve_1():
    assert solve([45, 5, '+']) == 50
Beispiel #8
0
def test_solve_0():
    assert solve([45, 5, 9, '*', '-', 6, 2, '/', '+']) == 3