Skip to content

Commit f525ecd

Browse files
Merge pull request #182 from scikit-learn-contrib/feat/migration-uv
tests updated
2 parents 1b83c6d + 3dd450e commit f525ecd

28 files changed

Lines changed: 5066 additions & 328 deletions

.github/workflows/publish.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,22 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
id-token: write
9+
710
jobs:
811
deploy:
912
runs-on: ubuntu-latest
13+
environment: pypi
1014

1115
steps:
1216
- uses: actions/checkout@v4
13-
- name: Set up Python
14-
uses: actions/setup-python@v4
15-
with:
16-
python-version: '3.10'
17-
- name: Install Poetry
18-
run: |
19-
curl -sSL https://install.python-poetry.org | python3 -
20-
echo "$HOME/.local/bin" >> $GITHUB_PATH
21-
- name: Install dependencies
22-
run: |
23-
poetry install
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v3
20+
2421
- name: Build package
25-
run: |
26-
poetry build
27-
- name: Publish package
28-
env:
29-
PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
30-
run: |
31-
poetry config pypi-token.pypi $PYPI_TOKEN
32-
poetry publish
22+
run: uv build
23+
24+
- name: Publish to PyPI
25+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,39 @@ jobs:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
1818
matrix:
19-
os: [ubuntu-latest, windows-latest]
20-
python-version: ["3.9", "3.11", "3.12"]
19+
# Full matrix only for PRs to main
20+
os: ${{ github.event_name == 'pull_request' && github.base_ref == 'main' && fromJSON('["ubuntu-latest", "windows-latest"]') || fromJSON('["ubuntu-latest"]') }}
21+
python-version: ${{ github.event_name == 'pull_request' && github.base_ref == 'main' && fromJSON('["3.9", "3.11", "3.12"]') || fromJSON('["3.12"]') }}
2122
defaults:
2223
run:
2324
shell: bash -l {0}
2425

