本文整理汇总了Python中location.Location.partition_around_median方法的典型用法代码示例。如果您正苦于以下问题:Python Location.partition_around_median方法的具体用法?Python Location.partition_around_median怎么用?Python Location.partition_around_median使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类location.Location
的用法示例。
在下文中一共展示了Location.partition_around_median方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from location import Location [as 别名]
# 或者: from location.Location import partition_around_median [as 别名]
def __init__(self, locations, xy=None, randomize=True):
self.size = len(locations)
if xy is not None:
self.xy = xy
else:
self.xy = True
start = 0
end = self.size - 1
if self.size % 2 == 0:
median = self.size / 2 - 1
else:
median = self.size / 2
if start < end:
self.loc = Location.partition_around_median(locations, self.xy, randomize)
if start < median:
self.left = TwoDTree(locations[:median], not self.xy, randomize)
else:
self.left = None
if median < end:
self.right = TwoDTree(locations[median + 1:], not self.xy, randomize)
else:
self.right = None
elif start == end:
self.loc = locations[start]
self.left = self.right = None
else:
self.loc = self.left = self.right = None