These were not too critical errors as we normal only do + and -
operations in the experiments. - Identified and fixed multiple logic and syntax errors in the `Accumulation` class similar to those recently found in `ADC_Result`. - Implemented missing arithmetic operators (`*`, `/`, `//`) and their inplace/reverse counterparts for the `Accumulation` class. - Verified that all arithmetic operations correctly maintain statistical data (sum of squares) where mathematically possible.
This commit is contained in:
+14
-13
@@ -233,7 +233,6 @@ class TestAccumulation(unittest.TestCase):
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(accu.y[i], y[i] - 10 - 10.)
|
||||
|
||||
@unittest.skip("Not implmented")
|
||||
def test_operator_mul_scalar(self):
|
||||
"""
|
||||
Test the functionality of __mul and __rmul__
|
||||
@@ -254,33 +253,35 @@ class TestAccumulation(unittest.TestCase):
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(accu.y[i], y[i] * 10 * 10.0)
|
||||
|
||||
@unittest.skip("Not implmented")
|
||||
def test_operator_truediv_scalar(self):
|
||||
"""
|
||||
Test the functionality of __div__ and __rdiv__
|
||||
Test the functionality of __truediv__ and __itruediv__
|
||||
"""
|
||||
adc = self.create_adc_result()
|
||||
y = adc.y
|
||||
accu = Accumulation()
|
||||
accu += adc
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(adc.y[i]/10, y[i] / 10, strict=True)
|
||||
adc /= 10
|
||||
np.testing.assert_array_equal(accu.y[i]/10, y[i] / 10)
|
||||
accu /= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] / 10, strict=True)
|
||||
np.testing.assert_array_equal(accu.y[i], y[i] / 10)
|
||||
|
||||
@unittest.skip("Not implmented")
|
||||
def test_operator_floordiv_scalar(self):
|
||||
"""
|
||||
Test the functionality of __div__ and __rdiv__
|
||||
Test the functionality of __floordiv__ and __ifloordiv__
|
||||
"""
|
||||
adc = self.create_adc_result()
|
||||
y = adc.y
|
||||
accu = Accumulation()
|
||||
accu += adc
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(adc.y[i]//10, y[i] // 10, strict=True)
|
||||
adc //= 10
|
||||
np.testing.assert_array_equal(accu.y[i]//10, y[i] // 10)
|
||||
accu //= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] // 10, strict=True)
|
||||
self.assertRaises(ValueError, adc.__floordiv__, 1.0)
|
||||
self.assertRaises(ValueError, adc.__rfloordiv__, 1.0)
|
||||
np.testing.assert_array_equal(accu.y[i], y[i] // 10)
|
||||
self.assertRaises(ValueError, accu.__floordiv__, 1.0)
|
||||
self.assertRaises(ValueError, accu.__ifloordiv__, 1.0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user