Skip to content

Fix AttributeError in DRILLSearchTreePriorityQueue.get_top_n - #605

Merged
Demirrr merged 2 commits into
developfrom
fix/search-798-drill-get-top-n
Aug 6, 2026
Merged

Demirrr merged 2 commits into
developfrom
fix/search-798-drill-get-top-n

Conversation

@Demirrr

@Demirrr Demirrr commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes item 1 in Improvements.md: DRILLSearchTreePriorityQueue.get_top_n() (ontolearn/search.py:798) referenced self.refined_nodes, an attribute that is never assigned anywhere in the codebase, and attempted + on a dict_values object — both raise at runtime (AttributeError/TypeError) any time this method is called.
  • Replaced with all_nodes = list(self.nodes.values()) and removed the subsequent no-op all_nodes.union(self.nodes) call, whose result was discarded and which would also fail since list has no .union() method.
  • Added tests/test_search.py with regression tests for get_top_n() covering the quality, heuristic, and result-size-limiting behavior.

Test plan

  • pytest tests/test_search.py -p no:warnings -v passes on this branch
  • Confirmed the new tests fail with AttributeError: 'DRILLSearchTreePriorityQueue' object has no attribute 'refined_nodes' against the pre-fix version of ontolearn/search.py

🤖 Generated with Claude Code

Demirrr and others added 2 commits August 6, 2026 11:59
self.refined_nodes was never assigned anywhere, and dict.values()
doesn't support +. Replace with list(self.nodes.values()); drop the
useless all_nodes.union(self.nodes) call whose result was discarded.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Covers ontolearn/search.py:798: previously get_top_n() referenced the
never-assigned self.refined_nodes and tried to add it to a dict_values
object, raising AttributeError. These tests fail against the pre-fix
code and pass against the fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Demirrr
Demirrr merged commit 6c6dcb3 into develop Aug 6, 2026
2 checks passed
@Demirrr
Demirrr deleted the fix/search-798-drill-get-top-n branch August 6, 2026 11:29
@Demirrr Demirrr mentioned this pull request Oct 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