Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
dermatologist committed Jun 1, 2020
2 parents 0ed6b49 + fb2e85b commit ecbce92
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ pip install dadpy
from dadpy import DadLoad
from dadpy import DadRead
dl = DadLoad('/path/to/dad/sample/spss/sav/file/', "dad201617c") # version
# with the trailing slash
dl = DadLoad('/path/to/dad/sample/spss/sav/file/') # clin_sample_spss.sav
dr = dad_read(dl.sample)
# records with obesity as pandas df
Expand Down
16 changes: 2 additions & 14 deletions dadpy/dadload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,13 @@ class DadLoad(object):
filepath {str} -- [path to the downloaded files]
version {str} -- [Ex: dad201617c]
"""
def __init__ (self, filepath: str, version: str):
def __init__ (self, filepath: str):

self._filepath = filepath
self._version = version
self.read_sample()

def read_sample(self):
if os.path.exists(self._filepath + "clin_sample_spss.fth"):
self._dfs = pd.read_feather(self._filepath + "clin_sample_spss.fth")
else:
self._dfs = pd.read_spss(self._filepath + "clin_sample_spss.sav")
self._dfs.to_feather(self._filepath + "clin_sample_spss.fth")

def read_full(self):
if os.path.exists(self._filepath + self._version +'.fth'):
self._df = pd.read_feather(self._filepath + self._version +'.fth')
else:
self._df = pd.read_spss(self._filepath + self._version +'.sav')
self._df.to_feather(self._filepath + self._version +'.fth')
self._dfs = pd.read_spss(self._filepath + "clin_sample_spss.sav")

@property
def sample(self):
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "dadpy"
version = "0.1.0"
description = "The swiss army knife of discharge abstract database"
version = "1.0.0"
description = "The swiss army knife for discharge abstract database"
authors = ["Bell Eapen <github_public@gulfdoctor.net>"]

readme = 'README.md' # Markdown files are supported
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dadload.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def dad_fixture():
return DadLoad

def test_load_sample(dad_fixture, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
print(dl.sample.head(5))
assert dl is not None

def test_load_count(dad_fixture, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
print(dl.count)
assert dl.count > 100
10 changes: 5 additions & 5 deletions tests/test_dadread.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ def dad_read():
return DadRead

def test_read_diagnosis(dad_fixture, dad_read, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
dr = dad_read(dl.sample)
print(dr.has_diagnosis('E66')) # Obesity
assert dr.count(dr.has_diagnosis('E66')) > 100

def test_read_treatment(dad_fixture, dad_read, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
dr = dad_read(dl.sample)
print(dr.has_treatment('1NF80')) # Partial gastrectomy for repair of gastric diverticulum
assert dr.count(dr.has_treatment('1NF80')) > 10

def test_read_comorbidity(dad_fixture, dad_read, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
dr = dad_read(dl.sample)
print(dr.comorbidity('E66')) # Obesity

def test_read_interventions(dad_fixture, dad_read, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
dr = dad_read(dl.sample)
print(dr.interventions('1NF80')) # Partial gastrectomy for repair of gastric diverticulum

def test_read_vector(dad_fixture, dad_read, capsys):
dl = dad_fixture(os.getenv("DAD_PATH"), "dad201617c")
dl = dad_fixture(os.getenv("DAD_PATH"))
dr = dad_read(dl.sample)
print(dr.vector(dr.has_diagnosis('E66'), include_treatments=True)) # Obesity

0 comments on commit ecbce92

Please sign in to comment.