Skip to content

Commit

Permalink
Update data processing tests, refs #35
Browse files Browse the repository at this point in the history
  • Loading branch information
Meredith Anderson committed Apr 30, 2021
1 parent 3480b77 commit c1d59e7
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions tests/test_processdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

class DataTestCase(unittest.TestCase):
def setUp(self):
self.df = pd.read_csv("growthviz-data/sample-adults-cleaned.csv")
self.df = pd.read_csv("growthviz-data/sample-adults-data.csv")

def test_setup_individual_obs(self):
setup_df = processdata.setup_individual_obs_df(self.df, "adults")
setup_df = processdata.setup_individual_obs_df(self.df)
self.assertEqual(
set(
[
Expand All @@ -19,7 +19,6 @@ def test_setup_individual_obs(self):
"age",
"sex",
"clean_value",
"reason",
"clean_cat",
"include",
]
Expand All @@ -28,23 +27,23 @@ def test_setup_individual_obs(self):
)

def test_keep_age_range(self):
setup_df = processdata.setup_individual_obs_df(self.df, "adults")
setup_df = processdata.setup_individual_obs_df(self.df)
keep_df = processdata.keep_age_range(setup_df, "adults")
self.assertTrue(len(setup_df) >= len(keep_df))

def setup_keep_merge(self, df, mode):
setup_df = processdata.setup_individual_obs_df(df, mode)
keep_df = processdata.keep_age_range(setup_df, mode)
merge_df = processdata.setup_merged_df(keep_df, mode)
def setup_keep_merge(self, df):
setup_df = processdata.setup_individual_obs_df(df)
keep_df = processdata.keep_age_range(setup_df, "adults")
merge_df = processdata.setup_merged_df(keep_df)
return merge_df

def test_no_nans(self):
merge_df = self.setup_keep_merge(self.df, "adults")
merge_df = self.setup_keep_merge(self.df)
self.assertEqual(0, merge_df["age"].isnull().sum())
self.assertEqual(0, merge_df["sex"].isnull().sum())

def test_cols(self):
merge_df = self.setup_keep_merge(self.df, "adults")
merge_df = self.setup_keep_merge(self.df)
self.assertEqual(
set(
[
Expand All @@ -55,7 +54,6 @@ def test_cols(self):
"height_cat",
"include_height",
"height",
"reason",
"weight_cat",
"include_weight",
"weight",
Expand All @@ -68,7 +66,7 @@ def test_cols(self):
)

def test_sex(self):
merge_df = self.setup_keep_merge(self.df, "adults")
merge_df = self.setup_keep_merge(self.df)
self.assertTrue(merge_df["sex"].isin([0, 1]).all())


Expand Down

0 comments on commit c1d59e7

Please sign in to comment.