added tests for Accumulation and ADC_Result
This commit is contained in:
@@ -18,6 +18,7 @@ class TestADCResult(unittest.TestCase):
|
||||
sampl_freq = 1000.0
|
||||
job_id = 11
|
||||
adc = ADC_Result(x, y, index, sampl_freq, desc, job_id, job_date)
|
||||
adc.set_nChannels(2)
|
||||
return adc
|
||||
|
||||
def test_constructor_with_no_arguments(self):
|
||||
@@ -162,37 +163,37 @@ class TestADCResult(unittest.TestCase):
|
||||
y = adc.y
|
||||
# test integer addition
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i]+10, y[i] + 10))
|
||||
np.testing.assert_array_equal(adc.y[i]+10, y[i] + 10, strict=True)
|
||||
adc += 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] + 10))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] + 10, strict=True)
|
||||
|
||||
# test float addition
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i] + 10., y[i] + 10.))
|
||||
np.testing.assert_array_equal(adc.y[i] + 10., y[i] + 10., strict=True)
|
||||
adc += 10.
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] + 10 + 10.))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] + 10 + 10., strict=True)
|
||||
|
||||
def test_operator_sub_scalar(self):
|
||||
"""
|
||||
Test the functionality of __sub__ and __rsub__
|
||||
"""
|
||||
adc = self.create_adc_result()
|
||||
y = adc.y[0][1]=5
|
||||
y = adc.y
|
||||
# test integer subtraction
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i] - 10, y[i] - 10))
|
||||
np.testing.assert_array_equal(adc.y[i] - 10, y[i] - 10, strict=True)
|
||||
adc -= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] - 10))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] - 10, strict=True)
|
||||
|
||||
# test float subtraction
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i] - 10., y[i] - 10.))
|
||||
np.testing.assert_array_equal(adc.y[i] - 10., y[i] - 10., strict=True)
|
||||
adc -= 10.
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] - 10 - 10.))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] - 10 - 10., strict=True)
|
||||
|
||||
def test_operator_mul_scalar(self):
|
||||
"""
|
||||
@@ -203,17 +204,17 @@ class TestADCResult(unittest.TestCase):
|
||||
y = adc.y
|
||||
# test integer multiplication
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i] * 10, y[i] * 10))
|
||||
np.testing.assert_array_equal(adc.y[i] * 10, y[i] * 10, strict=True)
|
||||
adc *= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] * 10))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] * 10, strict=True)
|
||||
|
||||
# test float multiplication
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i] * 10.0, y[i] * 10.0))
|
||||
np.testing.assert_array_equal(adc.y[i] * 10.0, y[i] * 10.0, strict=True)
|
||||
adc *= 10.0
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] * 10 * 10.0))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] * 10 * 10.0, strict=True)
|
||||
|
||||
def test_operator_truediv_scalar(self):
|
||||
"""
|
||||
@@ -222,10 +223,10 @@ class TestADCResult(unittest.TestCase):
|
||||
adc = self.create_adc_result()
|
||||
y = adc.y
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i]/10, y[i] / 10))
|
||||
np.testing.assert_array_equal(adc.y[i]/10, y[i] / 10, strict=True)
|
||||
adc /= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] / 10))
|
||||
np.testing.assert_array_equal(adc.y[i], y[i] / 10, strict=True)
|
||||
|
||||
def test_operator_floordiv_scalar(self):
|
||||
"""
|
||||
@@ -234,10 +235,10 @@ class TestADCResult(unittest.TestCase):
|
||||
adc = self.create_adc_result()
|
||||
y = adc.y
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i]//10, y[i] // 10))
|
||||
np.testing.assert_array_equal(adc.y[i]//10, y[i] // 10, strict=True)
|
||||
adc //= 10
|
||||
for i in range(adc.get_nChannels()):
|
||||
self.assertIsNone(np.testing.assert_array_equal(adc.y[i], y[i] // 10))
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user