summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-08-13 16:36:09 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-08-13 16:36:09 +0200
commit882a9b84a7ab9a1c2b53a272ba1380547088ea3d (patch)
tree3facd75e4b2acf8ad64d81108bd12263ffc704e2
parented64ef760b95600e8df4c7d6916671bcd7ed359e (diff)
add fit tests for AnalyticModel
-rw-r--r--.gitlab-ci.yml2
-rwxr-xr-xtest/test_timingharness.py29
2 files changed, 19 insertions, 12 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4d0c3ae..3ff619b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -17,5 +17,5 @@ test:
- wget -qO test-data/20170116_145420_sharpLS013B4DN.tar https://lib.finalrewind.org/energy-models/20170116_145420_sharpLS013B4DN.tar
- wget -qO test-data/20170116_151348_sharpLS013B4DN.tar https://lib.finalrewind.org/energy-models/20170116_151348_sharpLS013B4DN.tar
- wget -qO test-data/20170220_164723_RF24_int_A.tar https://lib.finalrewind.org/energy-models/20170220_164723_RF24_int_A.tar
- - wget -qO test-data/20190724_161440_nRF24_no-rx.json https://lib.finalrewind.org/energy-models/20190724_161440_nRF24_no-rx.json
+ - wget -qO test-data/20190726_150423_nRF24_no-rx.json https://lib.finalrewind.org/energy-models/20190726_150423_nRF24_no-rx.json
- PYTHONPATH=lib pytest-3
diff --git a/test/test_timingharness.py b/test/test_timingharness.py
index 5cc8dae..ac19a29 100755
--- a/test/test_timingharness.py
+++ b/test/test_timingharness.py
@@ -5,23 +5,30 @@ import unittest
class TestModels(unittest.TestCase):
def test_model_singlefile_rf24(self):
- raw_data = TimingData(['test-data/20190724_161440_nRF24_no-rx.json'])
+ raw_data = TimingData(['test-data/20190726_150423_nRF24_no-rx.json'])
preprocessed_data = raw_data.get_preprocessed_data(verbose = False)
by_name, parameters, arg_count = pta_trace_to_aggregate(preprocessed_data)
- model = AnalyticModel(by_name, parameters, verbose = False)
- self.assertEqual(model.names, 'setAutoAck setPALevel setRetries setup startListening stopListening write'.split(' '))
+ model = AnalyticModel(by_name, parameters, arg_count, verbose = False)
+ self.assertEqual(model.names, 'setPALevel setRetries setup write'.split(' '))
static_model = model.get_static()
- self.assertAlmostEqual(static_model('setAutoAck', 'duration'), 72, places=0)
- self.assertAlmostEqual(static_model('setPALevel', 'duration'), 145, places=0)
- self.assertAlmostEqual(static_model('setRetries', 'duration'), 72, places=0)
- self.assertAlmostEqual(static_model('setup', 'duration'), 6464, places=0)
- self.assertAlmostEqual(static_model('startListening', 'duration'), 455, places=0)
- self.assertAlmostEqual(static_model('stopListening', 'duration'), 487, places=0)
- self.assertAlmostEqual(static_model('write', 'duration'), 5877, places=0)
+ self.assertAlmostEqual(static_model('setPALevel', 'duration'), 146, places=0)
+ self.assertAlmostEqual(static_model('setRetries', 'duration'), 73, places=0)
+ self.assertAlmostEqual(static_model('setup', 'duration'), 6533, places=0)
+ self.assertAlmostEqual(static_model('write', 'duration'), 12400, places=0)
- for transition in 'setAutoAck setPALevel setRetries setup startListening stopListening'.split(' '):
+ for transition in 'setPALevel setRetries setup write'.split(' '):
self.assertAlmostEqual(model.stats.param_dependence_ratio(transition, 'duration', 'channel'), 0, places=2)
+ param_model, param_info = model.get_fitted()
+ self.assertEqual(param_info('setPALevel', 'duration'), None)
+ self.assertEqual(param_info('setRetries', 'duration'), None)
+ self.assertEqual(param_info('setup', 'duration'), None)
+ self.assertEqual(param_info('write', 'duration')['function']._model_str, '0 + regression_arg(0) + regression_arg(1) * parameter(max_retry_count) + regression_arg(2) * parameter(retry_delay) + regression_arg(3) * parameter(max_retry_count) * parameter(retry_delay)')
+
+ self.assertAlmostEqual(param_info('write', 'duration')['function']._regression_args[0], 1016, places=0)
+ self.assertAlmostEqual(param_info('write', 'duration')['function']._regression_args[1], 464, places=0)
+ self.assertAlmostEqual(param_info('write', 'duration')['function']._regression_args[2], 1, places=0)
+ self.assertAlmostEqual(param_info('write', 'duration')['function']._regression_args[3], 1, places=0)
if __name__ == '__main__':
unittest.main()