Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cf0b471
First Pyright cleanup
Advueu963 Aug 14, 2025
513fec5
TypeChecked game
Advueu963 Aug 17, 2025
c5d175b
fixed introduced bugs in game and interaction_values
Advueu963 Aug 18, 2025
73e9a6a
Pyright Save Sampling
Advueu963 Aug 18, 2025
a9e792d
TypeSafe Approximator
Advueu963 Aug 18, 2025
29f948d
Typechecked Datasets
Advueu963 Aug 18, 2025
d158dc7
Explainer folder typechecked
Advueu963 Aug 20, 2025
ff5d200
GameTheory Typechecked
Advueu963 Aug 26, 2025
3b98a02
Imputer Typechecked
Advueu963 Aug 26, 2025
3eba9c0
Plot Typechecked
Advueu963 Aug 26, 2025
2b16269
Added static typechecking to pre-commit
Advueu963 Aug 27, 2025
836ac2b
Refactoring
Advueu963 Aug 27, 2025
2826195
Add pyright change to CHANGELOG
Advueu963 Aug 27, 2025
97425f6
Activate code quality show diff
Advueu963 Sep 11, 2025
5a0da34
changed uv sync in pre-commit hook
Advueu963 Sep 11, 2025
526579e
made fixtures local import
Advueu963 Sep 11, 2025
e622b9d
Merge branch 'main' into Pyright-Integration
mmschlk Sep 11, 2025
696b061
Introduced Generic TypeVar in Approximator, reducing ignores
Advueu963 Sep 15, 2025
2feb9c7
Introduced Generic Types for Explainer. Approximator, Imputer and Exa…
Advueu963 Sep 15, 2025
fa087ea
Bug fix caused through refactoring
Advueu963 Sep 15, 2025
979e7e9
updated overrides
mmschlk Oct 10, 2025
57524c7
tightened CoalitionMatrix to accept only bool arrays
mmschlk Oct 10, 2025
be15438
Remove Python reinstallation step in CI workflow
Advueu963 Oct 12, 2025
f917f7d
Add Python reinstallation and Tkinter installation steps
Advueu963 Oct 12, 2025
4a26a5a
Fix command for installing Tkinter in workflow
Advueu963 Oct 12, 2025
a979c7a
Update Windows workflow to install Tkinter via Chocolatey
Advueu963 Oct 12, 2025
023d3b7
Remove Tkinter installation step from Windows workflow and adjust mat…
Advueu963 Oct 12, 2025
e2f2f6d
adapted some pyright types
mmschlk Oct 13, 2025
e15e2ed
removed generics from explainer again
mmschlk Oct 13, 2025
b2a7359
tightened index type check
mmschlk Oct 13, 2025
a49b7a0
made n_players None at assignment again
mmschlk Oct 14, 2025
f75cf49
moved comments
mmschlk Oct 14, 2025
b4d517e
Merge branch 'main' into Pyright-Integration
mmschlk Oct 14, 2025
97466aa
Merge branch 'main' into Pyright-Integration
mmschlk Oct 14, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:

- name: Install pre-commit
run: |
uv sync --only-group lint
uv sync --all-extras
uv run pre-commit install

- name: Run code-quality checks
run: uv run pre-commit run --all-files
run: uv run pre-commit run --all-files --show-diff-on-failure
6 changes: 0 additions & 6 deletions .github/workflows/tests-shapiq-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ jobs:
with:
python-version: "3.12"

# we need to reinstall Python on Windows because of some problems with tkinter
# https://github.com/astral-sh/uv/issues/7036
- name: Reinstall Python
run: |
uv python install --reinstall
uv run python --version

- name: Install dependencies
run: uv sync --all-extras --dev
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ repos:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
- id: ruff-format

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.404
hooks:
- id: pyright
args: [--verbose, --venvpath=.]
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Development

