def testSkipRatioBad(): """This is a really confusing one. For the program to return the expected answer below, I would have to break most of the other tests in this file! Since they depend on it not slurping up extra frames. Very hard to explain. Argh.""" raise SkipTest() res = convert_integers_by_iterator_ratio(0.5, multirange('0-0,2-2')) assert_equal(list(res), [(0,0), (2,1)])
def parse_range(range_str): """Parses a range like 234-789 into a tuple (234, 789) """ parts = range_str.split('-') if len(parts) != 2: parser.error("Ranges can only have two parts: start-end") return tuple(float(s) for s in parts) if __name__ == '__main__': (opts, args) = parser.parse_args() if opts.in_bounds and opts.in_times: parser.error("Options --take and --take-times are mutually exclusive") elif opts.in_bounds: frames = multirange(opts.in_bounds) elif opts.in_times: parse = lambda x: time_to_frame(float(x)) frames = multirange(opts.in_times, parser=parse) else: frames = None # set the first frame of output if opts.keep_numbers: out_offset = frames[0] else: out_offset = 0 if len(args) < 2: parser.error("Input file and Output file format are required")
def parse_range(range_str): """Parses a range like 234-789 into a tuple (234, 789) """ parts = range_str.split('-') if len(parts) != 2: parser.error("Ranges can only have two parts: start-end") return tuple(float(s) for s in parts) if __name__ == '__main__': (opts, args) = parser.parse_args() if opts.in_bounds and opts.in_times: parser.error("Options --take and --take-times are mutually exclusive") elif opts.in_bounds: frames = multirange(opts.in_bounds) elif opts.in_times: parse = lambda x: time_to_frame(float(x)) frames = multirange(opts.in_times, parser=parse) else: frames = None # set the first frame of output if opts.keep_numbers: out_offset = frames[0] else: out_offset = 0 if len(args) < 2: parser.error("Input file and Output file format are required")
def testSkipRatioOffset(): res = convert_integers_by_iterator_ratio(0.5, multirange('0-1,5-6'), dest_offset=5) assert_equal(list(res), [(1,5), (5,7)])
def testSkipRatio(): res = convert_integers_by_iterator_ratio(0.5, multirange('0-1,5-6')) assert_equal(list(res), [(1,0), (5,2)])
def testSkip(): res = convert_integers_by_iterator_ratio(1, multirange('0-1,5-6')) assert_equal(list(res), [(0,0), (1,1), (5,5), (6,6)])