Skip to content

Commit 33591cb

Browse files
authored
Merge pull request #39 from mitre/t23-package-reorg
Reorganized package
2 parents 04e8689 + 781a2d0 commit 33591cb

19 files changed

+662
-568
lines changed

.gitignore

+10-1
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,13 @@ dmypy.json
135135
.pytype/
136136

137137
# Cython debug symbols
138-
cython_debug/
138+
cython_debug/
139+
140+
# VSCode environment
141+
.history
142+
.vscode
143+
144+
# Other local additions
145+
*.swo
146+
*.swp
147+
.DS_Store

GrowthViz-adults.ipynb

+211-173
Large diffs are not rendered by default.

GrowthViz-adults.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@
2828
# In[1]:
2929

3030

31-
import pandas as pd
32-
import numpy as np
3331
import matplotlib.pyplot as plt
3432
import matplotlib as mpl
33+
import numpy as np
34+
import pandas as pd
35+
import seaborn as sns
36+
3537
from ipywidgets import interact, interactive, fixed, interact_manual
3638
import ipywidgets as widgets
37-
import seaborn as sns
3839
from IPython.display import FileLink, FileLinks
3940
import qgrid
4041

@@ -76,11 +77,11 @@
7677
# In[6]:
7778

7879

79-
import processdata
80-
import sumstats
81-
import charts
82-
import compare
83-
import check_data
80+
from growthviz import charts
81+
from growthviz import check_data
82+
from growthviz import compare
83+
from growthviz import processdata
84+
from growthviz import sumstats
8485

8586

8687
# This cell reads in a data set that has been run through the [growthcleanr](https://github.com/carriedaymont/growthcleanr) algorithm. Details of the algorithm can be found in [Automated identification of implausible values in growth data from pediatric electronic health records](https://academic.oup.com/jamia/article/24/6/1080/3767271)
@@ -169,7 +170,7 @@
169170

170171

171172
# adult percentiles
172-
percentiles = pd.read_csv("vdsmeasures.csv", encoding ='latin1')
173+
percentiles = pd.read_csv("growthviz-data/ext/vdsmeasures.csv", encoding ='latin1')
173174
percentiles_clean = processdata.setup_percentiles_adults(percentiles)
174175

175176
# save out smoothed percentiles
@@ -527,9 +528,3 @@ def on_button_clicked(b):
527528

528529

529530
# In addition, users can take advantage of all of the plotting capabilities of [Matplotlib](https://matplotlib.org/3.1.1/tutorials/index.html) and [Seaborn](https://seaborn.pydata.org/tutorial.html)
530-
531-
# In[ ]:
532-
533-
534-
535-

GrowthViz-pediatrics.ipynb

+387-337
Large diffs are not rendered by default.

GrowthViz-pediatrics.py

+8-19
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
# In[1]:
2929

3030

31+
import matplotlib.pyplot as plt
3132
import pandas as pd
3233
import numpy as np
33-
import matplotlib.pyplot as plt
34+
import seaborn as sns
35+
3436
from ipywidgets import interact, interactive, fixed, interact_manual
3537
import ipywidgets as widgets
36-
import seaborn as sns
3738
from IPython.display import FileLink, FileLinks
3839
import qgrid
3940

@@ -75,11 +76,11 @@
7576
# In[6]:
7677

7778

78-
import processdata
79-
import sumstats
80-
import charts
81-
import compare
82-
import check_data
79+
from growthviz import charts
80+
from growthviz import check_data
81+
from growthviz import compare
82+
from growthviz import processdata
83+
from growthviz import sumstats
8384

8485

8586
# This cell reads in a data set that has been run through the [growthcleanr](https://github.com/carriedaymont/growthcleanr) algorithm. Details of the algorithm can be found in [Automated identification of implausible values in growth data from pediatric electronic health records](https://academic.oup.com/jamia/article/24/6/1080/3767271)
@@ -556,15 +557,3 @@ def on_button_clicked(b):
556557

557558
compare.subject_stats_comparison(combined)
558559

559-
560-
# In[ ]:
561-
562-
563-
564-
565-
566-
# In[ ]:
567-
568-
569-
570-

check_setup.py

100644100755
+17-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python
2+
13
import os
24
import sys
35

@@ -24,19 +26,23 @@ def check_for_file(file_name, not_found_message):
2426

