def test_Deflection_basicCreation(self): defl = Deflection(Degree(7.0)) self.assertIsNotNone(defl) expected = 7.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Deflection(Degree(359.0)) expected = 359.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Deflection(Degree(361.0)) expected = 1.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Deflection(Degree(-21.0)) expected = -21.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Deflection(Degree(-361.0)) expected = -1.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5)
def test_createAzimuthFromDegree(self): newAz = Azimuth(Degree(45.0)) self.assertTrue(nearlyEqual(newAz.asRadians(), 0.7853981634)) newAz = Azimuth(Degree(356.0)) expected = 6.2133721371 actual = newAz.valu self.assertAlmostEqual(expected, actual, 7)
def test_deflectionGreaterThanPiComplementsToLTpi(self): defl = Deflection(Degree(350.0)) defl = defl.complement360() expected = -10.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Deflection(Degree(-345.0)) self.assertAlmostEqual(defl.asDegreesFloat(), -345.0, 5) defl = defl.complement360() expected = 15.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5)
def test_inputAnglesOutsideNorms(self): az1 = Azimuth(Degree(40.0)) self.assertAlmostEqual(az1.asDegreesFloat(), 40.0, 5) az1 = Azimuth(Degree(270.0)) self.assertAlmostEqual(az1.asDegreesFloat(), 270.0, 5) az1 = Azimuth(Degree(-10.0)) deg = az1.asDegreesFloat() self.assertAlmostEqual(deg, 350.0, 5) az1 = Azimuth(Degree(370.0)) deg = az1.asDegreesFloat() self.assertAlmostEqual(deg, 10.0, 5)
def test_getAsDMS(self): angl_ = Angle(Degree(10, 3, 5)) expected = (10, 3, 5.0) actual = angl_.asDMS() self.assertEqual(expected[0], actual[0]) self.assertEqual(expected[1], actual[1]) self.assertAlmostEqual(actual[2], expected[2], 5)
def test_AzimuthAddition_Deflection(self): az = Azimuth(Degree(2.5)) defl = Angles.deflection.Deflection(Degree(3.5)) newAz = az + defl expected = 6.0 actual = newAz.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = Angles.deflection.Deflection(Degree(-12.0)) newAz = newAz + defl expected = 360.0 - 6.0 actual = newAz.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az = Azimuth(Degree(355.0)) defl = Angles.deflection.Deflection(Degree(12.5)) newAz = az + defl expected = 7.5 actual = newAz.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az = Azimuth(Degree(356)) expected = 6.2133721371 actual = az.valu self.assertAlmostEqual(expected, actual, 7) defl = Angles.deflection.Deflection(Degree(-352.0)) newAz = az + defl expected = 4.0 actual = newAz.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az = Azimuth(Degree(1)) + Angles.deflection.Deflection(Degree(-90)) expected = 271.0 actual = az.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az = Azimuth(0) + Angles.deflection.Deflection(Degree(-90)) expected = 270.0 actual = az.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5)
def test_TrigFunctionsForAzimuth(self): az1 = Azimuth(Degree(10.0)) expected = 0.984807753012 actual = az1.sin() self.assertAlmostEqual(expected, actual, 5) actual = az1.cos() expected = 0.173648177667 self.assertAlmostEqual(expected, actual, 5) actual = az1.tan() expected = 5.67128181962 self.assertAlmostEqual(expected, actual, 5)
def test_createDeflectionBySubtractingTwoAzimuths(self): az1 = Azimuth(Degree(10.0)) az2 = Azimuth(Degree(350.0)) defl = az2 - az1 expected = -20.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az3 = az1 + defl self.assertAlmostEqual(az2.valu, az3.valu, 5) deflComplement = defl.complement360() expected = 340.0 actual = deflComplement.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) defl = az1 - az2 expected = 20.0 actual = defl.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5) az3 = az2 + defl self.assertAlmostEqual(az1.valu, az3.valu, 5) deflComplement = defl.complement360() expected = -340.0 actual = deflComplement.asDegreesFloat() self.assertAlmostEqual(expected, actual, 5)
def test_inputAnglesOutsideNorms(self): angle1 = Angle.factory(Degree(45.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), 45.0)) angle1 = Angle.factory(Degree(180.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), 180.0)) angle1 = Angle.factory(Degree(190.0)) deg = angle1.asDegreesFloat() self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), -170.0)) angle1 = Angle.factory(Degree(350.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), -10.0)) angle1 = Angle.factory(Degree(370.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), 10.0)) angle1 = Angle.factory(Degree(710.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), -10.0)) angle1 = Angle.factory(Degree(-710.0)) self.assertTrue(nearlyEqual(angle1.asDegreesFloat(), 10.0))
def asDMSstring(self): retDeg = Degree.factoryFromRadians(self.valu) return retDeg.asDMSstring()
def __init__(self, name, age, deg, school): self.name = name self.age = age self.degree = Degree(deg, school)
def test_getAsDMSstring(self): deg = Angle(Degree(16, 30, 24)) expected = '16' + degree.degree_sign + " 30' " + '24.0"' actual = deg.asDMSstring() self.assertEqual(expected, actual)