Skip to content

Commit af95153

Browse files
authored
Bump python version (#497)
* bumped min python version to 3.12 * Removed deprecated behaviour from shapiq: - removed `path_to_values` from `Game` - made json the only viable file format for `InteractionValues` * updated CHANGELOG.md * bumped min python version to 3.12 * bumped python version to 3.14 * added entry to CHANGELOG.md * updated uv.lock * updated uv.lock * update tabpfn download for CI * fixed ty issues * fixed setup code * fixed tabpfn code * increased workflow dependencies for less workflow runtime in case of failure * introduce AGENTS.md (prev. only CLAUDE.md) * fixed tests with new versions of dependencies
1 parent c45923c commit af95153

16 files changed

Lines changed: 2180 additions & 2561 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Run code-quality checks
2828
run: uv run pre-commit run --all-files --show-diff-on-failure
2929
# ----------------------------------------------------------------------------------------------
30-
# Install and Import Check
30+
# Install and Import Check `shapiq`
3131
# ----------------------------------------------------------------------------------------------
3232
install_and_import_shapiq:
3333
name: Install and import check shapiq
@@ -36,9 +36,9 @@ jobs:
3636
matrix:
3737
include:
3838
- os: ubuntu-latest
39-
python-version: "3.10"
39+
python-version: "3.12"
4040
- os: ubuntu-latest
41-
python-version: "3.13"
41+
python-version: "3.14"
4242
- os: windows-latest
4343
python-version: "3.12"
4444
- os: macos-latest
@@ -58,7 +58,7 @@ jobs:
5858
- name: Test import
5959
run: uv run --no-sync python -c "import shapiq; print('shapiq imported successfully')"
6060
# ----------------------------------------------------------------------------------------------
61-
# Install and Import Check
61+
# Install and Import Check `shapiq_games`
6262
# ----------------------------------------------------------------------------------------------
6363
install_and_import_shapiq_games:
6464
name: Install and import check shapiq-games
@@ -79,22 +79,37 @@ jobs:
7979
- name: Test import of shapiq_games
8080
run: uv run --no-sync python -c "import shapiq_games; print('shapiq_games imported successfully')"
8181
# ----------------------------------------------------------------------------------------------
82-
# Unit Tests with Matrix
82+
# Unit Tests for shapiq (Stable Python and Matrix)
8383
# ----------------------------------------------------------------------------------------------
84-
test_shapiq:
85-
name: Run Unit Tests
84+
test_shapiq_stable:
85+
name: Run Unit Tests (Stable Python)
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v6
89+
- name: Set up Python and uv
90+
uses: astral-sh/setup-uv@v7
91+
with:
92+
python-version: "3.12"
93+
enable-cache: true
94+
- name: Install test dependencies
95+
run: uv sync
96+
- name: Run unit tests
97+
run: uv run pytest "tests/shapiq"
98+
test_shapiq_matrix:
99+
name: Run Unit Tests (Matrix)
100+
needs:
101+
- test_shapiq_stable
102+
- install_and_import_shapiq
86103
strategy:
87104
fail-fast: false
88105
matrix:
89106
include:
90107
- os: ubuntu-latest
91-
python-version: "3.10"
92-
- os: ubuntu-latest
93-
python-version: "3.13"
108+
python-version: "3.14" # Test latest Python on Ubuntu
94109
- os: windows-latest
95-
python-version: "3.12"
110+
python-version: "3.12" # Test stable Python on Windows
96111
- os: macos-latest
97-
python-version: "3.12"
112+
python-version: "3.12" # Test stable Python on macOS
98113
runs-on: ${{ matrix.os }}
99114
steps:
100115
- uses: actions/checkout@v6
@@ -112,6 +127,9 @@ jobs:
112127
# ----------------------------------------------------------------------------------------------
113128
test_shapiq_games:
114129
runs-on: ubuntu-latest
130+
needs:
131+
- install_and_import_shapiq
132+
- test_shapiq_stable
115133
steps:
116134
- uses: actions/checkout@v6
117135
- name: Set up Python and uv
@@ -156,6 +174,7 @@ jobs:
156174
needs:
157175
- install_and_import_shapiq
158176
- check_code_quality
177+
- test_shapiq_stable
159178
steps:
160179
- uses: actions/checkout@v6
161180
- name: Set up Python and uv

AGENTS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# CLAUDE.md
2+
3+
Guidance for Claude Code when working in this repository.
4+
5+
## Project Overview
6+
7+
`shapiq` is a Python library for computing Shapley Interactions for Machine Learning. The repo hosts **two separate installable packages**:
8+
- `shapiq` in `src/shapiq/` — the core library
9+
- `shapiq_games` in `src/shapiq_games/` — optional benchmark games (requires extra ML deps via `uv sync --group all_ml`)
10+
11+
## Commands
12+
13+
```sh
14+
# Setup
15+
uv sync # dev dependencies (test + lint + all_ml)
16+
17+
# Testing
18+
uv run pytest tests/shapiq
19+
uv run pytest tests/shapiq_games -n logical
20+
uv run pytest tests/shapiq/tests_unit/test_interaction_values.py # single file
21+
22+
# Quality (run before every commit)
23+
uv run pre-commit run --all-files
24+
uv run ty check # type check src/shapiq/ only
25+
26+
# Docs
27+
uv run sphinx-build -b html docs/source docs/build/html
28+
```
29+
30+
## Package Structure
31+
32+
```
33+
src/
34+
├── shapiq/
35+
│ ├── interaction_values.py # InteractionValues — central output type
36+
│ ├── game.py # Base Game class
37+
│ ├── approximator/ # Approximation algorithms (base.py + subdirs)
38+
│ ├── explainer/
39+
│ │ ├── tabular.py # TabularExplainer — main user-facing class
40+
│ │ ├── tree/
41+
│ │ └── product_kernel/
42+
│ ├── imputer/ # MarginalImputer is the default
43+
│ ├── game_theory/
44+
│ │ ├── exact.py
45+
│ │ ├── indices.py # ALL_AVAILABLE_CONCEPTS — index registry
46+
│ │ └── moebius_converter.py
47+
│ ├── plot/
48+
│ └── utils/
49+
└── shapiq_games/
50+
├── benchmark/
51+
├── synthetic/
52+
└── tabular/
53+
```
54+
55+
## Code Style
56+
57+
- **All files** must start with `from __future__ import annotations``isort` enforces this
58+
- `ruff` with `black` style, line length 100, Google-style docstrings
59+
- Uppercase `X` in function signatures is allowed (ML convention)
60+
61+
## Key Rules
62+
63+
- **Do not** add ML-heavy dependencies to `shapiq` core — they belong in `shapiq_games`
64+
- Use existing fixtures in `tests/shapiq/fixtures/` rather than duplicating setup
65+
- `ty` type checking runs on `src/shapiq/` only; tests are excluded

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## v1.5.0 (unreleased)
44

5+
### Python Version
6+
- adds support for Python 3.14 making the package compatible with the latest Python version.
7+
- drops support for Python 3.10 and 3.11. The minimum supported Python version is now 3.12.
8+
59
### Removed Deprecated Features
610
- removes `path_to_values` parameter from `shapiq.Game`, which was previously deprecated. Use `shapiq.Game.load()` instead.
711
- removes pickle support from `shapiq.InteractionValues`. JSON is now the only supported file format. Use `InteractionValues.save()` and `InteractionValues.load()` with JSON files.

CLAUDE.md

Lines changed: 0 additions & 149 deletions
This file was deleted.

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"sphinx.ext.viewcode",
4848
"sphinx.ext.autosectionlabel",
4949
"sphinx_autodoc_typehints",
50-
"sphinx_toolbox.more_autodoc.autoprotocol",
5150
"sphinxcontrib.bibtex",
5251
"sphinx_gallery.gen_gallery",
5352
]

