Skip to content

Raise test coverage, fix two numerical bugs, and halve test-suite time - #66

Merged
Autoplectic merged 7 commits into
mainfrom
test-coverage-and-speed
Nov 16, 2026
Merged

Autoplectic merged 7 commits into
mainfrom
test-coverage-and-speed

Conversation

@Autoplectic

@Autoplectic Autoplectic commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Raises test coverage, fixes two numerical bugs surfaced by failing tests, and roughly halves the wall-clock time of the default test suite by speeding up the hot numerical paths in sofic itself. Test budgets, tolerances and Hypothesis example counts are unchanged.

Results

Full default suite (coverage on), main vs this branch, run back to back on an idle 10-worker machine:

main this branch
Wall clock 12m41s 6m07s
CPU 3378 s 2766 s
Outcome 1 failed, 2691 passed 2858 passed
Coverage (CI environment, no python-sat/pymc) 88.26% 91.59%
Coverage (all extras installed) 89.40% 92.14%

Bug fixes

  • renyi_entropy_rate near α = 1: pressure(α) / (1 − α) cancels catastrophically within ~1e-8 of 1 (Hypothesis found α = 0.9999999999999999). Inside a 1e-7 window the Shannon rate is returned, where truncation and rounding error balance.
  • topological_entropy_from_matrix: strongly connected components joined by transient edges make the leading eigenvalue defective, so eigvals resolved it only to ~eps ** (1/multiplicity) (up to ~1e-5 for three chained unit cycles). The spectral radius is now the largest over the strongly connected components, whose Perron roots are simple. This made test_properties_shifts.py::test_adding_transient_states_changes_nothing fail on main.

Speedups

Each change is checked against the previous implementation, kept in tests/oracles.py, by a property test. Times are the affected test alone, without coverage, main → branch.

Change Test Before → after
_LiftedProblem: two-operand matrix products instead of 4-operand einsum, tensors cached between SLSQP's constraint and Jacobian calls, all three conditional mutual informations in one entropy pass test_odd_process_wyner_model_generates 231 s → 115 s
(same) test_generative_gap_rll_two_infinity 137 s → 56 s
Mixed-state enumeration: numeric beliefs kept in an array, the candidate window compared in one vectorized check (same np.isclose semantics and first-match order) test_survey_explosion_code_may_build_with_ladder 38.5 s → 4.9 s
_column_box_lp: Cramer's-rule solves for the 3×3 vertex systems instead of batched LAPACK det + solve test_hyperplane_cap_brackets_planted_rank_two_mass 97 s → 22 s
_tighten: exact outward rounding with math.fsum instead of Fraction (bit-identical, so certified caps are unchanged); mu1_vertex: every tree edge's split from one rooted traversal plus one masked argmin per tree (bit-identical) test_lifted_bound_separates_lifted_generators_from_g 37 s → 19 s

pytest now uses --dist=worksteal (requires pytest-xdist>=3.2).

Not changed: the line-split / coupled-generator searches are dominated by ~90k small HiGHS solves (~0.85 ms each); building the LP matrices is ~4% of each call and sparse input is slower.

Coverage

  • Exercised modules that need optional dependencies (dfasat, pymc_backend, trapdoor_code, channel_coding) and filled their remaining paths; tests stay importorskip-guarded.
  • New or extended tests for bayesian/markov, transducers, language operations and residuals, stationary, pfa, papni, CSSR counts, properties, examples/processes, viz edge specs and I-diagram legend layout, idfa, modular VPA minimization, and the bidirectional-construction and generative-search helpers.

CI

test-without-symbolic has been failing on main: four test modules import sympy at module level and one sympy test had no guard. Those tests now skip individually with pytest.importorskip("sympy"); with sympy blocked, the suite gives 2794 passed, 50 skipped.

Dependencies

  • dit>=2.4 (lockfile updated), so the channel-coding and trapdoor tests run in CI instead of skipping. Calls into dit now pass rng= instead of the deprecated prng=.
  • Still open: dit 2.4 deprecates _strategy in functional_markov_chain, which functional_generative_model(strategy=...) passes through. Removing or deprecating that public argument is left for a follow-up.

Ryan James and others added 7 commits November 15, 2026 22:09
…rage tests

Co-authored-by: Cursor <cursoragent@cursor.com>
…ed tensors, batched entropies

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…-pass tree splits in mu1_vertex, closed-form 3x3 vertex solves

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…g= to dit 2.4

Co-authored-by: Cursor <cursoragent@cursor.com>
…tion

Co-authored-by: Cursor <cursoragent@cursor.com>
@Autoplectic
Autoplectic merged commit f6f2404 into main Nov 16, 2026
10 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.

1 participant