Skip to content

Fix the Python test suite and the zero-density pipeline - #200

Open
Chessing234 wants to merge 2 commits into
teorth:mainfrom
Chessing234:fix-python-test-suite
Open

Fix the Python test suite and the zero-density pipeline#200
Chessing234 wants to merge 2 commits into
teorth:mainfrom
Chessing234:fix-python-test-suite

Conversation

@Chessing234

@Chessing234 Chessing234 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Two things are broken on main, both easy to hit.

python tests/test_all.py never reaches an assertion. tests/test_affine2.py imports large_values.max_of, removed in "Remove redundant code" (Oct 2024) along with the affine max machinery, and test_all.py imports that module first. I rebuilt the same edge case against what survived — Affine2/Piecewise.min_with — with a value check against the naive minimum, so it still tests something.

lv_zlv_to_zd crashes part-way through. #194 made try_union raise on an input with extreme rays. But Region._as_disjoint_union_poly uses try_union as a merge attempt and relies on the documented None return to keep the pieces separate, so the raise aborts the caller instead of degrading. Returning None there restores the pipeline and still never produces a wrong envelope. That same raise also aborted run_union_test, which calls try_union on an unbounded pair and drops the result.

Evidence, on python 3.13 with pycddlib<3:

  • before: python tests/test_all.py stops at the test_affine2 import; after: reaches "All test cases passed."
  • before, on a clean checkout of main:
hs = Hypothesis_Set()
hs.add_hypothesis(lv.large_value_estimate_L2)
hs.add_hypotheses(literature.list_hypotheses(hypothesis_type="Zeta large value estimate"))
zd.lv_zlv_to_zd(hs, Interval(frac(1,2), 1), tau0=frac(3))

raises ValueError: Polytope.try_union only supports finite polytopes; with this branch it returns A(x) \leq 7/6 - x/3 on [1/2,1).

tests/test_affine2.py imported large_values.max_of, which was deleted in
"Remove redundant code" (Oct 2024) along with the rest of the affine max
machinery. The import has raised ImportError ever since, and test_all.py
imports this module first, so `python tests/test_all.py` never reached a
single assertion.

Rebuild the same edge case against the machinery that survived: fold the
five affine functions with Piecewise.min_with over the same region, check
the pieces tile it without overlap, and cross-check every sample point
against the naive minimum.
try_union is documented to return None when the union of its inputs is
not a polytope, and Region._as_disjoint_union_poly relies on that: it
tries to merge a group of pieces and keeps them separate when the merge
fails. Raising on an unbounded input therefore aborts the caller instead
of degrading, and lv_zlv_to_zd - the main zero-density pipeline - dies
part-way through with "only supports finite polytopes".

Return None for those inputs instead, and assert that in the two union
tests. The envelope is still never wrong, since the vertex-only
feasibility checks cannot see extreme rays. run_union_test also called
try_union on an unbounded pair and dropped the result, which is what
aborted the whole test module.
@Chessing234
Chessing234 force-pushed the fix-python-test-suite branch from a77ac65 to 8cc5c0a Compare August 16, 2026 15:39
@Chessing234 Chessing234 changed the title Make python tests/test_all.py run to completion Fix the Python test suite and the zero-density pipeline Aug 16, 2026
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