Skip to content

Commit

Permalink
[UPD] update typing_extension to typing
Browse files Browse the repository at this point in the history
  • Loading branch information
tushar1854 committed Jun 4, 2024
1 parent e5d971b commit 02a54aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions retailtree/logics/vp_tree.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import math
import statistics as stats
from typing_extensions import Callable
from typing import Callable

from retailtree.structs.annotation_struct import Annotation

Expand Down Expand Up @@ -60,7 +60,7 @@ def _is_leaf(self):

def get_all_in_range(self, query, max_distance):
# type: (tuple[float, float], float) -> list[tuple[float, Annotation]]
neighbors = list() # type: list[tuple[float, Annotation]]
neighbors = list() # type: list[tuple[float, Annotation]]
nodes_to_visit = [(self, 0)]

while len(nodes_to_visit) > 0:
Expand Down
7 changes: 4 additions & 3 deletions retailtree/retailtree.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import math
from random import sample
import numpy as np
from typing_extensions import Callable, Literal
from typing import Callable

from retailtree.structs.annotation_struct import Annotation
from retailtree.logics.vp_tree import VPTree
Expand Down Expand Up @@ -186,7 +186,7 @@ def neighbors(self, id, radius=1):
return result_lst

def TBLR(self, id, radius=1, overlap=0.5):
# type:(int, int, float) -> (dict[str, int | bool] | Literal['SKU is absent in annotation bucket'])
# type:(int, int, float) -> (dict[str, int | bool] | str)
"""
Computes top, bottom, left, and right connections for a given annotation within a specified radius.
Expand All @@ -198,8 +198,9 @@ def TBLR(self, id, radius=1, overlap=0.5):
- overlap (float, optional): The overlap percentage used to compute connections. Defaults to 0.5.
Returns:
- dict: A dictionary containing top, bottom, left, and right connections of the given annotation.
- dict OR str: A dictionary containing top, bottom, left, and right connections of the given annotation.
Each connection is represented by the ID of the connected annotation, or False if no connection exists.
If the SKU is not present in the bucket, a string with value 'SKU is absent in annotation bucket' is returned.
Examples:
Example usages of TBLR:
Expand Down
12 changes: 6 additions & 6 deletions retailtree/structs/annotation_struct.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from typing_extensions import Any
from typing import Any


class Annotation:
Expand All @@ -25,7 +25,7 @@ class Annotation:
"""

def __init__(self, id, x_min, y_min, x_max, y_max, label = None, metadata = None):
def __init__(self, id, x_min, y_min, x_max, y_max, label=None, metadata=None):
# type:(int, float, float, float, float, Any , dict[Any, Any]) -> None
self.__id = int(id)
self.__x_min = float(x_min)
Expand All @@ -41,10 +41,10 @@ def __init__(self, id, x_min, y_min, x_max, y_max, label = None, metadata = None
self.__width = None

# TODO Check compatibility for older versions of python
self.right = None # type: Annotation
self.left = None # type: Annotation
self.top = None # type: Annotation
self.bottom = None # type: Annotation
self.right = None # type: Annotation
self.left = None # type: Annotation
self.top = None # type: Annotation
self.bottom = None # type: Annotation

self.overlap_right = 0
self.overlap_top = 0
Expand Down

0 comments on commit 02a54aa

Please sign in to comment.