def get(self, request, data): bounds = data > maybe | X.get('in_polygon') return ((data or {}) > as_kwargs(get_car_position_data) | where(X['car'] | self.filter) | group_by(X['location'] | (grouping_precision, X, bounds)) | X.iteritems() | foreach({ 'location': X[1][0]['location'], 'cars': X[1] | foreach(X['car']) | self.get_car_data, }) | tuple)
unit_id = unit_id or randint(1, 1000) length = length or randint(100, 1000) x_range = 0.004 y_range = 0.004 dx = random() * x_range * 2 - x_range dy = random() * y_range * 2 - y_range dx_range = 0.004 dy_range = 0.004 for index in xrange(length): yield dict( { 'location': point, 'unit_id': unit_id, 'timestamp': timestamp, }, **get_extra_data(point, index)) point = point[0] + dx, point[1] + dy if not within(bounds, point): point = random_move((point[0] - dx, point[1] - dy), bounds=bounds) dx = random() * x_range * 2 - x_range dy = random() * y_range * 2 - y_range dx += random() * dx_range * 2 - dx_range dy += random() * dy_range * 2 - dy_range d = time_step_variation_seconds timestamp += (time_step + timedelta(seconds=randint(-d, d))) create_and_store_dummy_route = pipe | generate | foreach_do(as_kwargs(store))
def test_as_kwargs(self): d = {'foo': 4, 'bar': 2} assert as_kwargs(lambda **kw: kw)(d) == d
timestamp = start_time or datetime.now() unit_id = unit_id or randint(1, 1000) length = length or randint(100, 1000) x_range = 0.004 y_range = 0.004 dx = random() * x_range * 2 - x_range dy = random() * y_range * 2 - y_range dx_range = 0.004 dy_range = 0.004 for index in xrange(length): yield dict({ 'location': point, 'unit_id': unit_id, 'timestamp': timestamp, }, **get_extra_data(point, index)) point = point[0] + dx, point[1] + dy if not within(bounds, point): point = random_move((point[0] - dx, point[1] - dy), bounds=bounds) dx = random() * x_range * 2 - x_range dy = random() * y_range * 2 - y_range dx += random() * dx_range * 2 - dx_range dy += random() * dy_range * 2 - dy_range d = time_step_variation_seconds timestamp += (time_step + timedelta(seconds=randint(-d, d))) create_and_store_dummy_route = pipe | generate | foreach_do(as_kwargs(store))