Skip to content

Commit

Permalink
Fix circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kklemon committed Sep 25, 2024
1 parent 8f77304 commit 6466dd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/penai/shape_name_generation/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def generate_name_impl(
frame_bbox = result.artifacts.bounding_boxes[top_frame.shape_id]

message_builder.with_text_message(
f"The bounding box (x1, y1, x2, y2) of the design document is {format_bbox(frame_bbox)} while the "
f"design element is located at {format_bbox(bbox)}."
f"The bounding box (x1, y1, x2, y2) of the design document is {frame_bbox.format_as_string()} while the "
f"design element is located at {bbox.format_as_string()}."
)

message_builder.with_text_message(
Expand Down
7 changes: 7 additions & 0 deletions src/penai/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ def intersects(self, other: Self) -> bool:
return False
return True

def format_as_string(self) -> str:
"""Format a bounding box as a string."""
bbox_tuple = self.to_view_box_tuple()
bbox_values = [str(round(value)) for value in bbox_tuple]
bbox_str = "[" + ", ".join(bbox_values) + "]"
return bbox_str

def __eq__(self, other: object) -> bool:
if not isinstance(other, BoundingBox):
return False
Expand Down
9 changes: 0 additions & 9 deletions src/penai/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import requests_cache
from cssutils import CSSParser

from penai.svg import BoundingBox
from penai.types import PathLike, RGBColor


Expand All @@ -35,14 +34,6 @@ def random_rgb_color() -> RGBColor:
return f"#{rgb[0]:02x}{rgb[1]:02x}{rgb[2]:02x}"


def format_bbox(bbox: BoundingBox) -> str:
"""Format a bounding box as a string."""
bbox_tuple = bbox.to_view_box_tuple()
bbox_values = [str(round(value)) for value in bbox_tuple]
bbox_str = "[" + ", ".join(bbox_values) + "]"
return bbox_str


def get_project_root() -> Path:
"""Get the root directory of the project."""
return Path(__file__).parent.parent.parent.parent.resolve()
Expand Down

0 comments on commit 6466dd7

Please sign in to comment.