Skip to content

feat: raise ValueError when variables and missing_only=True are used together in AddMissingIndicator and DropMissingData#912

Open
direkkakkar319-ops wants to merge 16 commits intofeature-engine:mainfrom
direkkakkar319-ops:issue-905-missing-only-variables-mutually-exclusive
Open

feat: raise ValueError when variables and missing_only=True are used together in AddMissingIndicator and DropMissingData#912
direkkakkar319-ops wants to merge 16 commits intofeature-engine:mainfrom
direkkakkar319-ops:issue-905-missing-only-variables-mutually-exclusive

Conversation

@direkkakkar319-ops
Copy link

@direkkakkar319-ops direkkakkar319-ops commented Mar 8, 2026

Description

Fixes #905

Makes variables and missing_only=True mutually exclusive in both AddMissingIndicator and DropMissingData. Previously, passing both silently produced confusing behaviour — variables with no missing data would be quietly dropped from the output with no indication to the user.

Changes

feature_engine/imputation/missing_indicator.py

  • Added ValueError in __init__() when variables is not None and missing_only=True
  • Updated docstrings for variables and missing_only to document mutual exclusivity

feature_engine/imputation/drop_missing_data.py

  • Same validation and docstring updates

tests/test_imputation/test_missing_indicator.py

  • 3 new tests: raises on invalid combo, valid with missing_only=False, valid with variables=None
  • Updated existing tests that implicitly relied on default missing_only=True alongside variables

tests/test_imputation/test_drop_missing_data.py

  • Same 3 new tests
  • Same existing test updates

docs/whats_new/v_190.rst

  • Changelog entry added

Type of Change

  • Bug fix
  • New feature (non-breaking)
  • Breaking change
  • Documentation update

Tests

pytest tests/test_imputation/test_missing_indicator.py tests/test_imputation/test_drop_missing_data.py
23 passed

Notes

  • Default behaviour (variables=None, missing_only=True) is completely unchanged
  • Users passing both variables and missing_only=True now get a clear ValueError instead of silent unexpected output
image

@direkkakkar319-ops direkkakkar319-ops marked this pull request as ready for review March 9, 2026 19:06
@direkkakkar319-ops
Copy link
Author

Hi @solegalli
All 13 CI checks are green, including test_style, test_type, and all Python/sklearn matrix builds.
This PR is ready for your review. Happy to make any changes based on your feedback!

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (f72a2b7) to head (dc34edf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #912   +/-   ##
=======================================
  Coverage   98.27%   98.27%           
=======================================
  Files         116      116           
  Lines        4978     4996   +18     
  Branches      795      804    +9     
=======================================
+ Hits         4892     4910   +18     
  Misses         55       55           
  Partials       31       31           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@direkkakkar319-ops
Copy link
Author

@solegalli, @ankitlade12 Hi! I'm facing issues with the two failing codecov checks on this PR:

  • codecov/patch: Currently at 93.33% but the target is 98.27%
  • codecov/project: Dropped by 0.04% compared to f72a2b7

Could you help me understand:

  1. Which specific lines/files are not covered by tests?
  2. Are there any existing tests I can extend, or should I add new test cases?

I want to bring the patch coverage up to meet the target. Any guidance would be appreciated.

@solegalli
Copy link
Collaborator

solegalli commented Mar 15, 2026 via email

@direkkakkar319-ops
Copy link
Author

Hey @solegalli,no worries at all ,take your time! I hope you're enjoying your travels.
I'll also take the opportunity to look into the 2 failing checks before you're back, and will try to get those resolved.Looking forward to your feedback on the 21st. Thanks again

@direkkakkar319-ops direkkakkar319-ops force-pushed the issue-905-missing-only-variables-mutually-exclusive branch from 8eb611c to 213acab Compare March 16, 2026 10:19
@direkkakkar319-ops
Copy link
Author

there were few local file that were push to this branch , I removed them

@direkkakkar319-ops
Copy link
Author

Fixed the Codecov patch coverage failure by adding a missing test for the errors='warn' branch in the single variable path of CategoricalImputer. This branch was previously not being hit by any test

all the test cases have also passed
Screenshot 2026-03-16 153721

the 15CI checks including the 2 codecov checks have also passes

changes file :-
tests/test_imputation/test_categorical_imputer.py

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.

revise the use of missing_only in AddMissingIndicartors

2 participants