Skip to content

Commit

Permalink
refactor: removed in_region_i
Browse files Browse the repository at this point in the history
  • Loading branch information
eladyaniv01 committed Aug 27, 2020
1 parent 54ce9c1 commit f8c7103
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions MapAnalyzer/MapData.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def closest_towards_point(
>>> enemy_army_position = Point2((50,50)) # random point for this example
>>> my_base_location = self.bot.townhalls[0]
>>> my_region = self.where(my_base_location)
>>> my_region = self.where_all(my_base_location)[0]
>>> corners = my_region.corner_points
>>> best_siege_spot = self.closest_towards_point(points=corners, target=enemy_army_position)
(57,120)
Expand Down Expand Up @@ -549,32 +549,7 @@ def in_region_p(self, point: Union[Point2, tuple]) -> Optional[Region]:
if isinstance(point, tuple):
point = int(point[0]), int(point[1])
for region in self.regions.values():
if region.inside_p(point):
return region

@lru_cache(100)
def in_region_i(
self, point: Union[Point2, tuple]
) -> Optional[Region]: # pragma: no cover
"""
:rtype: Optional[:class:`.Region`]
Will query a if a point is in, and in which Region using Indices <slower>
Tip:
:meth:`.in_region_p` performs better, and should be used.
time benchmark 18.6 µs ± 197 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
"""
if isinstance(point, Point2):
point = point.rounded
if isinstance(point, tuple):
point = int(point[0]), int(point[1])
for region in self.regions.values():
if region.inside_i(point):
if region.is_inside_point(point):
return region

""" longest map compile is 1.9 s """
Expand Down

0 comments on commit f8c7103

Please sign in to comment.