Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): fix coverage #32

Merged
merged 8 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.vscode
*.ps1
coverage.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
30 changes: 11 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -19,7 +19,6 @@ authors = [{ name = "Manuel Martinez", email = "[email protected]" }]
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",
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/stochatreat/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = "0.0.18"
# pragma: no cover
__version__ = "0.0.19"
20 changes: 2 additions & 18 deletions src/stochatreat/utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down