Skip to content

Add Game.compute function and related test to the Game class#397

Merged
mmschlk merged 7 commits intomainfrom
345-add-a-compute-method-to-the-game-class
Jun 12, 2025
Merged

Add Game.compute function and related test to the Game class#397
mmschlk merged 7 commits intomainfrom
345-add-a-compute-method-to-the-game-class

Conversation

@IsaH57
Copy link
Copy Markdown
Collaborator

@IsaH57 IsaH57 commented Jun 4, 2025

This pull request adds a Game.compute() function to the shapiq.Game class. After computing the game values, it returns the normalized game values, the coalition_lookup, and the normalization_value. Notably, using the compute function does not alter the state of the Game object. This PR also adds an utility function generate_interaction_lookup_from_coalitions for creating an interaction lookup dict from an arbitrary coalition array.

@IsaH57 IsaH57 linked an issue Jun 4, 2025 that may be closed by this pull request
Comment thread shapiq/games/base.py Outdated
@mmschlk
Copy link
Copy Markdown
Owner

mmschlk commented Jun 4, 2025

This PR closes #345

Comment thread shapiq/games/base.py Outdated
self.precompute_flag = True

def compute(
self, coalitions: np.ndarray | None = None, *, return_normalization: bool = False
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you actually always return the normalization_value as the third thing and not normalize the values in line 440. Then this function would be more usable because it's the "raw" computation.

Comment thread shapiq/games/base.py
coalitions: The coalitions to evaluate.

Returns:
A tuple containing:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the return types because sphinx will display automatically and then we do not have to maintain two parts of the code. :)

@mmschlk mmschlk changed the title Add compute() function and related test to the Game class Add Game.compute function and related test to the Game class Jun 12, 2025
@mmschlk mmschlk changed the title Add Game.compute function and related test to the Game class Add Game.compute function and related test to the Game class Jun 12, 2025
@mmschlk mmschlk merged commit 4b487a8 into main Jun 12, 2025
7 checks passed
@mmschlk mmschlk deleted the 345-add-a-compute-method-to-the-game-class branch June 12, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a compute() method to the Game class

2 participants