Fix tests that pass for the wrong reason, and export ZeroInflatedImputer - #217
Open
vahid-ahmadi wants to merge 3 commits into
Open
vahid-ahmadi wants to merge 3 commits into
vahid-ahmadi wants to merge 3 commits into
Conversation
tests/test_autoimpute.py named Matching unconditionally whenever MDN was absent, though HAS_MATCHING was already computed and unused. Without rpy2 that raised NameError before the call under test ran, which is the whole of #204: eight errors that looked like failures of the code under test. An available_models() helper builds the list from what actually imported. That NameError was also masking a real problem. Four pytest.raises calls had no match=, so they passed on any exception - including that NameError. test_autoimpute_missing_predictors was passing on it rather than on the missing-column error it claims to test, which is visible now that each raises names the message it expects. A fifth test asserted inside an except branch, so it would have passed silently if predict ever stopped raising, and a sixth skipped its assertion when both losses were NaN, which is exactly the case #210 produces. ZeroInflatedImputer was reachable only by full module path despite being a documented feature of the paper. DEFAULT_MODEL_PARAMS and VALID_YEARS had no references anywhere in the package, and the Imputer.fit docstring still described the bootstrap resampling scheme that was replaced by native sample_weight support. Fixes #204
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Matching surfaces a missing predictor from R rather than from pandas, so the message differs from the other models'. Only visible where rpy2 and StatMatch are installed.
This was referenced Sep 17, 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.
Fixes #204 and addresses the test and export items from #213.
The autoimpute tests select models that actually imported, so environments without optional R or MDN dependencies exercise the available models. Error tests check their expected messages, and the determinism test rejects missing losses before comparing results.
ZeroInflatedImputeris available from bothmicroimputeandmicroimpute.models.VALID_YEARSandDEFAULT_MODEL_PARAMSremain importable with their existing values for compatibility, including the two bundled notebooks that import survey years. Comments distinguish those legacy values from runtime model defaults. The fit docstring describes native sample weights, and the Markdown examples pass the formatter.Validation: six new public-API cases first produced 4 failures and 2 passing alias controls. Restoring compatibility imports brought the complete affected suite to 127 passing tests.
Final commit:
edc372c19a622b385048e59a84b9ad04f8c4bfb6. All eight checks passed. Python 3.14 CI passed 359 tests with 2 skipped, including all 13 real R/StatMatch Matching tests; the pipeline example passed. Python 3.12 smoke tests, documentation, lint, changelog and deployment checks also passed. The two skipped modules require optional MDN dependencies. Coverage XML was generated; the existing Codecov upload step reported its nonblocking protected-branch token error.The exact final heads of #214, #215, #216 and #217 also merge cleanly together. Their combined suite passed 350 tests with 3 optional skips, and the combined source distribution, wheel, import and numerical smoke checks passed. Merge these before #219, then rebase #219 while retaining its broader correctness fixes.