fix: remove dead branch in WealthPercentileTransformer.fit (#168) - #176
Closed
Larslllllll wants to merge 2 commits into
Closed
fix: remove dead branch in WealthPercentileTransformer.fit (#168)#176Larslllllll wants to merge 2 commits into
Larslllllll wants to merge 2 commits into
Conversation
added 2 commits
September 6, 2026 02:06
…umns Add two unit tests pinning the behaviour of all-NaN and partially-NaN wealth columns: the all-missing branch must return NaN ranks, keep a stable output width, and raise no warning; the partial-missing branch must rank only observed values and propagate NaN to the rank column. Closes PhilanthroPy-Project#169.
The hasattr(X, "columns") branch in fit() never executed because validate_data() returns a NumPy array, which never has a .columns attribute. validate_data() itself sets feature_names_in_ when given a DataFrame, so the column names are preserved regardless. The elif branch (array-input path) was doing all the work. Deleted the dead branch and promoted the elif to a plain if. Added test_wealth_percentile_feature_names_match_for_frame_and_array_input to pin the expected feature names for both input types, proving the deletion is safe. Fixes PhilanthroPy-Project#168
4 tasks
shivamlalakiya
pushed a commit
that referenced
this pull request
Sep 6, 2026
Closes #156. WealthPercentileTransformer.fit now raises an actionable ValueError when an explicit wealth_cols list matches no training column; partial matches and automatic detection are unchanged. Also removes the dead hasattr(X, 'columns') branch in fit, which closes #168 and subsumes PRs #175 and #176.
5 tasks
Contributor
|
Thank you, @Larslllllll. Closing this one as already-landed rather than rejected, and your credit is safe on both counts. Where each piece went:
So everything in this PR is on The duplication with #175 the same evening was our process failure, not yours. A "claim the issue before you open a PR" rule is going into CONTRIBUTING.md so contributors stop colliding like this. |
2 tasks
shivamlalakiya
added a commit
that referenced
this pull request
Sep 6, 2026
…attempt (#187) Two follow-ups after the #175/#176 duplicate-PR triage: - CONTRIBUTING.md gets a "Claiming an issue" rule (comment before opening a PR, wait for maintainer assignment) so two people never again spend an evening fixing the same four-line bug. The issue-draft template states the same rule inline, so every newly filed good-first-issue carries it without depending on a reader following a link. - @HeaTTap independently identified and fixed the same dead `hasattr(X, "columns")` branch as @Larslllllll, via #175. That PR was closed as subsumed by #179 (which carried the same fix), but @HeaTTap had no CONTRIBUTORS.md line as a result; Lars was already credited via #174. This adds it.
This was referenced Sep 6, 2026
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.
Summary
The
hasattr(X, "columns")branch infit()never executed becausevalidate_data()returns a NumPy array, which never has a.columnsattribute.validate_data()itself setsfeature_names_in_when given a DataFrame, so the column names are preserved regardless.The
elifbranch (array-input path) was doing all the work. This PR deletes the dead branch and promotes theelifto a plainifwith an explanatory comment.Changes
if hasattr(X, "columns"):branchelifto a plainifwith comment explaining why the check is onselfnotXtest_wealth_percentile_feature_names_match_for_frame_and_array_inputto pin expected feature names for both DataFrame and array inputsVerification
Fixes #168