Skip to content

Simplify cnf_manager.py: remove dead code, deduplicate, fix types#4

Merged
omereliy merged 5 commits into
masterfrom
cnf-manager-cleanup
Mar 14, 2026
Merged

Simplify cnf_manager.py: remove dead code, deduplicate, fix types#4
omereliy merged 5 commits into
masterfrom
cnf-manager-cleanup

Conversation

@omereliy

Copy link
Copy Markdown
Owner

Summary

  • Remove 10 unused/obsolete methods from cnf_manager.py, reducing 838 → 582 lines (-30%)
  • Extract _literals_to_var_clause and _enumerate_models helpers to eliminate code duplication
  • Modernize type hints to Python 3.10+ and fix all 5 mypy errors in the file

Test plan

  • All 211 tests pass (uv run pytest tests/ -v)
  • Zero mypy errors in cnf_manager.py
  • AMLGym blocksworld experiment: precision/recall = 1.0 (identical to pre-cleanup)
  • Local framework quick mode: 5/5 domains pass (identical to pre-cleanup)

Remove 10 unused/obsolete methods (minimize_qm, _rebuild_from_solutions,
minimize_espresso, get_variable, add_var_clause, remove_clause, merge,
create_with_state_constraints, add_unit_constraint,
add_constraint_from_unsatisfied) reducing the file from 838 to 582 lines.

Extract _literals_to_var_clause helper to consolidate 4 duplicated
literal-to-variable conversion sites, and _enumerate_models to
deduplicate the SAT model counting loop.

Modernize all type hints to Python 3.10+ style, fix all 5 mypy errors,
and fix __repr__ to not trigger SAT solve on print.

Replace removed-method tests with production API tests
(state_constraints_to_assumptions, count_models_with_temporary_clause).
All 211 tests pass, experiments produce identical results.
mypy was missing from the dependency group, causing CI type checking
to fail with "No such file or directory".
  2. _invalidate_cache() moved after loop — called once instead of per-iteration
  3. assumptions is not None — correct empty-list handling
Fix real bugs in model_metrics.py (wrong class name, missing constructor
args, wrong attribute access), add null guards in information_gain.py
and active_environment.py, fix forward references in parallel_gain.py,
and add missing type annotations across 11 files.
@omereliy omereliy merged commit aa53212 into master Mar 14, 2026
3 checks passed
@omereliy omereliy deleted the cnf-manager-cleanup branch March 14, 2026 17:03
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.

1 participant