Add Game.compute function and related test to the Game class#397
Merged
Add Game.compute function and related test to the Game class#397
Game.compute function and related test to the Game class#397Conversation
mmschlk
requested changes
Jun 4, 2025
Owner
|
This PR closes #345 |
mmschlk
requested changes
Jun 4, 2025
| self.precompute_flag = True | ||
|
|
||
| def compute( | ||
| self, coalitions: np.ndarray | None = None, *, return_normalization: bool = False |
Owner
There was a problem hiding this comment.
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.
mmschlk
approved these changes
Jun 12, 2025
| coalitions: The coalitions to evaluate. | ||
|
|
||
| Returns: | ||
| A tuple containing: |
Owner
There was a problem hiding this comment.
I deleted the return types because sphinx will display automatically and then we do not have to maintain two parts of the code. :)
Game.compute function and related test to the Game class
Game.compute function and related test to the Game classGame.compute function and related test to the Game class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds a
Game.compute()function to theshapiq.Gameclass. 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 theGameobject. This PR also adds an utility functiongenerate_interaction_lookup_from_coalitionsfor creating an interaction lookup dict from an arbitrary coalition array.