forked from UW-Madison-ACI/simplestats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_stats.py
67 lines (51 loc) · 1.23 KB
/
test_stats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from nose.tools import assert_equal, assert_almost_equal, assert_true, \
assert_false, assert_raises, assert_is_instance
from stats import mean, mode, std, var#, median
def test_mean1():
obs = mean([0, 0, 0, 0])
exp = 0
assert_equal(obs, exp)
obs = mean([0, 200])
exp = 100
assert_equal(obs, exp)
obs = mean([0, -200])
exp = -100
assert_equal(obs, exp)
obs = mean([0])
exp = 0
assert_equal(obs, exp)
def test_floating_mean1():
obs = mean([1, 2])
exp = 1.5
assert_equal(obs, exp)
# FIXME Put Median tests here
# FIXME Put Mode tests here
def test_std1():
obs = std([0.0, 2.0])
exp = 1.0
assert_equal(obs, exp)
def test_std2():
obs = std([])
exp = 0.0
assert_equal(obs, exp)
def test_std3():
obs = std([0.0, 4.0])
exp = 2.0
assert_equal(obs, exp)
def test_std4():
obs = std([1.0, 3.0])
exp = 1.0
assert_equal(obs, exp)
def test_std5():
obs = std([1.0, 1.0, 1.0])
exp = 0.0
assert_equal(obs, exp)
def test_std6():
obs = std([1e500])
exp = NotImplemented
assert_equal(obs, exp)
def test_std7():
obs = std([0.0, 1e4242])
exp = NotImplemented
assert_equal(obs, exp)
# FIXME Put Variance tests here