Skip to content

Fix issue #12: Implement edge case with empty covariate set for MINT … - #19

Merged
RickardKarl merged 1 commit into
mainfrom
dev
Mar 4, 2026
Merged

Fix issue #12: Implement edge case with empty covariate set for MINT …#19
RickardKarl merged 1 commit into
mainfrom
dev

Conversation

@RickardKarl

Copy link
Copy Markdown
Owner

…(#18)

This commit addresses GitHub issue #12 and provides a fix for the related bug in issue #7 where MINT would crash with confusing error messages.

Changes:

  1. Enable MINT to handle empty covariate sets (covariate_vars=[])

    • Added proper handling in polynomial feature generation
    • Updated independence test to handle 1D parameter arrays
    • Ensured model fitting always returns 2D arrays
  2. Improved error handling for insufficient samples

    • Added validation to catch empty coefficient lists early
    • Provides clear, actionable error message instead of cryptic "Need at least one array to concatenate" error
  3. Comprehensive test suite for edge cases

    • Tests for empty covariates with different outcome/treatment types
    • Tests for polynomial features with empty covariates
    • Tests for insufficient samples error handling

All existing tests pass. The fix is backward compatible.

Fixes #12
Related to #7

  • Update mint.py

Add len(coef_treatment_mech) == 0 to ValueError check

  • Update test_mint_edge_cases.py

Remove unnecessary check of error test strings

  • Delete ISSUE_12_FIX_SUMMARY.md

  • Update mint.py

Fix consistent output shape of fit_model_jax

  • Fix array shapes

…18)

* Fix issue #12: Implement edge case with empty covariate set for MINT

This commit addresses GitHub issue #12 and provides a fix for the related
bug in issue #7 where MINT would crash with confusing error messages.

Changes:
1. Enable MINT to handle empty covariate sets (covariate_vars=[])
   - Added proper handling in polynomial feature generation
   - Updated independence test to handle 1D parameter arrays
   - Ensured model fitting always returns 2D arrays

2. Improved error handling for insufficient samples
   - Added validation to catch empty coefficient lists early
   - Provides clear, actionable error message instead of cryptic
     "Need at least one array to concatenate" error

3. Comprehensive test suite for edge cases
   - Tests for empty covariates with different outcome/treatment types
   - Tests for polynomial features with empty covariates
   - Tests for insufficient samples error handling

All existing tests pass. The fix is backward compatible.

Fixes #12
Related to #7

* Update mint.py

Add len(coef_treatment_mech) == 0 to ValueError check

* Update test_mint_edge_cases.py

Remove unnecessary check of error test strings

* Delete ISSUE_12_FIX_SUMMARY.md

* Update mint.py

Fix consistent output shape of fit_model_jax

* Fix array shapes

---------

Co-authored-by: Claude <noreply@anthropic.com>
@RickardKarl
RickardKarl merged commit a84e87a into main Mar 4, 2026
1 check passed
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.

Implement edge case with empty covariate set for MINT

1 participant