summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-02-26 10:54:04 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-02-26 10:54:49 +0100
commit21698b9915f02216a1afa5afb36b56f65f30b8ca (patch)
treecbd37997cb43adfcd897e2126508c5983b883b89 /test
parent2be86e1d7cccb6f2b0daaa5c69c95796537b47c1 (diff)
add more complex decisiontree test
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_ptamodel.py605
1 files changed, 586 insertions, 19 deletions
diff --git a/test/test_ptamodel.py b/test/test_ptamodel.py
index dad4328..55f84b8 100755
--- a/test/test_ptamodel.py
+++ b/test/test_ptamodel.py
@@ -790,37 +790,604 @@ class TestFromFile(unittest.TestCase):
places=0,
)
- """
- param_model, param_info = model.get_fitted()
- self.assertEqual(param_info("POWERDOWN", "power"), None)
+ def test_decisiontrees_more_rf24(self):
+ raw_data = RawData(["test-data/20191024-150723-nrf24l01.tar"])
+ preprocessed_data = raw_data.get_preprocessed_data()
+ by_name, parameters, arg_count = pta_trace_to_aggregate(preprocessed_data)
+ model = PTAModel(by_name, parameters, arg_count)
+ self.assertEqual(model.states(), "STANDBY1".split(" "))
self.assertEqual(
- param_info("RX", "power")["function"].model_function,
- "0 + regression_arg(0) + regression_arg(1) * np.sqrt(parameter(datarate))",
+ model.transitions(),
+ "setAutoAck setPALevel setRetries setup write".split(" "),
)
+ static_model = model.get_static()
+ self.assertAlmostEqual(static_model("STANDBY1", "power"), 130, places=0)
+ self.assertAlmostEqual(static_model("setAutoAck", "power"), 150, places=0)
+ self.assertAlmostEqual(static_model("setPALevel", "power"), 150, places=0)
+ self.assertAlmostEqual(static_model("setRetries", "power"), 150, places=0)
+ self.assertAlmostEqual(static_model("setup", "power"), 156, places=0)
+ self.assertAlmostEqual(static_model("write", "power"), 14247, places=0)
+
+ self.assertAlmostEqual(static_model("setAutoAck", "duration"), 90, places=0)
+ self.assertAlmostEqual(static_model("setPALevel", "duration"), 160, places=0)
+ self.assertAlmostEqual(static_model("setRetries", "duration"), 90, places=0)
+ self.assertAlmostEqual(static_model("setup", "duration"), 6550, places=0)
+ self.assertAlmostEqual(static_model("write", "duration"), 1245, places=0)
+
self.assertAlmostEqual(
- param_info("RX", "power")["function"].model_args[0], 48530.7, places=0
+ model.attr_by_name["write"]["duration"].stats.param_dependence_ratio(
+ "auto_ack!"
+ ),
+ 1,
+ places=2,
)
self.assertAlmostEqual(
- param_info("RX", "power")["function"].model_args[1], 117, places=0
+ model.attr_by_name["write"]["duration"].stats.param_dependence_ratio(
+ "max_retry_count"
+ ),
+ 1,
+ places=2,
)
- self.assertEqual(param_info("STANDBY1", "power"), None)
- self.assertEqual(
- param_info("TX", "power")["function"].model_function,
- "0 + regression_arg(0) + regression_arg(1) * 1/(parameter(datarate)) + regression_arg(2) * parameter(txpower) + regression_arg(3) * 1/(parameter(datarate)) * parameter(txpower)",
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["duration"].stats.param_dependence_ratio(
+ "retry_delay"
+ ),
+ 1,
+ places=2,
)
- self.assertEqual(
- param_info("epilogue", "timeout")["function"].model_function,
- "0 + regression_arg(0) + regression_arg(1) * 1/(parameter(datarate))",
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["duration"].stats.param_dependence_ratio(
+ "tx_power"
+ ),
+ 0.36,
+ places=2,
)
- self.assertEqual(
- param_info("stopListening", "duration")["function"].model_function,
- "0 + regression_arg(0) + regression_arg(1) * 1/(parameter(datarate))",
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["power"].stats.param_dependence_ratio(
+ "auto_ack!"
+ ),
+ 1,
+ places=2,
+ )
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["power"].stats.param_dependence_ratio(
+ "max_retry_count"
+ ),
+ 0.98,
+ places=2,
+ )
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["power"].stats.param_dependence_ratio(
+ "retry_delay"
+ ),
+ 1,
+ places=2,
+ )
+ self.assertAlmostEqual(
+ model.attr_by_name["write"]["power"].stats.param_dependence_ratio(
+ "tx_power"
+ ),
+ 1,
+ places=2,
)
+ param_model, param_info = model.get_fitted()
+
+ # auto_ack! == 0 -> max_retry_count and retry_delay have no effect on duraton
+
self.assertAlmostEqual(
- param_model("RX", "power", param=[1, None, None]), 48647, places=-1
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1150,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1150,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1150,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 15,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1150,
+ places=0,
+ )
+
+ # auto_ack! == 1 -> max_retry_count and retry_delay affect duration, tx_power does not
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1425,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 1425,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 4982,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 16,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 4982,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 19982,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "duration",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 15,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 19982,
+ places=0,
+ )
+
+ # auto_ack! == 0 -> max_retry_count and retry_delay have no effect on power, txpower does
+
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 12989,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 20055,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 12989,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 20055,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 12989,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 0,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 20055,
+ places=0,
+ )
+
+ # auto_ack! == 1 -> max_retry_count and retry_delay also affect power
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 17255,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 0,
+ None,
+ None,
+ 250,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 23074,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 26633,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 250,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 35656,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 0,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 7964,
+ places=0,
+ )
+ self.assertAlmostEqual(
+ param_model(
+ "write",
+ "power",
+ param=[
+ 1,
+ None,
+ 1000,
+ None,
+ 5,
+ None,
+ None,
+ 2750,
+ 12,
+ None,
+ None,
+ None,
+ None,
+ ],
+ ),
+ 10400,
+ places=0,
)
- """
def test_singlefile_mmparam(self):
raw_data = RawData(["test-data/20161221_123347_mmparam.tar"])