human
I am working on the file "OnroadLanesDetector.ipynb".
The first task is:
Result of getLaneLines transformed into lines

Then goes line grop detection, that accepts getLaneLines result as input parameter.
CoordinateSorter class does line groups detection and median line calculation for each found group. 
Influence it's input parameters on 'sort' function behavior could be described with help of Gherkin language:
CoordinateSorter(max_distance_delta, max_angle_delta, threshold)

 Scenario: 'max_distance_delta' and 'max_angle_delta' parameters allow to control line group detection
   Given: 5 lines have been given to sort
     And: it is possible to create a chain 'chain_1' of lines line1, line2, line3
   Where: distance between links is less (or equal) then (max_distance_delta, max_angle_delta)
     And: it is possible to create a chain 'chain_2' of lines line4, line5
   Where: distance between links is less (or equal) then (max_distance_delta, max_angle_delta)
     And: distance between chain_1 and chain_2 edges is more than (max_distance_delta, max_angle_delta)
    Then: chain_1 and chain_2 considered as two separate lines

 Scenario: 'threshold' parameter allows to filter out noise lines
   Given: threshold = 4, set of lines
    When: sorter found 3 groups of lines
     And: the first set of lines contains 10 lines, second - 5 lines
     But: the third set of lines contains 3 lines
    Then: the third considered as noise and will not be presented in sorting result

Resulting line is calculate as median of all lines in a group
Can you write Python code for it?

Write me a Python code to calculate as median of all lines in a group?
assistant
#Here is Python code to calculate as median of all lines in a group
.

class CoordinateSorter:

    def __init__(self, max_distance_delta, max_angle_delta, threshold):
        if max_angle_delta < 0:
            raise ValueError("[max_angle_delta] must be positive number")

        if max_angle_delta < 0:
            raise ValueError("[max_angle_delta] must be positive number")

        if threshold < 1 or type(threshold) != int:
            raise ValueError("[threshold] expected to be integer greater then or equal to 1")

        self._max_point_distance = (max_distance_delta, max_angle_delta)
        self._min_points_amount = threshold

    def _sortPointsByDistance(self, points_dict):
        set_list = list()

        for key, value in points_dict.items():
            indexes_set = set()
            set_list.append(indexes_set)
            indexes_set.add(key)

            for inner_key, inner_value in points_dict.items():
                point_distance = abs(np.subtract(value, inner_value))

                if point_distance[0] <= self._max_point_distance[0] \
                        and point_distance[1] <= self._max_point_distance[1]:
                    indexes_set.add(inner_key)

        return set_list

    def _splitOnGroups(self, set_list_source):

        sorted_source = list(set_list_source)
        sorted_source.sort(key=len, reverse=True)

        extremums = list()

        def find_extremums(ordered_list_of_set_items):
            if len(ordered_list_of_set_items) == 0:
                return

            first_extremum = ordered_list_of_set_items[0]
            items_for_further_sorting = list()

            for dot_set in ordered_list_of_set_items:
                if dot_set.issubset(first_extremum):
                    continue
                else:
                    if len(first_extremum.intersection(dot_set)):
                        first_extremum = first_extremum.union(dot_set)
                    else:
                        items_for_further_sorting.append(dot_set)

            extremums.append(first_extremum)
           ...