Debian Codegraph @

tests/test_coverup_4.py

raw symbols SCIP
1 # file scalene/runningstats.py:32-49
2 # lines [32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 49]
3 # branches ['34->35', '34->36']
4
5 import pytest
6 from scalene.runningstats import RunningStats
7
8
9 @pytest.fixture
10 def running_stats():
11 return RunningStats()
12
13
14 def test_push(running_stats):
15 # Push a value and check if the peak is updated
16 running_stats.push(10.0)
17 assert running_stats._peak == 10.0
18 assert running_stats._n == 1
19 assert running_stats._m1 == 10.0
20 assert running_stats._m2 == 0.0
21 assert running_stats._m3 == 0.0
22 assert running_stats._m4 == 0.0
23
24 # Push another value and check if the statistics are updated correctly
25 running_stats.push(20.0)
26 assert running_stats._peak == 20.0
27 assert running_stats._n == 2
28 assert running_stats._m1 == 15.0
29 # The exact values for _m2, _m3, and _m4 depend on the internal calculations
30 # and are not asserted here for simplicity. In a real test, these should be
31 # calculated and asserted as well.
32
33 # Push a smaller value and check if the peak remains the same
34 running_stats.push(5.0)
35 assert running_stats._peak == 20.0
36 assert running_stats._n == 3
37 # Again, the exact values for _m1, _m2, _m3, and _m4 should be asserted.