From 9ae8512a31d4557bbe85439bf15b96808ba421af Mon Sep 17 00:00:00 2001 From: Nikita Shevtsov <61932814+Travvy88@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:38:42 +0300 Subject: [PATCH] TLDR-473 add bbox class from dedoc (#15) Co-authored-by: Nikita Shevtsov --- CHANGELOG.md | 5 +++++ VERSION | 2 +- dedocutils/data_structures/bbox.py | 7 ++++--- dedocutils/data_structures/serializable.py | 16 ---------------- 4 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 dedocutils/data_structures/serializable.py diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0cd2c..c8fc1a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +v0.3.5 (2023-10-02) +------------------- +* Delete `Serializable` class +* Add `__hash__` method to `BBox` + v0.3.4 (2023-09-28) ------------------- * Add `Serializable` class diff --git a/VERSION b/VERSION index 448a0fa..09e9157 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.4 \ No newline at end of file +0.3.5 \ No newline at end of file diff --git a/dedocutils/data_structures/bbox.py b/dedocutils/data_structures/bbox.py index 310de53..78dcf8b 100644 --- a/dedocutils/data_structures/bbox.py +++ b/dedocutils/data_structures/bbox.py @@ -5,11 +5,9 @@ import numpy as np -from dedocutils.data_structures.serializable import Serializable - @dataclass -class BBox(Serializable): +class BBox: """ Bounding box around some page object, the coordinate system starts from top left corner. """ @@ -138,3 +136,6 @@ def to_relative_dict(self, page_width: int, page_height: int) -> dict: @staticmethod def from_dict(some_dict: Dict[str, int]) -> "BBox": return BBox(**some_dict) + + def __hash__(self) -> int: + return hash((self.x_top_left, self.y_top_left, self.width, self.height)) diff --git a/dedocutils/data_structures/serializable.py b/dedocutils/data_structures/serializable.py deleted file mode 100644 index 9de5d23..0000000 --- a/dedocutils/data_structures/serializable.py +++ /dev/null @@ -1,16 +0,0 @@ -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