def test_get_2nd_order_adjustment(self): points = [ grapoint(_rave.RaveValueType_DATA, 1.0, 0.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 1.0, 10.0, 20.0, "20131010", "101500", 1.0, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 2.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12) ] self.classUnderTest = gra.gra(points) result = self.classUnderTest.get_2nd_order_adjustment() self.assertEqual(6, len(result)) self.assertAlmostEqual( 1.0, result[0], 4) # The following 3 are from least square 2nd degree self.assertAlmostEqual(-2.0, result[1], 4) self.assertAlmostEqual(1.0, result[2], 4) self.assertAlmostEqual(0.6667, result[3], 4) # The std deviation self.assertAlmostEqual(0.4714, result[4], 4) self.assertEqual( 0, result[5] ) # This is the difference between provided points and used points, should be 0 in this case
def test_get_correlation_2(self): points = [ grapoint(_rave.RaveValueType_DATA, 1.0, 0.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 1.0, 10.0, 20.0, "20131010", "101500", 1.0, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 0.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12) ] self.classUnderTest = gra.gra(points) self.assertAlmostEqual(-1.0, self.classUnderTest.get_correlation(), 2)
def test_get_std_deviation(self): points = [ grapoint(_rave.RaveValueType_DATA, 1.0, 0.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 1.0, 10.0, 20.0, "20131010", "101500", 1.0, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 2.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12) ] self.classUnderTest = gra.gra(points) result = self.classUnderTest.get_std_deviation() self.assertEqual(2, len(result)) self.assertAlmostEqual(0.6667, result[0], 4) self.assertAlmostEqual(0.4714, result[1], 4)
def test_least_square_nth_degree(self): points = [ grapoint(_rave.RaveValueType_DATA, 1.0, 0.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 1.0, 10.0, 20.0, "20131010", "101500", 1.0, 12), grapoint(_rave.RaveValueType_DATA, 1.0, 2.0, 10.0, 20.0, "20131010", "101500", 10**0.1, 12) ] self.classUnderTest = gra.gra(points) result = self.classUnderTest.least_square_nth_degree(2) self.assertEqual(3, len(result)) self.assertAlmostEqual(1.0, result[0], 4) self.assertAlmostEqual(-2.0, result[1], 4) self.assertAlmostEqual(1.0, result[2], 4)