def test_basic_stats(self): testlog = MetricLog() for i in range(1, 101): testlog.record(float(i), rospy.Time(float(i))) self.assertEqual(testlog.curr(), 100.0, "Curr val should be (%.2f) and was instead (%.2f)"% (100.0, testlog.curr())) self.assertEqual(testlog.min(), 1.0, "Min val should be (%.2f) and was instead (%.2f)"% (1.0, testlog.min())) self.assertEqual(testlog.max(), 100.0, "Max val should be (%.2f) and was instead (%.2f)"% (100.0, testlog.max())) self.assertEqual(testlog.avg(), 50.5, "Avg val should be (%.2f) and was instead (%.2f)"% (50.5, testlog.avg())) self.assertEqual(testlog.count(), 100, "Count should be (%d) and was instead (%d)"% (100, testlog.count())) self.assertAlmostEqual(testlog.stdev(), 29.0115, 3, "Stdev should be (%.2f) and was instead (%.2f)"% (29.0115, testlog.stdev())) for i in range(101, 201): testlog.record(-float(i), rospy.Time(float(i))) self.assertEqual(testlog.curr(), -200.0, "Curr val should be (%.2f) and was instead (%.2f)"% (-200.0, testlog.curr())) self.assertEqual(testlog.min(), -200.0, "Min val should be (%.2f) and was instead (%.2f)"% (1.0, testlog.min())) self.assertEqual(testlog.max(), 100.0, "Max val should be (%.2f) and was instead (%.2f)"% (100.0, testlog.max())) self.assertEqual(testlog.avg(), -50.0, "Avg val should be (%.2f) and was instead (%.2f)"% (-50.0, testlog.avg())) self.assertEqual(testlog.count(), 200, "Count should be (%d) and was instead (%d)"% (200, testlog.count())) self.assertAlmostEqual(testlog.stdev(), 104.8258, 3, "Stdev should be (%.2f) and was instead (%.2f)"% (104.8258, testlog.stdev()))
def test_basic_stats(self): testlog = MetricLog() for i in range(1, 101): testlog.record(float(i), rospy.Time(float(i))) self.assertEqual( testlog.curr(), 100.0, "Curr val should be (%.2f) and was instead (%.2f)" % (100.0, testlog.curr())) self.assertEqual( testlog.min(), 1.0, "Min val should be (%.2f) and was instead (%.2f)" % (1.0, testlog.min())) self.assertEqual( testlog.max(), 100.0, "Max val should be (%.2f) and was instead (%.2f)" % (100.0, testlog.max())) self.assertEqual( testlog.avg(), 50.5, "Avg val should be (%.2f) and was instead (%.2f)" % (50.5, testlog.avg())) self.assertEqual( testlog.count(), 100, "Count should be (%d) and was instead (%d)" % (100, testlog.count())) self.assertAlmostEqual( testlog.stdev(), 29.0115, 3, "Stdev should be (%.2f) and was instead (%.2f)" % (29.0115, testlog.stdev())) for i in range(101, 201): testlog.record(-float(i), rospy.Time(float(i))) self.assertEqual( testlog.curr(), -200.0, "Curr val should be (%.2f) and was instead (%.2f)" % (-200.0, testlog.curr())) self.assertEqual( testlog.min(), -200.0, "Min val should be (%.2f) and was instead (%.2f)" % (1.0, testlog.min())) self.assertEqual( testlog.max(), 100.0, "Max val should be (%.2f) and was instead (%.2f)" % (100.0, testlog.max())) self.assertEqual( testlog.avg(), -50.0, "Avg val should be (%.2f) and was instead (%.2f)" % (-50.0, testlog.avg())) self.assertEqual( testlog.count(), 200, "Count should be (%d) and was instead (%d)" % (200, testlog.count())) self.assertAlmostEqual( testlog.stdev(), 104.8258, 3, "Stdev should be (%.2f) and was instead (%.2f)" % (104.8258, testlog.stdev()))