Skip to content

Commit

Permalink
ci: migrate to tox and fix tests for py3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Dec 2, 2024
1 parent 7da9806 commit f02ebde
Show file tree
Hide file tree
Showing 8 changed files with 1,601 additions and 74 deletions.
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
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
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
9 changes: 5 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
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.

81 changes: 76 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,11 +31,34 @@ classifiers = [
dependencies = [
"numpy",
"pandas",
"ruff>=0.8.0",
"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 @@ -90,10 +115,6 @@ annotated_tag = true

[tool.ruff]


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


[tool.ruff.lint]

# See rules: https://beta.ruff.rs/docs/rules/
Expand Down Expand Up @@ -142,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"]]
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

0 comments on commit f02ebde

Please sign in to comment.