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

ci: migrate to uv + tox based setup🔧 #131

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 5 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ on:
- '!docs/**'
jobs:
build:
name: test with ${{ matrix.env }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
env:
- ["3.8", "3.13"]
os: [ubuntu-latest, windows-latest]
python-version: [3.x]
steps:
- name: Git clone
uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
- name: Setup Python
uses: actions/setup-python@v5
with:
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pip install tclf

**[uv⚡](https://github.com/astral-sh/uv)**
```console
uv pip install tclf
uv add tclf
```

## Supported Algorithms
Expand Down Expand Up @@ -115,12 +115,13 @@ For more practical examples, see our [examples section](https://karelze.github.i

## Development

We are using [`pixi`](https://github.com/prefix-dev/pixi) as a dependency management and workflow tool.
We are using [`tox`](https://tox.wiki/en/latest/user_guide.html) with [`uv`](https://docs.astral.sh/uv/) for development.

```bash
pixi install
pixi run postinstall
pixi run test
tox -e lint
tox -e format
tox -e test
tox -e build
```

## Citation
Expand Down
11 changes: 6 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pip install tclf

**[uv⚡](https://github.com/astral-sh/uv)**
```console
uv pip install tclf
uv add tclf
```

## Supported Algorithms
Expand Down Expand Up @@ -115,12 +115,13 @@ For more practical examples, see our [examples section](https://karelze.github.i

## Development

We are using [`pixi`](https://github.com/prefix-dev/pixi) as a dependency management and workflow tool.
We are using [`tox`](https://tox.wiki/en/latest/user_guide.html) with [`uv`](https://docs.astral.sh/uv/) for development.

```bash
pixi install
pixi run postinstall
pixi run test
tox -e lint
tox -e format
tox -e test
tox -e build
```

## Citation
Expand Down
34 changes: 0 additions & 34 deletions pixi.toml

This file was deleted.

83 changes: 78 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Operating System :: OS Independent",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
Expand All @@ -29,10 +31,34 @@ classifiers = [
dependencies = [
"numpy",
"pandas",
"scikit-learn"
"scikit-learn",
]

dynamic = ["version"]

[project.optional-dependencies]
dev = [
# doc
"mkdocs",
"mkdocs-material",
"mkdocstrings-python",
# build
"build",
# test
"pytest",
"pytest-cov",
# linting",
"pre-commit",
"mypy",
"ruff",
"tox-uv>=1.13.1",
"tox>=4.23.2",
"pytest-codspeed",
"mkdocs-bibtex",
"commitizen",
"pypandoc-binary"
]

[tool.setuptools.dynamic]
version = {file = "version"}

Expand Down Expand Up @@ -89,16 +115,13 @@ annotated_tag = true

[tool.ruff]


include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"]


[tool.ruff.lint]

# See rules: https://beta.ruff.rs/docs/rules/
select = [
"C", # flake8-comprehensions
"D", # pydocstyle
"DOC", # pydoclint
"E", # pycodestyle errors
"F", # pyflakes
"FURB", # refurb
Expand Down Expand Up @@ -140,3 +163,53 @@ section-order = ["future", "standard-library", "third-party", "first-party", "lo

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.tox]
env_list = ["format", "lint", "pre-commit"]
min_version = "4.23"

[tool.tox.env_run_base]
runner = "uv-venv-lock-runner"
allowlist_externals = ["/bin/sh"]
skip_install = true
with_dev = true

[tool.tox.env.clean]
description = "cleanup tasks (remove build artifacts and cache)"
commands = [
["coverage", "erase"],
["sh", "-c", "rm -rf .mypy_cache .pytest_cache .ruff_cache dist mlruns reports"]
]

[tool.tox.env.doc]
description = "writing documentation using mkdocs"
commands = [
["mkdocs", "serve"]
]


[tool.tox.env.format]
description = "code formatting using ruff"
commands = [
["ruff", "format", { replace = "posargs", default = ["src", "tests"], extend = true }]
]

[tool.tox.env.lint]
description = "linting and syntax checks"
commands = [
["ruff", "check", { replace = "posargs", default = ["src", "tests"], extend = true} ],
["ruff", "format", "--check", { replace = "posargs", default = ["src", "tests"], extend = true} ],
["mypy", { replace = "posargs", default = ["src"], extend = true} ]
]

[tool.tox.env.pre-commit]
description = "pre-commit hooks"
commands = [["pre-commit", "run", "--all-files", "--show-diff-on-failure"]]

[tool.tox.env.test]
description = "tests"
commands = [["pytest"]]

[tool.tox.env.build]
description = "build the project"
commands = [["uv", "build"]]
4 changes: 4 additions & 0 deletions src/tclf/classical_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def _more_tags(self) -> dict[str, bool | dict[str, str]]:
"""Set tags for sklearn.

See: https://scikit-learn.org/stable/developers/develop.html#estimator-tags

Returns:
dict[str, bool | dict[str, str]]: dict with tags
"""
return {
"allow_nan": True,
Expand Down Expand Up @@ -213,6 +216,7 @@ def _mid(self, subset: str) -> npt.NDArray:
Args:
subset (str): subset i.e.,
'ex' or 'best'

Returns:
npt.NDArray: midpoints. Can be np.NaN.
"""
Expand Down
6 changes: 4 additions & 2 deletions src/tclf/types.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Common type hints."""

from typing import Union

import numpy as np
import numpy.typing as npt
import pandas as pd
from scipy.sparse import spmatrix

MatrixLike = np.ndarray | pd.DataFrame | spmatrix
ArrayLike = npt.ArrayLike | pd.Series
MatrixLike = Union[np.ndarray, pd.DataFrame, spmatrix]
ArrayLike = Union[npt.ArrayLike, pd.Series]
2 changes: 2 additions & 0 deletions tests/test_classical_classifier.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Tests for the classical classifier."""

from __future__ import annotations

from typing import Callable

import numpy as np
Expand Down
Loading
Loading