-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatureBuilderTest.py
More file actions
59 lines (51 loc) · 2.74 KB
/
featureBuilderTest.py
File metadata and controls
59 lines (51 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import unittest
from dataStore import DataStore
import featureBuilder
import responseBuilder
import start
__author__ = 'alexander'
class FeatureBuilderTest(unittest.TestCase):
def setUp(self):
self.app = start.harApp
start.harApp.config['TESTING'] = True
start.harApp.config['DATABASE'] = 'test.db'
def testBuildHandAccXFeature(self):
with start.harApp.test_request_context(""):
start.set_app_db()
# raw_data = {(activity_id, 10*activity_id) for activity_id in PROTOCOL_ACTIVITIES}
raw_data = { activity_id: DataStore().randomRawSamples(activity_id, 500, 3) for activity_id in responseBuilder.PROTOCOL_ACTIVITIES[2:5]}
handAccXFeature = featureBuilder.FeatureBuilder().rawFeature(raw_data, "handAccX")
for activity in handAccXFeature:
self.assertEqual(len(activity['values']), 1500)
def testBuildAllFeatures(self):
with start.harApp.test_request_context(""):
start.set_app_db()
raw_data = { activity_id: DataStore().randomRawSamples(activity_id, 500, 3) for activity_id in responseBuilder.PROTOCOL_ACTIVITIES[2:5]}
all_features = featureBuilder.FeatureBuilder().buildRawFeaturesForKeys(raw_data, ['handAccX', 'heartrate', 'chestGyrX'])
count = len(all_features)
def testMaximum(self):
with start.harApp.test_request_context(""):
start.set_app_db()
raw_data = { activity_id: DataStore().randomRawSamples(activity_id, 500, 4) for activity_id in responseBuilder.PROTOCOL_ACTIVITIES[5:7]}
maximums = featureBuilder.FeatureBuilder().maximum(raw_data, 'chestAccY')
count = len(maximums)
def testTwoWay(self):
with start.harApp.test_request_context(""):
start.set_app_db()
raw_data = { activity_id: DataStore().randomRawSamples(activity_id, 500, 4) for activity_id in responseBuilder.PROTOCOL_ACTIVITIES[5:7]}
maxChestAccX = featureBuilder.FeatureBuilder().maximum(raw_data, 'chestAccX')
maxHandAccX = featureBuilder.FeatureBuilder().maximum(raw_data, 'handAccX')
twoWay = featureBuilder.FeatureBuilder().twoWayCompare(maxHandAccX, maxChestAccX)
count = len(twoWay)
def testDft(self):
with start.harApp.test_request_context(""):
start.set_app_db()
raw_data = {activity_id: DataStore().randomRawSamples(activity_id, 500, 4) for activity_id in
responseBuilder.PROTOCOL_ACTIVITIES[5:7]}
dftResult = [
{
'feature_name': 'dft',
'data': featureBuilder.FeatureBuilder().dft(raw_data, 'chestAccX')
}
, ]
print dftResult