def __init__(self, population): """ :type population: Dict[T, double] """ data = list( map(lambda value: (value, float(population[value])), population.keys())) self._range_map = RangeMap(data)
def test(test_case): rm = RangeMap(DATA[test_case]) print('Testing query...') for (point, expect) in QUERIES[test_case]: assert expect == rm.get(point) print('Testing updates...') for (value, interval, point, expect) in UPDATES[test_case]: rm.update(value, interval) assert expect == rm.get(point) print('Test case %d passes!' % (test_case + 1))