def make_threshold_gradient(self, py3, thresholds, size=<NUM_LIT:100>):
thresholds = sorted(thresholds)<EOL>key = "<STR_LIT>".format(thresholds, size)<EOL>try:<EOL><INDENT>return self._gradients_cache[key]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>minimum = min(thresholds)[<NUM_LIT:0>]<EOL>maximum = max(thresholds)[<NUM_LIT:0>]<EOL>if maximum - minimum > size:<EOL><INDENT>steps_size = size / (maximum - minimum)<EOL><DEDENT>else:<EOL><INDENT>steps_size = <NUM_LIT:1><EOL><DEDENT>colors = []<EOL>for index in range(len(thresholds) - <NUM_LIT:1>):<EOL><INDENT>color_list = [thresholds[index][<NUM_LIT:1>], thresholds[index + <NUM_LIT:1>][<NUM_LIT:1>]]<EOL>num_colors = int(<EOL>(thresholds[index + <NUM_LIT:1>][<NUM_LIT:0>] - thresholds[index][<NUM_LIT:0>]) * steps_size<EOL>)<EOL>colors.extend(self.generate_gradient(color_list, num_colors))<EOL><DEDENT>self._gradients_cache[key] = colors<EOL>return colors<EOL>
Given a thresholds list, creates a gradient list that covers the range
of the thresholds.
The number of colors in the gradient is limited by size.
Because of how the range is split the exact number of colors in the
gradient cannot be guaranteed.