summaryrefslogtreecommitdiffstats
path: root/tests/utilities_tests/data_treatment_test.py
diff options
context:
space:
mode:
authorTim Rault <tim.rault@cengn.ca>2016-07-15 16:32:51 -0400
committerTim Rault <tim.rault@cengn.ca>2016-07-15 16:41:16 -0400
commitaa20b986cebf031489f4280988b4574a9acbc647 (patch)
tree354c6b521d83735a1be29183b447d3b35bf320ac /tests/utilities_tests/data_treatment_test.py
parent2227414bd57f4b7f5f275d915fa8f6a2aa21f8f7 (diff)
Add Steady State Detection module
Added a Steady State Detection module containing a steady_state(data_series) function that is able to return a boolean indicating wether or not steady state is reached with the data_series being passed. This module requires a data_treatment(data_series) and an average(data_series) modules that have been added in this commit as well. The data treatment function aims at formatting the data series that is passed to the high level steady_state function to reach the requirement of each sub-module (slope, average and range). Modified the Slope and Range functions so they return None when passed an empty data series instead of 0 which was wrong. Modified the corresponding test cases. Modified the math_range_test.py file to fix a bug in the 2 last tests. Change-Id: I9c3854cb0a21cc37b0787b8afca0821eefaa203d JIRA: STORPERF-60 JIRA: STORPERF-59 JIRA: STORPERF-61 JIRA: STORPERF-62 Signed-off-by: Tim Rault <tim.rault@cengn.ca>
Diffstat (limited to 'tests/utilities_tests/data_treatment_test.py')
-rw-r--r--tests/utilities_tests/data_treatment_test.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/utilities_tests/data_treatment_test.py b/tests/utilities_tests/data_treatment_test.py
new file mode 100644
index 0000000..4450f92
--- /dev/null
+++ b/tests/utilities_tests/data_treatment_test.py
@@ -0,0 +1,81 @@
+##############################################################################
+# Copyright (c) 2016 CENGN and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+import unittest
+from storperf.utilities import data_treatment as DataTreatment
+
+
+class DataTreatmentTest(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+
+ def test_empty_series(self):
+ expected = {
+ 'slope_data': [],
+ 'range_data': [],
+ 'average_data': []
+ }
+ data_series = []
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_integer_series(self):
+ expected = {
+ 'slope_data': [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]],
+ 'range_data': [5, 2, 98, 669, 66],
+ 'average_data': [5, 2, 98, 669, 66]
+ }
+ data_series = [[1, 5], [66, 2], [12, 98], [74, 669], [33, 66]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_series(self):
+ expected = {
+ 'slope_data': [[5.6, 12.7], [96.66, 78.212],
+ [639.568, 5.3], [4.65, 6.667]],
+ 'range_data': [12.7, 78.212, 5.3, 6.667],
+ 'average_data': [12.7, 78.212, 5.3, 6.667]
+ }
+ data_series = [
+ [5.6, 12.7], [96.66, 78.212], [639.568, 5.3], [4.65, 6.667]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_float_int_mix(self):
+ expected = {
+ 'slope_data': [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]],
+ 'range_data': [12.7, 7, 5.3, 6],
+ 'average_data': [12.7, 7, 5.3, 6]
+ }
+ data_series = [[5, 12.7], [96.66, 7], [639.568, 5.3], [4, 6]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_negative_values(self):
+ expected = {
+ 'slope_data': [[-15, 5.56], [41.3, -278], [41.3, -98],
+ [78.336, -0.12], [33.667, 66]],
+ 'range_data': [5.56, -278, -98, -0.12, 66],
+ 'average_data': [5.56, -278, -98, -0.12, 66]
+ }
+ data_series = [
+ [-15, 5.56], [41.3, -278], [41.3, -98],
+ [78.336, -0.12], [33.667, 66]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)
+
+ def test_single_value(self):
+ expected = {
+ 'slope_data': [[86.8, 65.36]],
+ 'range_data': [65.36],
+ 'average_data': [65.36]
+ }
+ data_series = [[86.8, 65.36]]
+ actual = DataTreatment.data_treatment(data_series)
+ self.assertEqual(expected, actual)