Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3187,8 +3187,8 @@ def from_dict(cls, data):
kind=data.get("kind", None),
row_index=data.get("row_index", None),
column_index=data.get("column_index", None),
row_span=data.get("row_span", None),
column_span=data.get("column_span", None),
row_span=data.get("row_span", 1),
column_span=data.get("column_span", 1),
content=data.get("content", None),
bounding_regions=[BoundingRegion.from_dict(v) for v in data.get("bounding_regions")] # type: ignore
if len(data.get("bounding_regions", [])) > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,58 @@ def test_document_table_cell_to_dict(self):

assert d == final

def test_document_table_cell_to_dict_use_defaults(self):
# NOTE: column_span and row_span are not included on purpose to test that the proper defaults are set.
model = _models.DocumentTableCell(
kind="content",
row_index=2,
column_index=3,
content="cell content",
bounding_regions=[
_models.BoundingRegion(
bounding_box=[_models.Point(1, 2), _models.Point(3, 4)],
page_number=1,
),
],
spans=[
_models.DocumentSpan(
offset=5,
length=2,
),
],
)

d = model.to_dict()

final = {
"kind": "content",
"row_index": 2,
"column_index": 3,
"row_span": 1,
"column_span": 1,
"content": "cell content",
"bounding_regions": [
{
"page_number": 1,
"bounding_box": [
{"x": 1, "y": 2},
{
"x": 3,
"y": 4,
},
],
},
],
"spans": [
{
"offset": 5,
"length": 2,
},
],
}

assert d == final

def test_model_operation_info_to_dict(self):
model = _models.ModelOperationInfo(
operation_id="id123",
Expand Down