diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 661fb3f..a9ffd27 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -10,30 +10,24 @@ on: branches: [ master ] jobs: - build: - + uv-example: + name: python runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.6, 3.7, 3.8] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pytest + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: "Set up Python" + uses: actions/setup-python@v5 + with: + python-version-file: "pyproject.toml" + + - name: Install the project + run: uv sync --all-extras --dev + + - name: Run tests + # For example, using `pytest` + run: uv run pytest tests diff --git a/README.md b/README.md index 5643f5f..695bb42 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Simple SIR simulation ```python from epimodels.continuous.models import SIR + model = SIR() model([1000, 1, 0], [0, 50], 1001, {'beta': 2, 'gamma': .1}) model.plot_traces() diff --git a/docs/Examples/Continuous_models.ipynb b/docs/Examples/Continuous_models.ipynb index ba77d99..0af13b8 100644 --- a/docs/Examples/Continuous_models.ipynb +++ b/docs/Examples/Continuous_models.ipynb @@ -17,7 +17,8 @@ }, "outputs": [], "source": [ - "import epimodels.continuous.models as CM" + "\n", + "import epimodels as CM" ] }, { diff --git a/src/epimodels/__init__.py b/epimodels/__init__.py similarity index 100% rename from src/epimodels/__init__.py rename to epimodels/__init__.py diff --git a/src/epimodels/discrete/__init__.py b/epimodels/continuous/__init__.py similarity index 70% rename from src/epimodels/discrete/__init__.py rename to epimodels/continuous/__init__.py index d689cde..e7a8400 100644 --- a/src/epimodels/discrete/__init__.py +++ b/epimodels/continuous/__init__.py @@ -1,6 +1,6 @@ -u""" +""" Created on 29/10/18 by fccoelho license: GPL V3 or Later """ - +from .models import * diff --git a/src/epimodels/continuous/models.py b/epimodels/continuous/models.py similarity index 100% rename from src/epimodels/continuous/models.py rename to epimodels/continuous/models.py diff --git a/src/epimodels/continuous/__init__.py b/epimodels/discrete/__init__.py similarity index 75% rename from src/epimodels/continuous/__init__.py rename to epimodels/discrete/__init__.py index d689cde..5947a09 100644 --- a/src/epimodels/continuous/__init__.py +++ b/epimodels/discrete/__init__.py @@ -3,4 +3,5 @@ by fccoelho license: GPL V3 or Later """ +from .models import * diff --git a/src/epimodels/discrete/models.py b/epimodels/discrete/models.py similarity index 100% rename from src/epimodels/discrete/models.py rename to epimodels/discrete/models.py diff --git a/src/epimodels/tools/__init__.py b/epimodels/tools/__init__.py similarity index 100% rename from src/epimodels/tools/__init__.py rename to epimodels/tools/__init__.py diff --git a/src/epimodels/tools/phase.py b/epimodels/tools/phase.py similarity index 100% rename from src/epimodels/tools/phase.py rename to epimodels/tools/phase.py diff --git a/pyproject.toml b/pyproject.toml index 7b3a0f0..03fd39d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,10 +24,12 @@ dependencies = [ "sphinx>=8.1.3", "sympy>=1.13.3", ] +packages = ["epimodels"] + [project.urls] Homepage = "https://github.com/fccoelho/epimodels" Documentation = "https://epimodels.readthedocs.io" -#packages = [{ include = "epimodels" }] + [tool.uv] dev-dependencies = [ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..03f586d --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 919f73f..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" - Dummy conftest.py for epimodels. - - If you don't know what this is for, just leave it empty. - Read more about conftest.py under: - https://pytest.org/latest/plugins.html -""" - -# import pytest diff --git a/tests/test_base.py b/tests/test_base.py index 0178853..f9b46ac 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,4 +1,6 @@ import unittest +import sys +sys.path.append('..') from epimodels.continuous import models as cm from epimodels.discrete import models as dm diff --git a/tests/test_continuous_models.py b/tests/test_continuous_models.py index a10509a..98f7030 100644 --- a/tests/test_continuous_models.py +++ b/tests/test_continuous_models.py @@ -1,10 +1,8 @@ __author__ = 'fccoelho' - -import unittest -import pytest +import sys +sys.path.append('..') from matplotlib import pyplot as P - -from epimodels.continuous.models import * +from epimodels.continuous import (SIS, SIR, SIR1D, SIRS, SEIR, SEQIAHR) def test_SIR(): @@ -13,7 +11,7 @@ def test_SIR(): assert len(model.traces) == 4 # assert len(model.traces['time']) == 50 model.plot_traces() - P.show() + # P.show() def test_SIR_with_t_eval(): model = SIR() @@ -27,7 +25,7 @@ def test_SIR1D(): # assert len(model.traces['R']) == 500 assert len(model.traces) == 2 model.plot_traces() - P.show() + # P.show() def test_SIS(): model = SIS() @@ -35,7 +33,7 @@ def test_SIS(): assert len(model.traces) == 3 # assert len(model.traces['time']) == 50 model.plot_traces() - P.show() + # P.show() def test_SIRS(): @@ -44,7 +42,7 @@ def test_SIRS(): assert len(model.traces) == 4 # assert len(model.traces['time']) == 50 model.plot_traces() - P.show() + # P.show() def test_SEIR(): @@ -54,7 +52,7 @@ def test_SEIR(): assert len(model.traces) == 5 # state variables plus time # assert len(model.traces['time']) == 50 model.plot_traces() - P.show() + # P.show() def test_SEQIAHR(): @@ -68,7 +66,7 @@ def test_SEQIAHR(): assert len(model.traces) == 9 # state variables plus time # assert len(model.traces['time']) == 50 model.plot_traces() - P.show() + # P.show() # def test_SIS_with_cache(): # model = SIS() diff --git a/tests/test_discrete_models.py b/tests/test_discrete_models.py index 652fc04..f3da0aa 100644 --- a/tests/test_discrete_models.py +++ b/tests/test_discrete_models.py @@ -1,9 +1,10 @@ __author__ = 'fccoelho' -import pytest # import pyximport; pyximport.install(pyimport=True) -from epimodels.discrete.models import (DiscreteModel, Influenza, SIS, SIR, SEIS, SEIR, - SIpRpS, SEIpRpS, SIpR, SEIpR, SIRS, SEQIAHR) +import sys +sys.path.append('..') +from epimodels.discrete import (DiscreteModel, Influenza, SIS, SIR, SEIS, SEIR, + SIpRpS, SEIpRpS, SIpR, SEIpR, SIRS, SEQIAHR) from matplotlib import pyplot as P @@ -13,7 +14,7 @@ def test_SIS(): assert len(modelsis.traces) == 3 assert len(modelsis.traces['time']) == 50 modelsis.plot_traces() - P.show() + # P.show() assert isinstance(modelsis, DiscreteModel) @@ -23,7 +24,7 @@ def test_SIR(): assert len(modelsir.traces) == 4 assert len(modelsir.traces['time']) == 500 modelsir.plot_traces() - P.show() + # P.show() assert isinstance(modelsir, DiscreteModel) @@ -52,7 +53,7 @@ def test_FLU(): assert len(modelflu.traces['time']) == 50 print(list(modelflu.traces.keys())) modelflu.plot_traces() - P.show() + # P.show() assert isinstance(modelflu, DiscreteModel) @@ -62,7 +63,7 @@ def test_SEIS(): assert len(modelseis.traces) == 4 assert len(modelseis.traces['time']) == 50 modelseis.plot_traces() - P.show() + # P.show() assert isinstance(modelseis, DiscreteModel) @@ -73,7 +74,7 @@ def test_SEIR(): assert len(modelseir.traces) == 5 assert len(modelseir.traces['time']) == tsteps[1] modelseir.plot_traces() - P.show() + # P.show() assert isinstance(modelseir, DiscreteModel) @@ -84,7 +85,7 @@ def test_SIpRpS(): assert len(modelsiprps.traces) == 4 assert len(modelsiprps.traces['time']) == tsteps[1] modelsiprps.plot_traces() - P.show() + # P.show() assert isinstance(modelsiprps, DiscreteModel) @@ -95,7 +96,7 @@ def test_SEIpRpS(): assert len(modelseiprps.traces) == 5 assert len(modelseiprps.traces['time']) == tsteps[1] modelseiprps.plot_traces() - P.show() + # P.show() assert isinstance(modelseiprps, DiscreteModel) @@ -105,7 +106,7 @@ def test_SIpR(): assert len(modelsipr.traces) == 4 assert len(modelsipr.traces['time']) == 50 modelsipr.plot_traces() - P.show() + # P.show() assert isinstance(modelsipr, DiscreteModel) def test_SEIpR(): @@ -115,7 +116,7 @@ def test_SEIpR(): assert len(modelseipr.traces) == 5 assert len(modelseipr.traces['time']) == tsteps[1] modelseipr.plot_traces() - P.show() + # P.show() assert isinstance(modelseipr, DiscreteModel) def test_SIRS(): @@ -124,7 +125,7 @@ def test_SIRS(): assert len(modelsirs.traces) == 4 assert len(modelsirs.traces['time']) == 50 modelsirs.plot_traces() - P.show() + # P.show() assert isinstance(modelsirs, DiscreteModel) def test_SEQIAHR(): @@ -135,5 +136,5 @@ def test_SEQIAHR(): }) assert len(model.traces) == 9 model.plot_traces() - P.show() + # P.show() assert isinstance(model, DiscreteModel) \ No newline at end of file