def best_units(self, sequence):
<EOL>ts_range = self.value(max(sequence)) - self.value(min(sequence))<EOL>package = self.determine_package(sequence[<NUM_LIT:0>])<EOL>if package == '<STR_LIT>':<EOL><INDENT>cuts = [<EOL>(<NUM_LIT>, '<STR_LIT>'),<EOL>(<NUM_LIT>, '<STR_LIT>'),<EOL>(<NUM_LIT>, '<STR_LIT:s>'),<EOL>(<NUM_LIT:9>, '<STR_LIT:m>'),<EOL>(<NUM_LIT:6>, '<STR_LIT:h>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:d>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:w>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:M>'),<EOL>(<NUM_LIT:3>, '<STR_LIT:y>')]<EOL>denomination = NANOSECONDS<EOL>base_units = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>cuts = [<EOL>(<NUM_LIT>, '<STR_LIT:s>'),<EOL>(<NUM_LIT:9>, '<STR_LIT:m>'),<EOL>(<NUM_LIT:6>, '<STR_LIT:h>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:d>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:w>'),<EOL>(<NUM_LIT:4>, '<STR_LIT:M>'),<EOL>(<NUM_LIT:3>, '<STR_LIT:y>')]<EOL>denomination = SECONDS<EOL>base_units = '<STR_LIT>'<EOL><DEDENT>for size, units in reversed(cuts):<EOL><INDENT>if ts_range >= size*denomination[units]:<EOL><INDENT>return units<EOL><DEDENT><DEDENT>return base_units<EOL>
Determine good units for representing a sequence of timedeltas