Skip to content

makes addition and subtraction work also for ivs of different index#423

Merged
mmschlk merged 1 commit intomainfrom
main-iv-add-subtract
Aug 4, 2025
Merged

makes addition and subtraction work also for ivs of different index#423
mmschlk merged 1 commit intomainfrom
main-iv-add-subtract

Conversation

@mmschlk
Copy link
Copy Markdown
Owner

@mmschlk mmschlk commented Aug 4, 2025

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

  • No Public API changes
  • Yes, Public API changes (Details below)

How Has This Been Tested?

Existing Test has been updated to account for the correct indices in the objects and the UserWarning.


Checklist

  • The changes have been tested locally.
  • Documentation has been updated (if the public API or usage changes).
  • An entry has been added to CHANGELOG.md (if relevant for users).
  • The code follows the project's style guidelines.
  • I have considered the impact of these changes on the public API.

@mmschlk mmschlk requested a review from Copilot August 4, 2025 13:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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

Comment thread src/shapiq/interaction_values.py
@mmschlk mmschlk merged commit 01f7694 into main Aug 4, 2025
9 checks passed
@mmschlk mmschlk deleted the main-iv-add-subtract branch August 4, 2025 13:59
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.

2 participants