Fix formatting.
parent
ed0b013801
commit
7aeb40d674
|
@ -49,4 +49,4 @@ def time_screen_sequence(df_screen: pd.DataFrame) -> pd.DataFrame:
|
||||||
# For example, from the two main sequences outlined above, the time of "real" phone usage can be calculated,
|
# For example, from the two main sequences outlined above, the time of "real" phone usage can be calculated,
|
||||||
# i.e. how long the screen was unlocked.
|
# i.e. how long the screen was unlocked.
|
||||||
# Another example might be the average time between screen unlocks and/or screen status checks.
|
# Another example might be the average time between screen unlocks and/or screen status checks.
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -19,14 +19,24 @@ class EsmFeatures(unittest.TestCase):
|
||||||
self.assertIn("question_id", self.esm_processed)
|
self.assertIn("question_id", self.esm_processed)
|
||||||
|
|
||||||
def test_classify_sessions_by_completion(self):
|
def test_classify_sessions_by_completion(self):
|
||||||
self.esm_classified_sessions = classify_sessions_by_completion(self.esm_processed)
|
self.esm_classified_sessions = classify_sessions_by_completion(
|
||||||
|
self.esm_processed
|
||||||
|
)
|
||||||
self.assertFalse(self.esm_classified_sessions["session_response"].isna().any())
|
self.assertFalse(self.esm_classified_sessions["session_response"].isna().any())
|
||||||
# Test that all sessions were indeed classified.
|
# Test that all sessions were indeed classified.
|
||||||
|
|
||||||
def test_classify_sessions_by_completion_time(self):
|
def test_classify_sessions_by_completion_time(self):
|
||||||
self.esm_classified = classify_sessions_by_completion_time(self.esm_processed)
|
self.esm_classified = classify_sessions_by_completion_time(self.esm_processed)
|
||||||
session_of_interest = self.esm_processed.query("(device_id == '049df3f8-8541-4cf5-af2b-83f6b3f0cf4b') & (esm_session == 1)").sort_values("_id").reset_index()
|
session_of_interest = (
|
||||||
session_of_interest_reclassified = self.esm_classified.query("(device_id == '049df3f8-8541-4cf5-af2b-83f6b3f0cf4b') & (esm_session == 1)").reset_index()
|
self.esm_processed.query(
|
||||||
|
"(device_id == '049df3f8-8541-4cf5-af2b-83f6b3f0cf4b') & (esm_session == 1)"
|
||||||
|
)
|
||||||
|
.sort_values("_id")
|
||||||
|
.reset_index()
|
||||||
|
)
|
||||||
|
session_of_interest_reclassified = self.esm_classified.query(
|
||||||
|
"(device_id == '049df3f8-8541-4cf5-af2b-83f6b3f0cf4b') & (esm_session == 1)"
|
||||||
|
).reset_index()
|
||||||
self.assertEqual(session_of_interest.loc[0, "time"], "morning")
|
self.assertEqual(session_of_interest.loc[0, "time"], "morning")
|
||||||
self.assertEqual(session_of_interest_reclassified.loc[0, "time"], "daytime")
|
self.assertEqual(session_of_interest_reclassified.loc[0, "time"], "daytime")
|
||||||
# Check that the first (morning) session is reclassified as a daytime session.
|
# Check that the first (morning) session is reclassified as a daytime session.
|
||||||
|
@ -38,10 +48,30 @@ class EsmFeatures(unittest.TestCase):
|
||||||
def test_reverse_jcq_demand_control_scoring(self):
|
def test_reverse_jcq_demand_control_scoring(self):
|
||||||
esm_reversed = reverse_jcq_demand_control_scoring(self.esm_clean)
|
esm_reversed = reverse_jcq_demand_control_scoring(self.esm_clean)
|
||||||
|
|
||||||
self.assertEqual(0, int(self.esm_clean.loc[self.esm_clean["question_id"] == 73, "esm_user_answer_numeric"]))
|
self.assertEqual(
|
||||||
self.assertEqual(1, int(esm_reversed.loc[esm_reversed["question_id"] == 73, "esm_user_score"]))
|
0,
|
||||||
|
int(
|
||||||
|
self.esm_clean.loc[
|
||||||
|
self.esm_clean["question_id"] == 73, "esm_user_answer_numeric"
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
1,
|
||||||
|
int(esm_reversed.loc[esm_reversed["question_id"] == 73, "esm_user_score"]),
|
||||||
|
)
|
||||||
# An example of a regular item: the score gets incremented by 1, to shift to 1-4 scoring.
|
# An example of a regular item: the score gets incremented by 1, to shift to 1-4 scoring.
|
||||||
|
|
||||||
self.assertEqual(0, int(self.esm_clean.loc[self.esm_clean["question_id"] == 79, "esm_user_answer_numeric"]))
|
self.assertEqual(
|
||||||
self.assertEqual(4, int(esm_reversed.loc[esm_reversed["question_id"] == 79, "esm_user_score"]))
|
0,
|
||||||
|
int(
|
||||||
|
self.esm_clean.loc[
|
||||||
|
self.esm_clean["question_id"] == 79, "esm_user_answer_numeric"
|
||||||
|
]
|
||||||
|
),
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
4,
|
||||||
|
int(esm_reversed.loc[esm_reversed["question_id"] == 79, "esm_user_score"]),
|
||||||
|
)
|
||||||
# An example of a reversed item.
|
# An example of a reversed item.
|
||||||
|
|
Loading…
Reference in New Issue