コード例 #1
0
 def test_running_mean(self):
     sb = StatBook('test_sb')
     ms = MultiStat(name='test_stat')
     ms.running_mean = MagicMock()
     ms.running_mean.return_value = [3., 4., 5.]
     sb.add_multi_stat(ms)
     result = sb.running_mean(ms.name)
     self.assertListEqual(result, [3., 4., 5.])
     ms.running_mean.assert_called_once()
コード例 #2
0
 def test_running_mean(self):
     ms = MultiStat('test_ms')
     ms.add_raw_value_stat(lambda x: x)
     ms.stats.get(ms.RAW_VALUE_STAT_NAME).record(1)
     ms.stats.get(ms.RAW_VALUE_STAT_NAME).record(2)
     ms.stats.get(ms.RAW_VALUE_STAT_NAME).record(3)
     ms.stats.get(ms.RAW_VALUE_STAT_NAME).record([5, 7, 0])
     ms.stats.get(ms.RAW_VALUE_STAT_NAME).record([40, 0, 5, 5, 5, 5])
     self.assertListEqual(ms.running_mean(), [1., 1.5, 2., 2.5, 4.])