### Shapiq Statically Typechecked [#430](https://github.com/mmschlk/shapiq/pull/430)
We have introduced static type checking to `shapiq` using [Pyright](https://github.com/microsoft/pyright), and integrated it into our `pre-commit` hooks.
This ensures that type inconsistencies are caught early during development, improving code quality and maintainability.
Developers will now benefit from immediate feedback on type errors, making the codebase more robust and reliable as it evolves.

### Separation of `shapiq` into `shapiq`, `shapiq_games`, and `shapiq-benchmark`

We have begun the process of modularizing the `shapiq` package by splitting it into three distinct packages: `shapiq`, `shapiq_games`, and `shapiq-benchmark`.
Expand All @@ -24,7 +29,7 @@ This restructuring aims to improve maintainability and development scalability.

### Removed Features
- removes the ability to load `InteractionValues` from pickle files. This is now deprecated and will be removed in the next release. Use `InteractionValues.save(..., as_json=True)` to save interaction values as JSON files instead. [#413](https://github.com/mmschlk/shapiq/issues/413)

- removes `coalition_lookup` and `value_storage` properties from `shapiq.Game` since the seperated view on game values and coalitions they belong to is now outdated. Use the `shapiq.Game.game_values` dictionary instead. [#430](https://github.com/mmschlk/shapiq/pull/430)

## v1.3.1 (2025-07-11)

Expand Down
82 changes: 30 additions & 52 deletions docs/source/notebooks/basics_notebooks/custom_games.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.403656Z",
"start_time": "2025-07-11T15:19:17.076499Z"
"end_time": "2025-10-13T14:46:47.375317Z",
"start_time": "2025-10-13T14:46:46.203980Z"
}
},
"source": [
Expand All @@ -31,7 +31,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"shapiq version: 1.3.1\n"
"shapiq version: None\n"
]
}
],
Expand Down Expand Up @@ -87,8 +87,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.417978Z",
"start_time": "2025-07-11T15:19:18.413699Z"
"end_time": "2025-10-13T14:46:47.383596Z",
"start_time": "2025-10-13T14:46:47.379175Z"
}
},
"source": [
Expand Down Expand Up @@ -160,8 +160,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.466123Z",
"start_time": "2025-07-11T15:19:18.463654Z"
"end_time": "2025-10-13T14:46:47.434052Z",
"start_time": "2025-10-13T14:46:47.431931Z"
}
},
"source": [
Expand All @@ -187,8 +187,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.474547Z",
"start_time": "2025-07-11T15:19:18.472575Z"
"end_time": "2025-10-13T14:46:47.443559Z",
"start_time": "2025-10-13T14:46:47.441300Z"
}
},
"source": [
Expand Down Expand Up @@ -220,8 +220,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.485790Z",
"start_time": "2025-07-11T15:19:18.484146Z"
"end_time": "2025-10-13T14:46:47.450937Z",
"start_time": "2025-10-13T14:46:47.449241Z"
}
},
"source": [
Expand Down Expand Up @@ -257,57 +257,35 @@
{
"cell_type": "code",
"metadata": {
"jupyter": {
"is_executing": true
},
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.513846Z",
"start_time": "2025-07-11T15:19:18.495567Z"
"start_time": "2025-10-13T14:49:05.169650Z"
}
},
"source": [
"# see that no values have been precomputed:\n",
"print(\"Coalitions stored before precomputation:\", cooking_game.coalition_lookup)\n",
"print(\"Values stored before precomputation: \", cooking_game.value_storage)\n",
"print(\"Game values stored before precomputation:\", cooking_game.game_values)\n",
"\n",
"# precompute the values of all coalitions\n",
"cooking_game.verbose = True # to see progress\n",
"cooking_game.precompute()\n",
"\n",
"# see that all values have been precomputed:\n",
"print(\"Coalitions stored after precomputation:\", cooking_game.coalition_lookup)\n",
"print(\"Values stored after precomputation: \", cooking_game.value_storage)"
"print(\"Game values stored after precomputation:\", cooking_game.game_values)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Coalitions stored before precomputation: {}\n",
"Values stored before precomputation: []\n"
]
},
{
"data": {
"text/plain": [
"Evaluating game: 0%| | 0/8 [00:00<?, ? coalition/s]"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "9fd21b9a74ec4be2bdd15013ed5faec2"
}
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Coalitions stored after precomputation: {(): 0, (0,): 1, (1,): 2, (2,): 3, (0, 1): 4, (0, 2): 5, (1, 2): 6, (0, 1, 2): 7}\n",
"Values stored after precomputation: [ 0. 4. 3. 2. 9. 8. 7. 15.]\n"
"Game values stored before precomputation: {(): np.float64(0.0), (0,): np.float64(4.0), (1,): np.float64(3.0), (2,): np.float64(2.0), (0, 1): np.float64(9.0), (0, 2): np.float64(8.0), (1, 2): np.float64(7.0), (0, 1, 2): np.float64(15.0)}\n",
"{(): np.float64(0.0), (0,): np.float64(4.0), (1,): np.float64(3.0), (2,): np.float64(2.0), (0, 1): np.float64(9.0), (0, 2): np.float64(8.0), (1, 2): np.float64(7.0), (0, 1, 2): np.float64(15.0)}\n"
]
}
],
"execution_count": 6
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -321,8 +299,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.523906Z",
"start_time": "2025-07-11T15:19:18.518722Z"
"end_time": "2025-10-13T14:46:47.490403Z",
"start_time": "2025-10-13T14:46:47.486413Z"
}
},
"source": [
Expand All @@ -332,17 +310,17 @@
"\n",
"# load the precomputed values from the file\n",
"empty_cooking_game = CookingGame()\n",
"print(\"Values stored before loading: \", empty_cooking_game.value_storage)\n",
"print(\"Values stored before loading: \", empty_cooking_game.game_values)\n",
"empty_cooking_game.load_values(save_path)\n",
"print(\"Values stored after loading: \", empty_cooking_game.value_storage)"
"print(\"Values stored after loading: \", empty_cooking_game.game_values)"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Values stored before loading: []\n",
"Values stored after loading: [ 0. 4. 3. 2. 9. 8. 7. 15.]\n"
"Values stored before loading: {}\n",
"Values stored after loading: {(): np.float64(0.0), (np.int64(0),): np.float64(4.0), (np.int64(1),): np.float64(3.0), (np.int64(2),): np.float64(2.0), (np.int64(0), np.int64(1)): np.float64(9.0), (np.int64(0), np.int64(2)): np.float64(8.0), (np.int64(1), np.int64(2)): np.float64(7.0), (np.int64(0), np.int64(1), np.int64(2)): np.float64(15.0)}\n"
]
}
],
Expand All @@ -360,8 +338,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.535118Z",
"start_time": "2025-07-11T15:19:18.531861Z"
"end_time": "2025-10-13T14:46:47.501638Z",
"start_time": "2025-10-13T14:46:47.498217Z"
}
},
"source": [
Expand Down Expand Up @@ -406,8 +384,8 @@
"cell_type": "code",
"metadata": {
"ExecuteTime": {
"end_time": "2025-07-11T15:19:18.543537Z",
"start_time": "2025-07-11T15:19:18.541828Z"
"end_time": "2025-10-13T14:46:47.517246Z",
"start_time": "2025-10-13T14:46:47.515436Z"
}
},
"source": [
Expand Down
Loading