Skip to content

Conversation

@gjbex
Copy link
Owner

@gjbex gjbex commented Sep 14, 2025

Summary

  • add plot_intersection_tree helper to render intersection trees
  • connect each interval's midpoint to the midpoints of its children

Testing

  • python -m py_compile source_code/intersection_trees/intersection_tree.py
  • pytest

https://chatgpt.com/codex/tasks/task_e_68c6ce8520888329ad1c08c2a4289305

Summary by Sourcery

New Features:

  • Add plot_intersection_tree function to traverse an intersection tree, plot each interval as a horizontal line at its depth with start, end, and max_end annotations, and draw connections between parent and child midpoints.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 14, 2025

Reviewer's Guide

This PR implements a new helper function, plot_intersection_tree, which traverses an existing intersection tree structure and uses matplotlib to render each interval as a horizontal line annotated with its bounds and max_end, then connects interval midpoints to illustrate parent–child relationships.

Class diagram for intersection tree plotting helper

classDiagram
class Node {
  float _start
  float _end
  float _max_end
  Node _left
  Node _right
}
class plot_intersection_tree {
  +plot_intersection_tree(tree: Node) None
}
Node <|-- plot_intersection_tree: uses
Loading

Flow diagram for intersection tree plotting process

flowchart TD
  A["plot_intersection_tree(tree: Node)"] --> B["Traverse tree and collect nodes with depth"]
  B --> C["Draw intervals as horizontal lines"]
  C --> D["Annotate start, end, and max_end"]
  D --> E["Record midpoints for each node"]
  E --> F["Connect parent midpoints to child midpoints"]
  F --> G["Show plot with axes and title"]
Loading

File-Level Changes

Change Details Files
Add plot_intersection_tree helper for visualizing intersection trees
  • Define and document plot_intersection_tree with parameters and behavior
  • Traverse the tree recursively to collect nodes with their depths
  • Draw each interval as a horizontal line with start/end markers and text annotations for bounds and max_end
  • Compute and store midpoints for each node, then draw gray lines connecting parent to child midpoints
  • Configure axes labels, depth limits, title, and display the plot
source_code/intersection_trees/intersection_tree.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gjbex gjbex merged commit 8f8cde2 into development Sep 14, 2025
1 check passed
@gjbex gjbex deleted the codex/add-matplotlib-visualization-for-intersection-tree branch September 14, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants