create base class MeasurementData for ADC_Result and Accumulation

This commit is contained in:
markusro committed 2026-10-20 23:21:43 +02:00
1 parent 5a18e48c2d
commit bd060dc4d0
6 files changed
+184 -47

No files matched your search

+15
View File
@@ -30,6 +30,21 @@ class TestADCResult(unittest.TestCase):
self.assertEqual(len(adc.x), 0)
self.assertEqual(len(adc.y), 0)
def test_shared_measurement_statistics(self):
adc = self.create_adc_result()
np.testing.assert_allclose(adc.get_ymean(), [20, 25])
np.testing.assert_allclose(adc.get_ymin_channels(), [10, 15])
np.testing.assert_allclose(adc.get_ymax_channels(), [30, 35])
np.testing.assert_allclose(adc.get_yrms(),
[np.sqrt(np.mean(np.array([10, 20, 30]) ** 2)),
np.sqrt(np.mean(np.array([15, 25, 35]) ** 2))])
np.testing.assert_allclose(adc.get_ystd(), [np.std([10, 20, 30]),
np.std([15, 25, 35])])
def test_shared_phase_uses_public_channel_values(self):
adc = self.create_adc_result()
self.assertAlmostEqual(adc.get_phase(), np.degrees(np.arctan2(15, 10)))
def test_constructor_with_arguments(self):
"""Test initializer with all arguments."""
x = np.array([0.0, 1.0, 2.0])
+8
View File
@@ -33,6 +33,14 @@ class TestAccumulation(unittest.TestCase):
self.assertEqual(len(accu.x), 0)
self.assertEqual(len(accu.y), 0)
def test_shared_measurement_statistics_use_accumulation_means(self):
accu = Accumulation()
accu += self.create_adc_result()
np.testing.assert_allclose(accu.get_ymean(), [20, 25])
np.testing.assert_allclose(accu.get_ymin_channels(), [10, 15])
np.testing.assert_allclose(accu.get_ymax_channels(), [30, 35])
self.assertAlmostEqual(accu.get_phase(), np.degrees(np.arctan2(15, 10)), places=6)
def test_constructor_with_arguments(self):
"""Test initializer with all arguments."""
x = np.array([0.0, 1.0, 2.0])