Skip to content

Commit

Permalink
TLDR-473 make BBox class Serializable (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Nikita Shevtsov <[email protected]>
  • Loading branch information
Travvy88 and Nikita Shevtsov authored Sep 29, 2023
1 parent a71b68b commit 38733a9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

v0.3.4 (2023-09-28)
-------------------
* Add `Serializable` class
* Make `BBox` child class of `Serializable`

v0.3.3 (2023-09-28)
-------------------
* Update `BBox` class
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.3
0.3.4
4 changes: 3 additions & 1 deletion dedocutils/data_structures/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

import numpy as np

from dedocutils.data_structures.serializable import Serializable


@dataclass
class BBox:
class BBox(Serializable):
"""
Bounding box around some page object, the coordinate system starts from top left corner.
"""
Expand Down
16 changes: 16 additions & 0 deletions dedocutils/data_structures/serializable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from abc import ABC, abstractmethod


class Serializable(ABC):
"""
Base class for the serializable objects which we need convert to dict.
"""
@abstractmethod
def to_dict(self) -> dict:
"""
Convert class data into dictionary representation.
Dictionary key should be string and dictionary value should be json serializable.
:return: dict with all class data.
"""
pass

0 comments on commit 38733a9

Please sign in to comment.