Skip to content

Commit ec6e608

Browse files
authored
refactor: fix bbox typing (#125)
Signed-off-by: Michele Dolfi <[email protected]>
1 parent ae349c1 commit ec6e608

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

docling_core/types/doc/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def normalized(self, page_size: Size) -> "BoundingBox":
8181

8282
return out_bbox
8383

84-
def as_tuple(self):
84+
def as_tuple(self) -> Tuple[float, float, float, float]:
8585
"""as_tuple."""
8686
if self.coord_origin == CoordOrigin.TOPLEFT:
8787
return (self.l, self.t, self.r, self.b)
@@ -143,7 +143,7 @@ def intersection_area_with(self, other: "BoundingBox") -> float:
143143

144144
return width * height
145145

146-
def to_bottom_left_origin(self, page_height) -> "BoundingBox":
146+
def to_bottom_left_origin(self, page_height: float) -> "BoundingBox":
147147
"""to_bottom_left_origin.
148148
149149
:param page_height:
@@ -160,7 +160,7 @@ def to_bottom_left_origin(self, page_height) -> "BoundingBox":
160160
coord_origin=CoordOrigin.BOTTOMLEFT,
161161
)
162162

163-
def to_top_left_origin(self, page_height):
163+
def to_top_left_origin(self, page_height: float) -> "BoundingBox":
164164
"""to_top_left_origin.
165165
166166
:param page_height:

docling_core/types/doc/tokens.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
"""Tokens used in the docling document model."""
77

88
from enum import Enum
9-
from typing import Annotated, Tuple
10-
11-
from pydantic import Field
9+
from typing import Tuple
1210

1311

1412
class TableToken(Enum):
@@ -169,8 +167,7 @@ def get_location_token(val: float, rnorm: int = 100):
169167

170168
@staticmethod
171169
def get_location(
172-
# bbox: Tuple[float, float, float, float],
173-
bbox: Annotated[list[float], Field(min_length=4, max_length=4)],
170+
bbox: tuple[float, float, float, float],
174171
page_w: float,
175172
page_h: float,
176173
xsize: int = 100,

0 commit comments

Comments
 (0)