Fix formatting.
parent
ed0b013801
commit
7aeb40d674
|
@ -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