diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2711864..3c21b7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,9 +17,9 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: pip @@ -34,8 +34,10 @@ jobs: hatch run types:check - name: Run tests with pytest run: | - hatch run +py=${{ matrix.python-version }} all:test + hatch run +py=${{ matrix.python-version }} all:test-cov - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + files: coverage.json + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 53d469b..09dca20 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .vscode *.ps1 +coverage.json # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/pyproject.toml b/pyproject.toml index e05bc6d..5b5824f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "stochatreat" dynamic = ["version"] description = 'Stratified random assignment using pandas' readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" keywords = [ "randomization", "block randomization", @@ -19,7 +19,6 @@ authors = [{ name = "Manuel Martinez", email = "manmartgarc@gmail.com" }] classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -29,7 +28,7 @@ classifiers = [ "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", ] -dependencies = ["pandas"] +dependencies = ["pandas>=2.2"] [project.urls] Documentation = "https://github.com/manmartgarc/stochatreat/blob/main/README.md" @@ -43,10 +42,8 @@ path = "src/stochatreat/__about__.py" installer = "uv" dependencies = ["pytest", "pytest-cov", "pytest-xdist", "coverage[toml]>=6.5"] [tool.hatch.envs.default.scripts] -test = "pytest -n auto {args:tests}" -test-cov = "pytest -n auto --cov {args:tests}" -cov-report = ["- coverage combine", "coverage report"] -cov = ["test-cov", "cov-report"] +test-cov = "pytest --cov=src/stochatreat tests/ --cov-report json -n auto" +test = "test-cov --no-cov" [tool.hatch.envs.all] installer = "uv" @@ -57,20 +54,15 @@ python = ["3.9", "3.10", "3.11", "3.12"] [tool.hatch.envs.types] dependencies = ["mypy>=1.0.0"] [tool.hatch.envs.types.scripts] -check = "mypy --install-types --non-interactive {args:src/stochatreat tests}" - -[tool.coverage.run] -source_pkgs = ["stochatreat", "tests"] -branch = true -parallel = true -omit = ["src/stochatreat/__about__.py"] - -[tool.coverage.paths] -stochatreat = ["src/stochatreat", "*/stochatreat/src/stochatreat"] -tests = ["tests", "*/stochatreat/tests"] +check = "mypy --install-types --non-interactive src/stochatreat tests/" [tool.coverage.report] -exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHEKCING"] +exclude_lines = [ + "no cov", + "if __name__ == .__main__.:", + "if TYPE_CHEKCING", + "__version__ = ", +] [tool.ruff] line-length = 79 diff --git a/src/stochatreat/__about__.py b/src/stochatreat/__about__.py index f18e5d0..39e62e7 100644 --- a/src/stochatreat/__about__.py +++ b/src/stochatreat/__about__.py @@ -1 +1,2 @@ -__version__ = "0.0.18" +# pragma: no cover +__version__ = "0.0.19" diff --git a/src/stochatreat/utils.py b/src/stochatreat/utils.py index cd8ee64..09ff168 100644 --- a/src/stochatreat/utils.py +++ b/src/stochatreat/utils.py @@ -1,22 +1,6 @@ -import sys +from collections.abc import Iterable from fractions import Fraction -from typing import Iterable - -LCM_VERSION = 9 - -if sys.version_info.minor < LCM_VERSION: - from functools import reduce - from math import gcd # type: ignore - - def lcm(*args): - """ - Helper function to compute the Lowest Common Multiple of a list of - integers - """ - return reduce(lambda a, b: a * b // gcd(a, b), args) - -else: - from math import lcm # type: ignore +from math import lcm def get_lcm_prob_denominators(probs: Iterable[float]) -> int: