diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index d9bbf3d..2daa629 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -14,7 +14,7 @@ on: jobs: build: - name: Build, run tests & display coverage + name: Build & Test runs-on: ubuntu-latest strategy: fail-fast: false @@ -41,7 +41,9 @@ jobs: - name: Unit testing with pytest run: | python -m pip install pytest - python -m pytest + # Running `pytest` instead of `python -m pytest` is equivalent + # except that the latter will add the current directory to sys.path + pytest - name: Produce the .coverage file run: | python -m pip install coverage diff --git a/pyproject.toml b/pyproject.toml index 55684ae..3102c5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,12 +31,20 @@ dependencies = [ ] [project.urls] -Homepage = "https://github.com/NPodlozhniy/seqabpy" -Issues = "https://npodlozhniy.github.io/posts/sequential-testing/" +Homepage = "https://npodlozhniy.github.io/posts/sequential-testing/" +"Source Code" = "https://github.com/NPodlozhniy/seqabpy" [tool.hatch.version] path = "src/seqabpy/__init__.py" +# config works for pytest >= 7 +# for earlier version you may +# a) set PYTHONPATH=".:src/" +# b) set sys path in tests/__init__.py +# c) run `pip install --editable .` prior to pytest +[tool.pytest.ini_options] +pythonpath = "src/" + [tool.coverage.paths] source = [ "*/src", diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/seqabpy/__init__.py b/src/seqabpy/__init__.py index 22b6f39..4995220 100644 --- a/src/seqabpy/__init__.py +++ b/src/seqabpy/__init__.py @@ -1,6 +1,11 @@ -__version__ = "0.1.1" +__version__ = "0.1.2" import numpy as np from scipy.stats import norm -from src.seqabpy import gatsby, gavi +# np and norm are given to gatsby and gavi via (import *) +from seqabpy import gatsby, gavi + +# once everything is imported, with (from seqabpy import *) +# only gavi and gatsby will be imported +__all__ = ["gatsby", "gavi"] diff --git a/src/seqabpy/gatsby.py b/src/seqabpy/gatsby.py index acb4a22..c7a00ce 100644 --- a/src/seqabpy/gatsby.py +++ b/src/seqabpy/gatsby.py @@ -6,7 +6,7 @@ from scipy.stats import multivariate_normal from statsmodels.sandbox.distributions.extras import mvnormcdf -from src.seqabpy import * +from seqabpy import * def alpha_spending_function( diff --git a/src/seqabpy/gavi.py b/src/seqabpy/gavi.py index 4fb088f..365b435 100644 --- a/src/seqabpy/gavi.py +++ b/src/seqabpy/gavi.py @@ -1,6 +1,6 @@ from scipy.special import gammaln, loggamma, xlogy -from src.seqabpy import * +from seqabpy import * class AlwaysValidInference: diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..f1f93bd --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +import sys + +sys.path.append("src") diff --git a/tests/test_gavi.py b/tests/test_gavi.py index 8760c7e..2f03588 100644 --- a/tests/test_gavi.py +++ b/tests/test_gavi.py @@ -1,6 +1,6 @@ import numpy as np -from src.seqabpy.gavi import * +from seqabpy.gavi import * def test_sequential_p_value(): diff --git a/tests/test_gst.py b/tests/test_gst.py index 80e798d..452c023 100644 --- a/tests/test_gst.py +++ b/tests/test_gst.py @@ -1,6 +1,6 @@ import numpy as np -from src.seqabpy.gatsby import * +from seqabpy.gatsby import * def test_calculate_sequential_bounds(): expected_bounds = (