Skip to content

Commit

Permalink
change package to src layout; fixed warning messages from changes in …
Browse files Browse the repository at this point in the history
…pandas
  • Loading branch information
jarathomas committed Apr 3, 2024
1 parent 82ab851 commit 18b4143
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
# os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v1
Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include README.md
include LICENSE
include interva/data/*.csv
include interva/data/*.xls
include interva/data/*.py
include src/interva/data/*.csv
include src/interva/data/*.xls
include src/interva/data/*.py
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "interva"
version = "0.0.7"
authors = [
{name = "Sherry Zhao", email = "[email protected]"},
{name = "Jason Thomas", email = "[email protected]"},
]
maintainers = [
{name = "Jason Thomas", email = "[email protected]"},
]
description = "Python implementation of the InterVA Algorithm."
readme = "README.md"
requires-python = ">=3.8"
keywords = ["verbal autopsy",]
license = {text = "GPLv3"}
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
]
dependencies = [
"pandas",
"numpy",
"vacheck",
"xlrd",
]

[project.urls]
"Homepage" = "https://github.com/verbal-autopsy-software/interva"
"Bug Tracker" = "https://github.com/verbal-autopsy-software/interva/issues"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
"interva.data" = ["*.csv"]

[tool.pytest.ini_options]
addopts = [
"--import-mode=importlib",
]

48 changes: 2 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,3 @@
import os
from codecs import open
from setuptools import setup, find_namespace_packages
from setuptools import setup

here = os.path.abspath(os.path.dirname(__file__))

about = {}
with open(os.path.join(here, "interva", "__version__.py"), "r", "utf-8") as f:
exec(f.read(), about)

with open("README.md", "r", "utf-8") as f:
readme = f.read()


setup(
name=about["__title__"],
version=about["__version__"],
author=about["__author__"],
author_email=about["__author_email__"],
description=about["__description__"],
long_description=readme,
long_description_content_type="text/markdown",
url=about["__url__"],
license=about["__license__"],
packages=find_namespace_packages(),
include_package_data=True,
package_dir={"": "."},
package_data={
"interva.data": ["*.csv", "*.xls"],
},
install_requires=[
"pandas",
"xlrd",
"numpy",
"vacheck",
],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
],
)
setup()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions interva/interva5.py → src/interva/interva5.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def run(self) -> None:
comcat = "Multiple"
comnum = " "
if nanmax(prob_C) >= 0.5:
comcat = prob_C_names[where(prob_C == nanmax(prob_C))[0][0]]
comcat = prob_C_names.iloc[where(prob_C == nanmax(prob_C))[0][0]]
comnum = round(nanmax(prob_C) * 100)

ID_list[i] = index_current
Expand Down Expand Up @@ -827,11 +827,11 @@ def get_csmf(self, top: int = 10,
dist_cod_sorted.sort_values(ascending=False, inplace=True)
# show causes with top non-zero values
show_top = 0
while dist_cod_sorted[show_top] > 0 and show_top < top:
while dist_cod_sorted.iloc[show_top] > 0 and show_top < top:
show_top = show_top + 1
if show_top == top:
a = dist_cod_sorted[show_top]
b = dist_cod_sorted[show_top-1]
a = dist_cod_sorted.iloc[show_top]
b = dist_cod_sorted.iloc[show_top-1]
while show_top < len(dist_cod_sorted) and \
(abs(a-b) < (a+b) * 1e-5):
show_top = show_top + 1
Expand Down
10 changes: 5 additions & 5 deletions interva/utils.py → src/interva/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ def csmf(iva5: interva.interva5.InterVA5,

# show causes with top non-zero values
show_top = 0
while dist_cod[show_top] > 0 and show_top < top:
while dist_cod.iloc[show_top] > 0 and show_top < top:
show_top = show_top + 1
if show_top == top:
a = dist_cod[show_top]
b = dist_cod[show_top - 1]
a = dist_cod.iloc[show_top]
b = dist_cod.iloc[show_top - 1]
while show_top < len(dist_cod) and (abs(a - b) < (a + b) * 1e-5):
show_top = show_top + 1
a = dist_cod[show_top]
b = dist_cod[show_top - 1]
a = dist_cod.iloc[show_top]
b = dist_cod.iloc[show_top - 1]
top_csmf = dist_cod.head(show_top)

return top_csmf
Expand Down
8 changes: 4 additions & 4 deletions tests/test_compare_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_r_va5_comparison():
for i in range(r_prob_check.shape[0]):
for j in range(r_prob_check.shape[1]):
a = round(r_prob_check.iloc[i, j], 10)
b = round(py_prob_check[i][j], 10)
b = round(py_prob_check.iloc[i].iloc[j], 10)
assert a == b


Expand All @@ -67,7 +67,7 @@ def test_r_csmf_top15_comparison():
r_csmf_top15 = r_csmf_top15_check.to_numpy()
for i in range(len(r_csmf_top15_check)):
a = round(float(py_csmf_top15[i]), 10)
b = round(float(r_csmf_top15[i]), 10)
b = round(float(r_csmf_top15[i][0]), 10)
assert a == b


Expand All @@ -80,7 +80,7 @@ def tests_utils_csmf_1():
r_csmf5_1_top15 = r_csmf5_1_top15.to_numpy()
for i in range(len(r_csmf5_1_top15)):
a = round(float(py_csmf5_1_top15[i]), 10)
b = round(float(r_csmf5_1_top15[i]), 10)
b = round(float(r_csmf5_1_top15[i][0]), 10)
assert a == b


Expand All @@ -93,5 +93,5 @@ def tests_utils_csmf_2():
r_csmf5_2_top15 = r_csmf5_2_top15.to_numpy()
for i in range(len(r_csmf5_2_top15)):
a = round(float(py_csmf5_2_top15[i]), 4)
b = round(float(r_csmf5_2_top15[i]), 4)
b = round(float(r_csmf5_2_top15[i][0]), 4)
assert a == b
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

def make_age_test_data(age_group, yes, no):
sex_groups = Series({"ID": "d1", "i019a": "y", "i019b": "n"})
age_groups = Series({f"i022{i}": no for i in age_letters})
age_groups = Series({f"i022{i}": no for i in age_letters}).astype(object)
age_groups[age_group] = yes
va_record = concat([sex_groups, age_groups])
age_all, age = all_age_groups[age_group]
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37, py38, py39, py310, py311
envlist = py38, py38, py39, py310, py311, py312

[testenv]
deps =
Expand Down

0 comments on commit 18b4143

Please sign in to comment.