makes addition and subtraction work also for ivs of different index#423
Merged
makes addition and subtraction work also for ivs of different index#423
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the behavior of addition and subtraction operations between InteractionValues objects with different indices. Previously, such operations would raise a ValueError; now they emit a UserWarning and proceed with the operation, using the index from the first object.
- Changes error handling from ValueError to UserWarning for different indices during arithmetic operations
- Updates test to validate the new warning behavior and result index preservation
- Documents the change in CHANGELOG.md
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/shapiq/interaction_values.py | Replaces ValueError with UserWarning when adding InteractionValues with different indices |
| tests/shapiq/tests_unit/test_interaction_values.py | Updates test to expect warning instead of error and validates result properties |
| CHANGELOG.md | Documents the new addition/subtraction behavior for different indices |
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.
Motivation and Context
This PR allows adding two InteractionValues objects together wich have a different index. This previously was not possible and returned in an error. Now this will only throw a UserWarning but is technically possible. This could be helpful for experiments.
Public API Changes
How Has This Been Tested?
Existing Test has been updated to account for the correct indices in the objects and the UserWarning.
Checklist
CHANGELOG.md(if relevant for users).