Skip to content

Commit

Permalink
fix: slight optimization to get_bound and generic bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Nov 28, 2024
1 parent d516d93 commit 1b5cf63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion playa/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,8 +1684,10 @@ def object_type(self):

@property
def bbox(self) -> Rect:
# These bboxes have already been computed in device space so
# we don't need all 4 corners!
points = itertools.chain.from_iterable(
((x0, y0), (x0, y1), (x1, y1), (x1, y0))
((x0, y0), (x1, y1))
for x0, y0, x1, y1 in (item.bbox for item in self)
)
return get_bound(points)
Expand Down
2 changes: 1 addition & 1 deletion playa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def get_bound(pts: Iterable[Point]) -> Rect:
Raises:
ValueError on empty input (as there is no bounding box).
"""
xs, ys = list(zip(*pts))
xs, ys = zip(*pts)
x0 = min(xs)
y0 = min(ys)
x1 = max(xs)
Expand Down

0 comments on commit 1b5cf63

Please sign in to comment.