# usr bin env python coding utf-8 10 20 30 50 70 значения доступное врем

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85``` ```#!/usr/bin/env python # coding: utf-8 a = [10, 20, 30, 50, 70] # значения b = [1, 2, 3, 4, 5] # доступное время сняти замеров def frange(start, stop, step): r = start while r < stop: yield r r += step assert tuple(frange(1.0, 5.0, 1.0)) == (1.0, 2.0, 3.0, 4.0) def pairwise(iterable): """ # # current = (0, b[0]) # # for x in b[1:]: # current = (current[1], x) # print(current) # """ iterable = iter(iterable) current = next(iterable) for x in iterable: yield (current, x) current = x assert tuple(pairwise(iter(range(3)))) == ((0, 1), (1, 2)) a = [10, 20, 30, 50, 70] # значения b = [1, 2, 3, 4, 5] # доступное время сняти замеров def in_range(a, range): return range[0] < a < range[1] assert in_range(5, [1, 9]) def gen_timers(from_, to, number_of_tics=10): # print(to) # print(from_) step = (to - from_) / number_of_tics return frange(from_, to, step) assert len((tuple(gen_timers(1, 10, number_of_tics=10)))) == 10 assert len(tuple(gen_timers(b[0], b[-1], number_of_tics=10))) == 10 assert len(tuple(gen_timers(b[0], b[-1], number_of_tics=15))) == 15 + 1 def pl(a): print(len(tuple(a))) def pt(a): print(tuple(a)) a = [10, 20, 30, 50, 70] # значения b = [1, 2, 3, 4, 5] # доступное время сняти замеров def magic_function(time, data): times = gen_timers(time[0], time[-1]) data = zip(pairwise(data), pairwise(time)) (start_data, end_data), (start_time, end_time) = next(data) for time in times: if start_time <= time < end_time: delta = (end_data - start_data) / \ (end_time - start_time) # в секунду? yield start_data + delta * (time - start_time) else: (start_data, end_data), (start_time, end_time) = next(data) yield start_data + delta * (time - start_time) p = tuple(magic_function(b, a)) import ipdb; ipdb.set_trace() ```