2526
steps:
26-
- name: Set OS and Python version
27-
id: set-vars
28-
run: |
29-
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/dev" ]]; then
30-
echo "os-matrix=ubuntu-latest,windows-latest" >> $GITHUB_ENV
31-
echo "python-matrix=3.9,3.11,3.12" >> $GITHUB_ENV
32-
else
33-
echo "os-matrix=ubuntu-latest" >> $GITHUB_ENV
34-
echo "python-matrix=3.12" >> $GITHUB_ENV
35-
fi
36-
- name: Checkout
37-
uses: actions/checkout@v3
38-
- name: Python
39-
uses: actions/setup-python@v4
40-
with:
41-
python-version: ${{ matrix.python-version }}
42-
- name: Cache Poetry
43-
uses: actions/cache@v3
44-
with:
45-
path: |
46-
~/.cache/pypoetry
47-
~/.cache/pip
48-
key: ${{ runner.os }}-poetry-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
49-
restore-keys: |
50-
${{ runner.os }}-poetry-${{ matrix.python-version }}-
51-
- name: Poetry
52-
uses: snok/install-poetry@v1
53-
with:
54-
version: 1.8.3
55-
- name: Lock
56-
run: poetry lock --no-update
57-
- name: Install
58-
run: poetry install
59-
- name: Checkers
60-
run: make checkers
61-
- name: Codecov
62-
uses: codecov/codecov-action@v3
63-
env:
64-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
65-
- name: Check Changed Files
66-
id: changed-files
67-
uses: tj-actions/changed-files@v40
27+
- uses: actions/checkout@v4
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v3
6831
with:
69-
files: |
70-
docs/**
71-
**.rst
32+
enable-cache: true
33+
cache-dependency-glob: "uv.lock"
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
run: uv python install ${{ matrix.python-version }}
37+
38+
- name: Install dependencies
39+
run: make install
40+
41+
- name: Check with ruff
42+
run: make check-quality
43+
44+
- name: Test with pytest
45+
run: make check-tests
46+
47+
- name: Check types
48+
run: make check-types
7249

73-
- name: Build Docs
74-
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && steps.changed-files.outputs.any_changed == 'true'
50+
- name: Build and test docs
51+
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
7552
run: |
76-
poetry run sphinx-build -b html docs/ _build/html
53+
make doc
54+
make doctest

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ var/
2828
*.egg-info/
2929
.installed.cfg
3030
*.egg
31-
poetry.lock
3231

3332
# PyInstaller
3433
# Usually these files are written by a python script from a template

.python-version

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
3.12.10

CONTRIBUTING.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ Local setup
2525

2626
We encourage you to use a virtual environment. You'll want to activate it every time you want to work on `Qolmat`.
2727

28-
You can create a virtual environment via `conda`:
28+
You can create a virtual environment and install dependencies with `uv`:
2929

3030
.. code:: sh
3131
32-
$ pip install poetry
33-
$ poetry config virtualenvs.in-project true
34-
$ poetry lock
35-
$ poetry install
36-
$ poetry shell
32+
$ uv sync
33+
$ uv run pytest
3734
3835
Once the environment is installed, pre-commit is installed, but need to be activated using the following command:
3936

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ History
55
0.1.11 (2025-12-30)
66
------------------
77
* PLKM test implemented and documented in the holes_characterization module
8+
* Dependency management improved with uv
9+
* Migrated from hyperopt to skopt for hyperparameter optimization
810

911
0.1.10 (2025-08-30)
1012
------------------

Makefile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
1+
# Install dependencies
2+
install:
3+
uv sync --all-extras
14

5+
# Code quality checks
26
check-coverage:
3-
poetry run pytest --cov-branch --cov=qolmat/ --cov-report=xml tests/
4-
5-
check-poetry:
6-
poetry check --lock
7+
uv run pytest --cov-branch --cov=qolmat/ --cov-report=xml tests/
78

89
check-quality:
9-
poetry run ruff check qolmat/ tests/
10+
uv run ruff check qolmat/ tests/
1011

1112
check-security:
12-
poetry run bandit --recursive --configfile=pyproject.toml qolmat/
13+
uv run bandit --recursive --configfile=pyproject.toml qolmat/
1314

1415
check-tests:
15-
poetry run pytest tests/
16+
uv run pytest tests/
1617

1718
check-types:
18-
poetry run mypy qolmat/ tests/
19+
uv run mypy qolmat/ tests/
1920

2021
checkers: check-coverage check-types
2122

23+
# Formatting
24+
format:
25+
uv run ruff format qolmat/ tests/
26+
uv run ruff check --fix qolmat/ tests/
27+
28+
# Cleaning
2229
clean:
23-
rm -rf .mypy_cache .pytest_cache .coverage*
30+
rm -rf .mypy_cache .pytest_cache .coverage* .ruff_cache
2431
rm -rf **__pycache__
25-
make clean -C docs
26-
27-
coverage:
28-
poetry run pytest --cov-branch --cov=qolmat --cov-report=xml tests
32+
uv run make clean -C docs
2933

34+
# Documentation
3035
doc:
31-
make html -C docs
36+
uv run make html -C docs
3237

3338
doctest:
34-
poetry run pytest --doctest-modules --pyargs qolmat
39+
uv run pytest --doctest-modules --pyargs qolmat
40+
41+
# Development helpers
42+
lock:
43+
uv lock
44+
45+
.PHONY: install check-coverage check-quality check-security check-tests check-types checkers format clean doc doctest lock

docs/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@
5353
# see https://github.com/numpy/numpydoc/issues/69
5454
numpydoc_show_class_members = False
5555

56-
from distutils.version import LooseVersion
57-
5856
# pngmath / imgmath compatibility layer for different sphinx versions
5957
# import sphinx
6058

docs/sg_execution_times.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Computation times
88
=================
9-
**00:00.000** total execution time for 6 files **from all galleries**:
9+
**01:04.897** total execution time for 6 files **from all galleries**:
1010

1111
.. container::
1212

@@ -33,20 +33,20 @@ Computation times
3333
- Time
3434
- Mem (MB)
3535
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_benchmark_TS.py` (``../examples/tutorials/plot_tuto_benchmark_TS.py``)
36-
- 00:00.000
36+
- 00:21.381
3737
- 0.0
3838
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_categorical.py` (``../examples/tutorials/plot_tuto_categorical.py``)
39-
- 00:00.000
39+
- 00:16.026
4040
- 0.0
4141
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_diffusion_models.py` (``../examples/tutorials/plot_tuto_diffusion_models.py``)
42-
- 00:00.000
43-
- 0.0
44-
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_hole_generator.py` (``../examples/tutorials/plot_tuto_hole_generator.py``)
45-
- 00:00.000
42+
- 00:11.896
4643
- 0.0
4744
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_mcar.py` (``../examples/tutorials/plot_tuto_mcar.py``)
48-
- 00:00.000
45+
- 00:08.072
4946
- 0.0
5047
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_mean_median.py` (``../examples/tutorials/plot_tuto_mean_median.py``)
51-
- 00:00.000
48+
- 00:04.939
49+
- 0.0
50+
* - :ref:`sphx_glr_examples_tutorials_plot_tuto_hole_generator.py` (``../examples/tutorials/plot_tuto_hole_generator.py``)
51+
- 00:02.583
5252
- 0.0

examples/benchmark.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ First, import some useful libraries
2222
```python tags=[]
2323
import warnings
2424
# warnings.filterwarnings('error')
25-
```
2625

27-
```python tags=[]
2826
%reload_ext autoreload
2927
%autoreload 2
3028

@@ -33,21 +31,21 @@ from IPython.display import Image
3331
import pandas as pd
3432
from datetime import datetime
3533
import numpy as np
36-
import hyperopt as ho
34+
from skopt.space import Real, Integer, Categorical
3735
np.random.seed(1234)
3836
from matplotlib import pyplot as plt
3937
import matplotlib.ticker as plticker
4038

4139
tab10 = plt.get_cmap("tab10")
4240
plt.rcParams.update({'font.size': 18})
4341

44-
4542
from sklearn.linear_model import LinearRegression
4643

4744
from qolmat.benchmark import comparator, missing_patterns
4845
from qolmat.imputations import imputers
4946
from qolmat.utils import data, utils, plot
5047

48+
5149
```
5250

5351
### **I. Load data**
@@ -124,15 +122,15 @@ imputer_residuals = imputers.ImputerResiduals(groups=("station",), period=365, m
124122
imputer_rpca = imputers.ImputerRpcaNoisy(groups=("station",), columnwise=False, max_iterations=500, tau=.01, lam=5, rank=1)
125123
imputer_rpca_opti = imputers.ImputerRpcaNoisy(groups=("station",), columnwise=False, max_iterations=256)
126124
dict_config_opti["RPCA_opti"] = {
127-
"tau": ho.hp.uniform("tau", low=.5, high=5),
128-
"lam": ho.hp.uniform("lam", low=.1, high=1),
125+
"tau": Real(0.5, 5.0, name="tau"),
126+
"lam": Real(0.1, 1.0, name="lam"),
129127
}
130128
imputer_rpca_opticw = imputers.ImputerRpcaNoisy(groups=("station",), columnwise=False, max_iterations=256)
131129
dict_config_opti["RPCA_opticw"] = {
132-
"tau/TEMP": ho.hp.uniform("tau/TEMP", low=.5, high=5),
133-
"tau/PRES": ho.hp.uniform("tau/PRES", low=.5, high=5),
134-
"lam/TEMP": ho.hp.uniform("lam/TEMP", low=.1, high=1),
135-
"lam/PRES": ho.hp.uniform("lam/PRES", low=.1, high=1),
130+
"tau/TEMP": Real(0.5, 5.0, name="tau/TEMP"),
131+
"tau/PRES": Real(0.5, 5.0, name="tau/PRES"),
132+
"lam/TEMP": Real(0.1, 1.0, name="lam/TEMP"),
133+
"lam/PRES": Real(0.1, 1.0, name="lam/PRES"),
136134
}
137135

138136
imputer_normal_sample = imputers.ImputerEM(groups=("station",), model="multinormal", method="sample", max_iter_em=8, n_iter_ou=128, dt=4e-2)

0 commit comments

Comments
 (0)