class TestRFToolsDatapoint(unittest.TestCase): def setUp(self): self.dp = Datapoint(100000, 0.1091, 0.3118) self.dp0 = Datapoint(100000, 0, 0) self.dp50 = Datapoint(100000, 1, 0) self.dp75 = Datapoint(100000, 0.2, 0) self.dp_im50 = Datapoint(100000, 0, 1) def test_properties(self): self.assertEqual(self.dp.z, complex(0.1091, 0.3118)) self.assertAlmostEqual(self.dp.phase, 1.23420722) self.assertEqual(self.dp0.gain, -math.inf) self.assertAlmostEqual(self.dp.gain, -9.6208748) self.assertEqual(self.dp50.vswr, 1.0) self.assertAlmostEqual(self.dp.vswr, 1.9865736) self.assertAlmostEqual(self.dp.impedance(), complex(49.997525, 34.9974501)) self.assertAlmostEqual(self.dp.impedance(75), complex(74.99628755, 52.49617517)) self.assertEqual(self.dp0.qFactor(), 0.0) self.assertEqual(self.dp75.qFactor(), 0.0) self.assertEqual(self.dp_im50.qFactor(), -1.0) self.assertAlmostEqual(self.dp.qFactor(), 0.6999837) self.assertAlmostEqual(self.dp.capacitiveEquivalent(), -4.54761539e-08) self.assertAlmostEqual(self.dp.inductiveEquivalent(), 5.57001e-05)
def getYPosition(self, d: Datapoint) -> int: return (self.topMargin + round( (self.maxValue - d.inductiveEquivalent()) / self.span * self.chartHeight))