[WIP] Fix tests to use pyprojroot.

rapids
junos 2021-10-29 12:07:12 +02:00
parent a63a7eac99
commit 005b09cfdf
4 changed files with 11 additions and 6 deletions

View File

@ -9,7 +9,7 @@ from pyprojroot import here
import participants.query_db import participants.query_db
from features import esm from features import esm
from machine_learning import QUESTIONNAIRE_IDS, QUESTIONNAIRE_IDS_RENAME from machine_learning import QUESTIONNAIRE_IDS, QUESTIONNAIRE_IDS_RENAME
from machine_learning.helper import to_csv_with_settings, read_csv_with_settings from machine_learning.helper import read_csv_with_settings, to_csv_with_settings
WARNING_PARTICIPANTS_LABEL = ( WARNING_PARTICIPANTS_LABEL = (
"Before aggregating labels, please set participants label using self.set_participants_label() " "Before aggregating labels, please set participants label using self.set_participants_label() "
@ -88,7 +88,7 @@ class Labels:
self.folder, self.folder,
self.filename_prefix, self.filename_prefix,
data_type="_".join(self.questionnaires), data_type="_".join(self.questionnaires),
grouping_variable=self.grouping_variable grouping_variable=self.grouping_variable,
) )
print("Read labels from the file.") print("Read labels from the file.")
except FileNotFoundError: except FileNotFoundError:

View File

@ -1,6 +1,7 @@
import unittest import unittest
from pandas.testing import assert_series_equal from pandas.testing import assert_series_equal
from pyprojroot import here
from features.esm import * from features.esm import *
from features.esm_JCQ import * from features.esm_JCQ import *
@ -9,7 +10,7 @@ from features.esm_JCQ import *
class EsmFeatures(unittest.TestCase): class EsmFeatures(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls) -> None: def setUpClass(cls) -> None:
cls.esm = pd.read_csv("../data/example_esm.csv", sep=";") cls.esm = pd.read_csv(here("data/example_esm.csv"), sep=";")
cls.esm["esm_json"] = cls.esm["esm_json"].apply(eval) cls.esm["esm_json"] = cls.esm["esm_json"].apply(eval)
cls.esm_processed = preprocess_esm(cls.esm) cls.esm_processed = preprocess_esm(cls.esm)
cls.esm_clean = clean_up_esm(cls.esm_processed) cls.esm_clean = clean_up_esm(cls.esm_processed)

View File

@ -18,7 +18,9 @@ class SensorFeaturesTest(unittest.TestCase):
self.assertIsInstance(sensor_features_params, dict) self.assertIsInstance(sensor_features_params, dict)
self.assertIsInstance(sensor_features_params.get("grouping_variable"), str) self.assertIsInstance(sensor_features_params.get("grouping_variable"), str)
self.assertIsInstance(sensor_features_params.get("features"), dict) self.assertIsInstance(sensor_features_params.get("features"), dict)
self.assertIsInstance(sensor_features_params.get("participants_usernames"), list) self.assertIsInstance(
sensor_features_params.get("participants_usernames"), list
)
def test_participants_label(self): def test_participants_label(self):
sensor_features = SensorFeatures(**self.sensor_features_params) sensor_features = SensorFeatures(**self.sensor_features_params)

View File

@ -1,5 +1,7 @@
import unittest import unittest
from pyprojroot import here
from features.proximity import * from features.proximity import *
@ -10,7 +12,7 @@ class ProximityFeatures(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls) -> None: def setUpClass(cls) -> None:
cls.df_proximity = pd.read_csv("../data/example_proximity.csv") cls.df_proximity = pd.read_csv(here("data/example_proximity.csv"))
cls.df_proximity["participant_id"] = 99 cls.df_proximity["participant_id"] = 99
def test_recode_proximity(self): def test_recode_proximity(self):