Skip to content

test: comprehensive causal_prediction tests with synthetic data and PR #1371 regression coverage#1654

Open
emrekiciman with Copilot wants to merge 3 commits into
mainfrom
copilot/improve-causal-prediction-tests
Open

test: comprehensive causal_prediction tests with synthetic data and PR #1371 regression coverage#1654
emrekiciman with Copilot wants to merge 3 commits into
mainfrom
copilot/improve-causal-prediction-tests

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The existing causal_prediction test suite had 14 mostly structural tests with no coverage of the core regularization logic, CACM training, or the bugs fixed in PR #1371. This PR expands coverage to 51 tests using synthetic tensors.

Shared fixtures

  • gaussian_reg — pre-built Regularizer(E_conditioned=True, gaussian, gamma=1.0); auto-skips when torch absent
  • tiny_dataset_factory — factory for torch.utils.data.Dataset integer sequences

New coverage

  • _split_by_attribute — two-label split, single-label passthrough, three-label
  • _optimized_mmd_penalty — correctness vs. naive for gaussian (2- and 3-tensor) and linear kernels; empty-tensor skip; float64 small-gamma precision
  • unconditional_reg — all four branches (E_eq_A × E_conditioned), both optimization modes
  • _compute_conditional_penalty — positive/zero penalty cases, value-based grouping, optimization equivalence
  • conditional_reg — all branches, optimization equivalence, cross-env merging
  • CACMattr_types=None / E_eq_A=None defaults, no mutable-default aliasing, training_step with all attr types
  • AdamW — base-class acceptance, configure_optimizers return type
  • ERM — end-to-end training_step with synthetic data
  • Dataloadersplit_dataset size, reproducibility, seed sensitivity

PR #1371 regression tests

Test Bug covered
test_compute_conditional_penalty_value_based_grouping Tensor-as-dict-key: equal-valued tensors from different envs treated as distinct keys → inflated penalty
test_unconditional_reg_not_e_conditioned_same_attr_gives_no_penalty Old code computed spurious cross-env MMD when both envs share one attribute value
test_conditional_reg_not_e_conditioned_cross_env_merging Cross-env sample merging in conditional_reg
test_cacm_e_eq_a_none_does_not_raise attr_type_idx in None raised TypeError with old E_eq_A=[] default
test_optimized_mmd_penalty_fp64_precision_small_gamma Float32 vanishing penalty for gamma ≤ 1e-6; fixed by float64 accumulation

Copilot AI and others added 3 commits July 7, 2026 07:01
…nd PR #1371 regression coverage

Co-authored-by: emrekiciman <5982160+emrekiciman@users.noreply.github.com>
…fixtures

Co-authored-by: emrekiciman <5982160+emrekiciman@users.noreply.github.com>
…ssage, and momentum clarity

Co-authored-by: emrekiciman <5982160+emrekiciman@users.noreply.github.com>
Copilot AI changed the title test: add comprehensive causal_prediction tests with synthetic data and PR #1371 regression coverage test: comprehensive causal_prediction tests with synthetic data and PR #1371 regression coverage Jul 7, 2026
Copilot AI requested a review from emrekiciman July 7, 2026 07:09
@emrekiciman
emrekiciman requested a review from amit-sharma July 7, 2026 07:18
@emrekiciman
emrekiciman marked this pull request as ready for review July 13, 2026 21:25
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.

2 participants