fix: use parametrized test values in PrototypeRepresentationLearner tests#1626
Merged
taharallouche merged 7 commits intofairlearn:mainfrom Feb 28, 2026
Merged
fix: use parametrized test values in PrototypeRepresentationLearner tests#1626taharallouche merged 7 commits intofairlearn:mainfrom
taharallouche merged 7 commits intofairlearn:mainfrom
Conversation
taharallouche
approved these changes
Feb 28, 2026
Member
taharallouche
left a comment
There was a problem hiding this comment.
LGTM thank you @BALOGUN-DAVID 🙏 Before merging, can you please add a short entry in the change log for this bug fix ?
2 tasks
BALOGUN-DAVID
added a commit
to BALOGUN-DAVID/fairlearn
that referenced
this pull request
Feb 28, 2026
…rner test fixes)
Contributor
Author
|
Hi @taharallouche 👋 I've added the changelog entry, Please let me know if any changes are needed. Thanks! |
Member
|
@BALOGUN-DAVID the change in this PR is the bug fix for degenerate sensitive feature values, not test parametrization though. Could you please correct the change log ? |
Contributor
Author
|
Done! I've updated the changelog entry. Thanks for the correction @taharallouche |
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.
[Improvement] – Fix parameterized unit tests and add multi-dimensional sensitive features coverage for PrototypeRepresentationLearner
Description
Context:
The existing unit tests for
PrototypeRepresentationLearnerin Fairlearn had a critical gap: while@pytest.mark.parametrizedecorators were defined to test multiple input variations (includingsensitive_features=Noneandpd.Serieslabels), these parameterized values were immediately overwritten inside the test functions. As a result, key code paths—like theNonesensitive features and string-based label handling—were never tested. Additionally, no tests existed for multi-dimensional sensitive features (e.g., race + gender), which are essential for intersectional fairness assessment in real-world scenarios.Approach:
test_reconstructionandtest_classificationsopytestparametrize runs all intended cases.test_statistical_parity_multi_dimension_sensitive_featurestest_transform_sensitive_features_with_two_dimensionsThese validate behavior with 2D sensitive features.
_merge_columnsutility to correctly merge multi-dimensional columns, mirroring internal learner behavior.Impact:
sensitive_features=Noneand multi-dimensional protected attributes.pd.Series) pass through the pipeline correctly.Visual Proof / Evidence
Screenshots/GIFs should show pytest results with all parametrize combinations passing and coverage report highlighting new multi-dimensional sensitive features tests.
Tests
Unit Tests Summary:
test_reconstructionfixedtest_classificationfixedtest_statistical_parity_multi_dimension_sensitive_featurestest_transform_sensitive_features_with_two_dimensions