Skip to content

Fix test failures and add coverage for counterfactual, claims, and paths modules#1089

Merged
SkBlaz merged 3 commits intomasterfrom
copilot/improve-test-coverage-de8aa39d-b5ab-41bc-9ab5-31b8b968a49a
Jan 14, 2026
Merged

Fix test failures and add coverage for counterfactual, claims, and paths modules#1089
SkBlaz merged 3 commits intomasterfrom
copilot/improve-test-coverage-de8aa39d-b5ab-41bc-9ab5-31b8b968a49a

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 14, 2026

Recent additions to counterfactual, claims, and paths modules lacked comprehensive test coverage. This PR fixes 4 failing tests and adds 44 new tests covering edge cases and core functionality.

Bugs Fixed

  • KnockoutSpec edge removal: Deduplicate edges before removal to prevent NetworkX double-removal errors when multiple knockout nodes share edges
  • Exception types: Updated tests to expect AlgorithmError instead of ValueError for domain-specific path algorithm errors
  • Flaky seed test: Increased intervention strength (0.2 → 0.5) and repeats (10 → 20) to ensure statistical differentiation

New Test Coverage

Counterfactual presets (19 tests):

  • All preset configurations and strength variations (light/medium/heavy)
  • Hashability, serialization, default behavior

Claims types (25 tests):

  • Antecedent/Consequent evaluation for all operators (>=, >, <=, <, =)
  • DSL string conversion for threshold, top_p, layer_count, and rank predicates
  • ClaimScore validation and rounding behavior
  • Claim immutability and serialization

Example

# Before: Double removal error
spec = KnockoutSpec(nodes=('a', 'b'), mode='replicas')
modified = spec.apply(net, seed=42)  # NetworkXError: edge not in graph

# After: Edges deduplicated
spec = KnockoutSpec(nodes=('a', 'b'), mode='replicas')
modified = spec.apply(net, seed=42)  # ✓ Works correctly

Test Results

231 tests passing across counterfactual (46), claims (50), paths (48), linter (23), wrappers (30), and temporal_utils_extended (19) modules.

Original prompt

This section details on the original issue you should resolve

<issue_title>test coverage improvements</issue_title>
<issue_description>Double check recent additions, pin with tests where missing</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 14, 2026 15:02
Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
…ypes

Co-authored-by: SkBlaz <10035780+SkBlaz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test coverage improvements for recent additions Fix test failures and add coverage for counterfactual, claims, and paths modules Jan 14, 2026
Copilot AI requested a review from SkBlaz January 14, 2026 15:10
@SkBlaz SkBlaz marked this pull request as ready for review January 14, 2026 16:53
@SkBlaz SkBlaz merged commit 7717648 into master Jan 14, 2026
32 checks 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.

test coverage improvements

2 participants