pyproject.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
66
name = "shapiq"
77
dynamic = ["readme", "version"]
88
description = "Shapley Interactions for Machine Learning"
9-
requires-python = ">=3.10"
9+
requires-python = ">=3.12"
1010
dependencies = [
1111
# core
1212
"numpy",
@@ -45,10 +45,9 @@ classifiers = [
4545
'Operating System :: Unix',
4646
'Operating System :: MacOS',
4747
'Programming Language :: Python :: 3',
48-
'Programming Language :: Python :: 3.10',
49-
'Programming Language :: Python :: 3.11',
5048
'Programming Language :: Python :: 3.12',
5149
'Programming Language :: Python :: 3.13',
50+
'Programming Language :: Python :: 3.14',
5251
]
5352
keywords = [
5453
"python",
@@ -93,7 +92,7 @@ minversion = "8.0"
9392

9493
[tool.ruff]
9594
line-length = 100
96-
target-version = "py310"
95+
target-version = "py312"
9796
src = ["tests", "src", "docs"]
9897

9998
[tool.ruff.lint]
@@ -212,7 +211,7 @@ include = ["src/shapiq"]
212211
exclude = ["tests", "docs", "benchmark", "scripts", "src/shapiq_games"]
213212

214213
[tool.ty.environment]
215-
python-version = "3.10"
214+
python-version = "3.12"
216215
python = "./.venv"
217216
python-platform = "linux"
218217

@@ -238,8 +237,8 @@ all_ml = [
238237
"tf-keras; python_version < '3.13' and platform_system != 'Windows'", # only up to py 3.12
239238
]
240239
test = [
241-
"pytest>=8.3.5", # for running tests
242-
"pytest-cov>=6.0.0", # for coverage
240+
"pytest>=9.0.2", # for running tests
241+
"pytest-cov>=7.0.0", # for coverage
243242
"pytest-xdist>=3.8.0", # for parallel test execution
244243
"packaging", # for version parsing in tests
245244
]
@@ -254,7 +253,6 @@ docs = [
254253
"myst-parser", # Markdown support for Sphinx
255254
"sphinx-copybutton", # copy button for code blocks
256255
"sphinx-autodoc-typehints", # include typehints in docs
257-
"sphinx_toolbox", # various sphinx extensions
258256
"sphinxcontrib-bibtex", # references based on bibtex
259257
"nbconvert", # notebook support for sphinx
260258
"nbsphinx", # notebook support for sphinx

src/shapiq/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
]
144144

145145

146-
def __getattr__(name: str) -> ModuleType | None:
146+
def __getattr__(name: str) -> ModuleType:
147147
"""Redirect deprecated imports to the new module."""
148-
return try_import_deprecated(name)
148+
result = try_import_deprecated(name)
149+
if result is None:
150+
msg = f"module 'shapiq' has no attribute {name!r}"
151+
raise AttributeError(msg)
152+
return result

0 commit comments

Comments
 (0)