Skip to content

Fix #611: cache per-feature DL syntax in TDL_refinement._merge_binary_feature_matrices - #619

Merged
Demirrr merged 1 commit into
developfrom
fix-611-tdl-refinement-dl-syntax-caching
Aug 11, 2026
Merged

Demirrr merged 1 commit into
developfrom
fix-611-tdl-refinement-dl-syntax-caching

Conversation

@Demirrr

@Demirrr Demirrr commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

  • TDL_refinement._merge_binary_feature_matrices re-rendered each candidate feature's DL syntax string from scratch inside the innermost (per-example) loop, giving O(examples × features × expression-size) work instead of O(features × expression-size). owl_expression_to_dl recursively walks the expression tree so its cost scales with expression complexity.
  • Precompute dl_by_feature = {f: owl_expression_to_dl(f) for f in new_features_list} once before the example loop and look up from that dict inside the loop, as suggested in the issue.
  • Added a CHANGELOG.md entry under [Unreleased] / Changed.

Fixes #611

Test plan

  • ruff check ontolearn/learners/tree_learner_refinement_inherit.py --line-length=200 passes
  • pytest tests/test_tdl_refinement.py — could not run in this environment due to a pre-existing, unrelated pandas/bottleneck ABI mismatch (AttributeError: _ARRAY_API not found) that reproduces on develop as well, before this change. Please run CI to confirm.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MLhnPY616ht2DRE275DuCE

…ure_matrices

owl_expression_to_dl recursively walks the expression tree, so re-rendering
it for every example was O(examples x features x expression-size) instead
of O(features x expression-size). Cache the rendering per feature before
the example loop.

Fixes #611

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MLhnPY616ht2DRE275DuCE
@Demirrr
Demirrr force-pushed the fix-611-tdl-refinement-dl-syntax-caching branch from e5a92c4 to 3a3121c Compare August 11, 2026 06:33
@Demirrr
Demirrr marked this pull request as ready for review August 11, 2026 06:33
@Demirrr
Demirrr merged commit 84a6e94 into develop Aug 11, 2026
2 checks passed
@Demirrr
Demirrr deleted the fix-611-tdl-refinement-dl-syntax-caching branch August 11, 2026 07:17
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.

TDL_refinement: DL-syntax rendering repeated per-example instead of per-feature in _merge_binary_feature_matrices

1 participant