2527
# Check for the function library
2628
check_for_file(
27-
"processdata.py", "Unable to find data processing library functions for GrowthViz."
29+
"growthviz/charts.py",
30+
"Unable to find visualization library functions for GrowthViz.",
2831
)
2932
check_for_file(
30-
"sumstats.py", "Unable to find summary statistics library functions for GrowthViz."
33+
"growthviz/check_data.py",
34+
"Unable to find data checks library functions for GrowthViz.",
3135
)
3236
check_for_file(
33-
"charts.py", "Unable to find visualization library functions for GrowthViz."
37+
"growthviz/compare.py", "Unable to find comparison library functions for GrowthViz."
3438
)
3539
check_for_file(
36-
"compare.py", "Unable to find comparison library functions for GrowthViz."
40+
"growthviz/processdata.py",
41+
"Unable to find data processing library functions for GrowthViz.",
3742
)
3843
check_for_file(
39-
"check_data.py", "Unable to find data checks library functions for GrowthViz."
44+
"growthviz/sumstats.py",
45+
"Unable to find summary statistics library functions for GrowthViz.",
4046
)
4147

4248
# Check for tests
@@ -51,17 +57,19 @@ def check_for_file(file_name, not_found_message):
5157

5258
# Check for the CDC growth charts
5359
check_for_file(
54-
"bmiagerev.csv", "Unable to find pediatric CDC growth charts for BMI at age."
60+
"growthviz-data/ext/bmiagerev.csv",
61+
"Unable to find pediatric CDC growth charts for BMI at age.",
5562
)
5663
check_for_file(
57-
"statage.csv",
64+
"growthviz-data/ext/statage.csv",
5865
"Unable to find pediatric CDC growth charts for height / stature at age.",
5966
)
6067
check_for_file(
61-
"wtage.csv", "Unable to find pediatric CDC growth charts for weight at age."
68+
"growthviz-data/ext/wtage.csv",
69+
"Unable to find pediatric CDC growth charts for weight at age.",
6270
)
6371
check_for_file(
64-
"vdsmeasures.csv",
72+
"growthviz-data/ext/vdsmeasures.csv",
6573
"Unable to find CDC growth charts for adult weight, height and BMI.",
6674
)
6775

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

growthviz/__init__.py

Whitespace-only changes.

charts.py growthviz/charts.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import numpy as np
21
import math
2+
33
import matplotlib.pyplot as plt
4+
import numpy as np
45

56

67
def weight_distr(df, mode):

check_data.py growthviz/check_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pandas as pd
21
import numpy as np
2+
import pandas as pd
33

44

55
def check_patient_data(file):

compare.py growthviz/compare.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pandas as pd
21
import numpy as np
2+
import pandas as pd
33

44

55
def prepare_for_comparison(frame_dict):

processdata.py growthviz/processdata.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import pandas as pd
2-
import numpy as np
3-
import matplotlib.pyplot as plt
4-
import matplotlib as mpl
51
from IPython.display import FileLinks
2+
import matplotlib as mpl
3+
import matplotlib.pyplot as plt
4+
import numpy as np
5+
import pandas as pd
66

77

88
def setup_individual_obs_df(obs_df):
@@ -95,7 +95,7 @@ def setup_percentiles_pediatrics(percentiles_file):
9595
Processes pediatrics percentiles from CDC
9696
"""
9797
percentiles = pd.read_csv(
98-
percentiles_file,
98+
f'growthviz-data/ext/{percentiles_file}',
9999
dtype={
100100
"Agemos": float,
101101
"P5": float,

sumstats.py growthviz/sumstats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import numpy as np
21
from IPython.display import Markdown
2+
import numpy as np
33

44

55
def setup_percentile_zscore_adults(percentiles_clean):

tests/test_processdata.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
2+
23
import pandas as pd
3-
import processdata
4+
5+
from growthviz import processdata
46

57

68
class DataTestCase(unittest.TestCase):
@@ -72,7 +74,7 @@ def test_sex(self):
7274

7375
class PctAdultTestCase(unittest.TestCase):
7476
def setUp(self):
75-
self.df = pd.read_csv("vdsmeasures.csv", encoding="latin1")
77+
self.df = pd.read_csv("growthviz-data/ext/vdsmeasures.csv", encoding="latin1")
7678

7779
def test_vdsmeasures_data(self):
7880
self.assertEqual(0, self.df["Number of examined persons"].isnull().sum())

tests/test_sumstats.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import unittest
2+
23
import pandas as pd
3-
import processdata
4-
import sumstats
4+
5+
from growthviz import processdata
6+
from growthviz import sumstats
57

68

79
class StatAdultTestCase(unittest.TestCase):
810
def setUp(self):
9-
self.df = pd.read_csv("vdsmeasures.csv")
11+
self.df = pd.read_csv("growthviz-data/ext/vdsmeasures.csv")
1012

1113
def test_setup_percentiles_adults(self):
1214
setup_df = processdata.setup_percentiles_adults(self.df)

0 commit comments

Comments
 (0)