Skip to content

Fix tests that pass for the wrong reason, and export ZeroInflatedImputer - #217

Open
vahid-ahmadi wants to merge 3 commits into
mainfrom
fix/213-exports-and-cleanup
Open

vahid-ahmadi wants to merge 3 commits into
mainfrom
fix/213-exports-and-cleanup

Conversation

@vahid-ahmadi

@vahid-ahmadi vahid-ahmadi commented Sep 16, 2026

Copy link
Copy Markdown

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.

ZeroInflatedImputer is available from both microimpute and microimpute.models. VALID_YEARS and DEFAULT_MODEL_PARAMS remain 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.

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
@vercel

vercel Bot commented Sep 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
microimpute-dashboard Ready Ready Preview Sep 17, 2026 10:36am UTC

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.
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.

Test suite fails with 8 errors on a clean checkout without rpy2

2 participants