Skip to content

Remove SolutionSpace.sample_tree, which the samplers replaced - #109

Merged
FelixLaarmann merged 1 commit into
developfrom
feature/remove-sample-tree
Sep 2, 2026
Merged

Remove SolutionSpace.sample_tree, which the samplers replaced#109
FelixLaarmann merged 1 commit into
developfrom
feature/remove-sample-tree

Conversation

@FelixLaarmann

Copy link
Copy Markdown
Member

Problem:

SolutionSpace.sample_tree is the predecessor of the samplers. It draws one tree top-down under an
optional depth bound and returns None where nothing came. The samplers of cosy.search draw the
same way through a resolution query, and since the genetic operators moved to them in #108, no
caller of sample_tree is left in the framework. What remains is a second way to draw from a
solution space that nothing asks for.

Changes:

  • sample_tree is removed with no replacement. A caller poses a resolution query and draws through
    a sampler of cosy.search. (BREAKING)
  • The three tests that drew through it draw through DepthBoundedRandomSampler over a generator
    query or a residual query instead, and their names follow.
  • test_a_sample_reaches_more_than_the_nullary_clause_of_the_start_symbol is dropped. It guarded a
    defect of the frontier sample_tree drew from, and
    test_every_completion_within_the_bound_is_drawn_by_some_seed asserts the same property more
    sharply, as set equality with the reachable terms on a space whose start symbol has a nullary
    clause.
  • The skeleton test gains the assertion its sibling already carries, that the seeds reach more than
    one term. Without it the subset direction stays true where the draw stops varying.
  • sample_tree was the only code under src/cosy/core that used the random module, so the S311
    exemption for that path goes with it.
  • Behavior: the seeded terms of test_a_seeded_sample_repeats differ from the ones sample_tree
    produced. The sampler draws its randomness from the clause order rather than from the goals of a
    step, and the property the test needs from the engine is the same one either way.

sample_tree drew one tree top-down under an optional depth bound and returned None where nothing
came. The samplers of cosy.search draw the same way through a resolution query, and since the
genetic operators moved to them, no caller of sample_tree is left in the framework. What remains is
a second way to draw from a solution space that nothing asks for.

The three tests that drew through it draw through DepthBoundedRandomSampler over a generator query
or a residual query instead, and their names follow.

test_a_sample_reaches_more_than_the_nullary_clause_of_the_start_symbol goes with no replacement. It
guarded a defect of the frontier sample_tree drew from, and the property it asserted is asserted
more sharply in tests/test_samplers.py, where test_every_completion_within_the_bound_is_drawn_by_some_seed
requires set equality with the reachable terms on a space whose start symbol has a nullary clause.

The skeleton test gains the assertion its sibling already carries, that the seeds reach more than
one term. Without it the subset direction stays true where the draw stops varying.

The seeded terms of test_a_seeded_sample_repeats differ from the ones sample_tree produced. The
sampler draws its randomness from the clause order rather than from the goals of a step, and the
property the test needs from the engine is the same one either way.

sample_tree was the only code under src/cosy/core that used the random module, so the S311
exemption for that path goes with it.

@tudo-seal-workflows tudo-seal-workflows Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark CoSy

Details
Benchmark suite Current: 44e36bd Previous: be71b5d Ratio
benchmarks/test_benchmark_maximal_elements.py::test_benchmark_maximal_elements 10.273612373811034 iter/sec (stddev: 0.0004668522031856945) 9.608281351562356 iter/sec (stddev: 0.010017085420616013) 0.94
benchmarks/test_benchmark_maze.py::test_benchmark_maze 4.352696216559452 iter/sec (stddev: 0.0236595215939288) 3.9235166334572096 iter/sec (stddev: 0.018797551923491352) 0.90
benchmarks/test_benchmark_maze_contains.py::test_benchmark_maze_contains 3.9859519905236427 iter/sec (stddev: 0.024390729940967856) 3.5391214334611916 iter/sec (stddev: 0.025877608823890046) 0.89
benchmarks/test_benchmark_maze_loopfree.py::test_benchmark_maze_loopfree 4.363107244067764 iter/sec (stddev: 0.01772350745971044) 3.8477221717914887 iter/sec (stddev: 0.02072136799063595) 0.88

This comment was automatically generated by workflow using github-action-benchmark.

@codecov-commenter

codecov-commenter commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.76%. Comparing base (a41fe1a) to head (44e36bd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #109      +/-   ##
===========================================
- Coverage    88.77%   88.76%   -0.01%     
===========================================
  Files           69       69              
  Lines         7456     7435      -21     
  Branches       829      829              
===========================================
- Hits          6619     6600      -19     
+ Misses         741      739       -2     
  Partials        96       96              
Flag Coverage Δ
macos-latest-3.10 88.72% <100.00%> (-0.01%) ⬇️
macos-latest-3.11 88.75% <100.00%> (-0.01%) ⬇️
macos-latest-3.12 88.75% <100.00%> (-0.01%) ⬇️
macos-latest-3.13 88.75% <100.00%> (-0.01%) ⬇️
ubuntu-latest-3.10 88.72% <100.00%> (-0.01%) ⬇️
ubuntu-latest-3.11 88.75% <100.00%> (-0.01%) ⬇️
ubuntu-latest-3.12 88.75% <100.00%> (-0.01%) ⬇️
ubuntu-latest-3.13 88.75% <100.00%> (-0.01%) ⬇️
windows-latest-3.10 88.72% <100.00%> (-0.01%) ⬇️
windows-latest-3.11 ?
windows-latest-3.12 88.75% <100.00%> (-0.01%) ⬇️
windows-latest-3.13 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@FelixLaarmann
FelixLaarmann merged commit 1a6dcbf into develop Sep 2, 2026
15 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.

2 participants