示例#1
0
def test_sd():
    a = -1
    b = 0
    c = 1.01
    x = stdev([a, b, c])
    command = "sd({}, {}, {})".format(a, b, c)
    assert sd(None)(command) == (
        POST_MESSAGE,
        block("{} = {}".format(remove_whitespace(command), round(x, 10))),
    )
示例#2
0
def test_lm():
    x = [1.0, 2.0, 3.0]
    y = [4.0, 5.0, 100.0]
    (m, b, r, p, _) = linregress(x, y)
    command = "lm({}, {})".format(x, y)
    response = [
        "{} =".format(remove_whitespace(command)),
        "    slope     : {:8.9f}",
        "    intercept : {:8.9f}",
        "    r-squared : {:8.9f}",
        "    p-value   : {:8.9f}",
    ]
    assert lm(None)(command) == \
        (POST_MESSAGE, block(newlines(response).format(m, b, r ** 2, p)))
示例#3
0
 def test_split(self):
     command = "median(-10.001, -10, 10, 1000)"
     assert median_(None)(command) == \
         (POST_MESSAGE, block("{} = 0".format(remove_whitespace(command))))
示例#4
0
 def test_no_exception(self):
     command = "mode(1.01, 1.01, 1.01, 0, 0)"
     assert mode_(None)(command) == (
         POST_MESSAGE,
         block("{} = 1.01".format(remove_whitespace(command))),
     )
示例#5
0
 def test_exact(self):
     command = "median(-11, -10.001, 1000)"
     assert median_(None)(command) == (
         POST_MESSAGE,
         block("{} = -10.001".format(remove_whitespace(command))),
     )
示例#6
0
def test_mean():
    command = "mean(100, 100, 100)"
    assert mean_(None)(command) == \
        (POST_MESSAGE, block("{} = 100".format(remove_whitespace(command))))
示例#7
0
def test_sum():
    command = "sum(1, 2, 3)"
    assert sum_(None)(command) == \
        (POST_MESSAGE, block("{} = 6".format(remove_whitespace(command))))
示例#8
0
 def test_eval(self):
     result = eval_list_with(command=self.command, **self.kwargs)
     response = \
         block("{} = {}".format(self.command.replace(" ", ""), str(1)))
     assert result == response
示例#9
0
 def test_edt(self):
     time = datetime(2019, 4, 1, 0, 0)
     response = block("here : 12:00:00 AM\nutc  : 04:00:00 AM")
     assert clock(time)(None) == (POST_MESSAGE, response)