From 5627a73a678f80be95fe39b4c5ad67c385d56282 Mon Sep 17 00:00:00 2001 From: kaguillera Date: Wed, 17 Jun 2020 16:23:00 -0400 Subject: [PATCH] Added testing for screen features (android) --- tests/Snakefile | 5 ++++ .../processed/test01/screen_afternoon.csv | 2 ++ tests/data/processed/test01/screen_daily.csv | 2 ++ tests/data/processed/test01/screen_deltas.csv | 8 +++++ .../data/processed/test01/screen_evening.csv | 2 ++ .../data/processed/test01/screen_morning.csv | 2 ++ tests/data/processed/test01/screen_night.csv | 2 ++ tests/data/raw/test01/screen_raw.csv | 29 +++++++++++++++++++ tests/scripts/run_tests.sh | 11 ++++++- tests/settings/config.yaml | 2 +- tests/settings/testing_config.yaml | 8 ++++- 11 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 tests/data/processed/test01/screen_afternoon.csv create mode 100644 tests/data/processed/test01/screen_daily.csv create mode 100644 tests/data/processed/test01/screen_deltas.csv create mode 100644 tests/data/processed/test01/screen_evening.csv create mode 100644 tests/data/processed/test01/screen_morning.csv create mode 100644 tests/data/processed/test01/screen_night.csv create mode 100644 tests/data/raw/test01/screen_raw.csv diff --git a/tests/Snakefile b/tests/Snakefile index 148f8c35..31925dfb 100644 --- a/tests/Snakefile +++ b/tests/Snakefile @@ -10,6 +10,8 @@ rule all: input: expand("data/raw/{pid}/{sensor}_raw.csv", pid=config["PIDS"], sensor=config["SENSORS"]), expand("data/raw/{pid}/{sensor}_with_datetime.csv", pid=config["PIDS"], sensor=config["SENSORS"]), + expand("data/processed/{pid}/screen_deltas.csv", pid=config["PIDS"]), + expand("data/interim/{pid}/phone_sensed_bins.csv", pid=config["PIDS"]), expand("data/processed/{pid}/sms_{sms_type}_{day_segment}.csv", pid=config["PIDS"], sms_type = config["SMS"]["TYPES"], @@ -18,6 +20,9 @@ rule all: pid=config["PIDS"], call_type=config["CALLS"]["TYPES"], segment = config["CALLS"]["DAY_SEGMENTS"]), + expand("data/processed/{pid}/screen_{day_segment}.csv", + pid = config["PIDS"], + day_segment = config["SCREEN"]["DAY_SEGMENTS"]), rule clean: shell: diff --git a/tests/data/processed/test01/screen_afternoon.csv b/tests/data/processed/test01/screen_afternoon.csv new file mode 100644 index 00000000..2d50887a --- /dev/null +++ b/tests/data/processed/test01/screen_afternoon.csv @@ -0,0 +1,2 @@ +local_date,screen_afternoon_countepisodeunlock,screen_afternoon_episodepersensedminutesunlock,screen_afternoon_sumdurationunlock,screen_afternoon_maxdurationunlock,screen_afternoon_mindurationunlock,screen_afternoon_avgdurationunlock,screen_afternoon_stddurationunlock,screen_afternoon_firstuseafter00unlock +2020-06-01,3,0.06,30.08298333333333,12.55,8.533333333333333,10.02766111111111,2.1968176781889985,43200 diff --git a/tests/data/processed/test01/screen_daily.csv b/tests/data/processed/test01/screen_daily.csv new file mode 100644 index 00000000..284ded93 --- /dev/null +++ b/tests/data/processed/test01/screen_daily.csv @@ -0,0 +1,2 @@ +local_date,screen_daily_countepisodeunlock,screen_daily_episodepersensedminutesunlock,screen_daily_sumdurationunlock,screen_daily_maxdurationunlock,screen_daily_mindurationunlock,screen_daily_avgdurationunlock,screen_daily_stddurationunlock,screen_daily_firstuseafter00unlock +2020-06-01,7,0.04,94.60658333333333,21.6598833333333,5.9910166666666695,13.51522619047619,6.19241804679586,10230 diff --git a/tests/data/processed/test01/screen_deltas.csv b/tests/data/processed/test01/screen_deltas.csv new file mode 100644 index 00000000..c4d8eb2e --- /dev/null +++ b/tests/data/processed/test01/screen_deltas.csv @@ -0,0 +1,8 @@ +"episode_id","episode","screen_sequence","time_diff","local_start_date_time","local_end_date_time","local_start_date","local_end_date","local_start_day_segment","local_end_day_segment" +3,"unlock","3, 0",5.99101666666667,"2020-06-01 02:50:30","2020-06-01 02:56:30","2020-06-01","2020-06-01","night","night" +7,"unlock","3, 0",6.99016666666667,"2020-06-01 05:56:51","2020-06-01 06:03:51","2020-06-01","2020-06-01","night","morning" +11,"unlock","3, 0",21.6598833333333,"2020-06-01 10:00:24","2020-06-01 10:22:04","2020-06-01","2020-06-01","morning","morning" +15,"unlock","3, 0",14.9953833333333,"2020-06-01 11:57:33","2020-06-01 12:12:33","2020-06-01","2020-06-01","morning","afternoon" +19,"unlock","3, 0",8.99965,"2020-06-01 14:51:02","2020-06-01 15:00:02","2020-06-01","2020-06-01","afternoon","afternoon" +23,"unlock","3, 0",16.9834166666667,"2020-06-01 17:51:27","2020-06-01 18:08:26","2020-06-01","2020-06-01","afternoon","evening" +27,"unlock","3, 0",18.9870666666667,"2020-06-01 20:42:58","2020-06-01 21:01:58","2020-06-01","2020-06-01","evening","evening" diff --git a/tests/data/processed/test01/screen_evening.csv b/tests/data/processed/test01/screen_evening.csv new file mode 100644 index 00000000..e30db407 --- /dev/null +++ b/tests/data/processed/test01/screen_evening.csv @@ -0,0 +1,2 @@ +local_date,screen_evening_countepisodeunlock,screen_evening_episodepersensedminutesunlock,screen_evening_sumdurationunlock,screen_evening_maxdurationunlock,screen_evening_mindurationunlock,screen_evening_avgdurationunlock,screen_evening_stddurationunlock,screen_evening_firstuseafter00unlock +2020-06-01,2,0.044444444444444446,27.420400000000033,18.9870666666667,8.433333333333334,13.710200000000016,7.462616406834528,64800 diff --git a/tests/data/processed/test01/screen_morning.csv b/tests/data/processed/test01/screen_morning.csv new file mode 100644 index 00000000..3a31f715 --- /dev/null +++ b/tests/data/processed/test01/screen_morning.csv @@ -0,0 +1,2 @@ +local_date,screen_morning_countepisodeunlock,screen_morning_episodepersensedminutesunlock,screen_morning_sumdurationunlock,screen_morning_maxdurationunlock,screen_morning_mindurationunlock,screen_morning_avgdurationunlock,screen_morning_stddurationunlock,screen_morning_firstuseafter00unlock +2020-06-01,3,0.06666666666666667,27.943216666666636,21.6598833333333,2.433333333333333,9.314405555555545,10.714935943920263,21600 diff --git a/tests/data/processed/test01/screen_night.csv b/tests/data/processed/test01/screen_night.csv new file mode 100644 index 00000000..4f3f518b --- /dev/null +++ b/tests/data/processed/test01/screen_night.csv @@ -0,0 +1,2 @@ +local_date,screen_night_countepisodeunlock,screen_night_episodepersensedminutesunlock,screen_night_sumdurationunlock,screen_night_maxdurationunlock,screen_night_mindurationunlock,screen_night_avgdurationunlock,screen_night_stddurationunlock,screen_night_firstuseafter00unlock +2020-06-01,2,0.05714285714285714,9.124350000000003,5.9910166666666695,3.1333333333333333,4.562175000000002,2.0206872634837794,10230 diff --git a/tests/data/raw/test01/screen_raw.csv b/tests/data/raw/test01/screen_raw.csv new file mode 100644 index 00000000..bfd17562 --- /dev/null +++ b/tests/data/raw/test01/screen_raw.csv @@ -0,0 +1,29 @@ +timestamp,device_id,screen_status +1590994230386,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1590994230688,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1590994590149,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1590994590775,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591005411491,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591005411795,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591005831205,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591005831699,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591020022531,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591020024938,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591021324531,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591021324957,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591027053231,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591027053831,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591027953554,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591027953954,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591037462155,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591037462512,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591038002491,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591038002938,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591048286712,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591048287050,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591049306055,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591049306405,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 +1591058578480,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,1 +1591058578811,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,3 +1591059718035,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,0 +1591059718492,wYESbVwI-4GfR-G5I6-7iKL-tOmCKs02MBun,2 \ No newline at end of file diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh index 62e7c67a..2619794f 100755 --- a/tests/scripts/run_tests.sh +++ b/tests/scripts/run_tests.sh @@ -1,9 +1,18 @@ #!/bin/bash # Commmands necessary to setup and run the tests for RAPIDS +echo Setting up for testing... + +echo Copying files... cp -r tests/data/raw/* data/raw -cp tests/data/external/* data/external +cp tests/data/external/* data/external + +echo Disabling downloading of dataset... sed -e '10,20 s/^/#/' -e 's/rules.download_dataset.output/"data\/raw\/\{pid\}\/\{sensor\}_raw\.csv"/' rules/preprocessing.snakefile > tmp cp tmp rules/preprocessing.snakefile + +echo Disabling downloading of dataset... snakemake --profile tests/settings + +echo Running tests on data produced... python -m unittest discover tests/scripts/ -v \ No newline at end of file diff --git a/tests/settings/config.yaml b/tests/settings/config.yaml index e4c2207e..5906bb65 100644 --- a/tests/settings/config.yaml +++ b/tests/settings/config.yaml @@ -2,4 +2,4 @@ directory: ./ configfile: ./tests/settings/testing_config.yaml snakefile: ./tests/Snakefile cores: 1 -forcerun: [sms_features, call_features] +forcerun: [sms_features, call_features, screen_features] diff --git a/tests/settings/testing_config.yaml b/tests/settings/testing_config.yaml index e05bbecc..86532e59 100644 --- a/tests/settings/testing_config.yaml +++ b/tests/settings/testing_config.yaml @@ -1,5 +1,5 @@ # Valid database table name -SENSORS: [messages, calls] +SENSORS: [messages, calls, screen] # Test Participant data to include in the unit testing # You must create a file for each participant @@ -26,3 +26,9 @@ CALLS: incoming: [count, distinctcontacts, meanduration, sumduration, minduration, maxduration, stdduration, modeduration, entropyduration, timefirstcall, timelastcall, countmostfrequentcontact] outgoing: [count, distinctcontacts, meanduration, sumduration, minduration, maxduration, stdduration, modeduration, entropyduration, timefirstcall, timelastcall, countmostfrequentcontact] DAY_SEGMENTS: *day_segments + +SCREEN: + DAY_SEGMENTS: *day_segments + REFERENCE_HOUR_FIRST_USE: 0 + FEATURES_DELTAS: ["countepisode", "episodepersensedminutes", "sumduration", "maxduration", "minduration", "avgduration", "stdduration", "firstuseafter"] + EPISODE_TYPES: ["unlock"]