Fix interval generation inconsistency between naive and intersection tree implementations#6
Merged
gjbex merged 2 commits intodevelopmentfrom Sep 11, 2025
Conversation
Co-authored-by: gjbex <4801336+gjbex@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] When I compare the number of intervals returned by the
Fix interval generation inconsistency between naive and intersection tree implementations
Sep 11, 2025
naive_intersectionic_queries.execute_queries and intersection_tree.execute_queries the number of intervals is different. The database as well as the query intervals are identical. Can you fin...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When comparing the number of intervals returned by
naive_intersectionic_queries.execute_queriesandintersection_tree.execute_querieswith identical databases and query intervals, the results were different. This inconsistency made it impossible to verify the correctness of the intersection tree optimization.Root Cause
The bug was in the
generate_intervalfunction inintersection_tree.py. While the naive implementations correctly followed the mathematical specification from the notebook that intervals must satisfyend - start > 1, the intersection tree implementation used a weaker constraint:This caused the implementations to generate completely different intervals when using the same random seed, leading to different databases and consequently different query results.
Solution
intersection_tree.generate_interval()to usestart + 2instead ofstart + 1end - start >= 1toend - start > 1to match the mathematical specificationVerification
Comprehensive testing confirms that:
naive_intersectionic_queries,intersection_tree, andnaive_pythonic_intersectionic_queries) now generate identical intervalsend - start > 1is satisfied by all generated intervalsExample verification:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.