<commit_before>package org.openlca.app;

import org.eclipse.swt.graphics.RGB;

class ColorCalculator {

	private final RGB[] colors;
	private final int[] steps;

	public ColorCalculator(RGB[] colors, int[] steps) {
		if (steps.length != colors.length - 1)
			throw new IllegalArgumentException(
					"Must have exactly one more color than steps");
		int count = 0;
		for (int step : steps)
			count += step;
		if (count != 201)
			throw new IllegalArgumentException("Steps must sum up to 201");

		this.colors = colors;
		this.steps = steps;
	}

	public RGB getColor(int percentage) {
		int perc = percentage;
		if (perc < -100)
			perc = -100;
		if (perc > 100)
			perc = 100;
		int value = percentage + 100;
		int prev = 0;
		int index = 0;
		double steps = 0;
		for (int step : this.steps) {
			steps = step;
			if (value < step + prev) {
				break;
			} else {
				index++;
				prev += step;
			}
		}
		value = value - prev;

		RGB startColor = colors[index];
		RGB endColor = colors[index + 1];

		double diffRed = endColor.red - startColor.red;
		double diffGreen = endColor.green - startColor.green;
		double diffBlue = endColor.blue - startColor.blue;
		double step = value % steps;
		step /= steps;

		int red = (int) (startColor.red + step * diffRed);
		int green = (int) (startColor.green + step * diffGreen);
		int blue = (int) (startColor.blue + step * diffBlue);

		return new RGB(red, green, blue);
	}

}
<commit_msg>do not throw exceptions when contribution is < -100 or greater > 100<commit_after>package org.openlca.app;

import org.eclipse.swt.graphics.RGB;

class ColorCalculator {

	private final RGB[] colors;
	private final int[] steps;

	public ColorCalculator(RGB[] colors, int[] steps) {
		if (steps.length != colors.length - 1)
			throw new IllegalArgumentException(
					"Must have exactly one more color than steps");
		int count = 0;
		for (int step : steps)
			count += step;
		if (count != 201)
			throw new IllegalArgumentException("Steps must sum up to 201");

		this.colors = colors;
		this.steps = steps;
	}

	public RGB getColor(int percentage) {
		int perc = percentage;
		if (perc < -100)
			perc = -100;
		if (perc > 100)
			perc = 100;
		int value = perc + 100;
		int prev = 0;
		int index = 0;
		double steps = 0;
		for (int step : this.steps) {
			steps = step;
			if (value < step + prev) {
				break;
			} else {
				index++;
				prev += step;
			}
		}
		value = value - prev;

		RGB startColor = colors[index];
		RGB endColor = colors[index + 1];

		double diffRed = endColor.red - startColor.red;
		double diffGreen = endColor.green - startColor.green;
		double diffBlue = endColor.blue - startColor.blue;
		double step = value % steps;
		step /= steps;

		int red = (int) (startColor.red + step * diffRed);
		int green = (int) (startColor.green + step * diffGreen);
		int blue = (int) (startColor.blue + step * diffBlue);

		return new RGB(red, green, blue);
	}

}

{'fraction_non_alphanumeric': 0.12324064538276691, 'fraction_numerical': 0.02059732234809475, 'mean_word_length': 3.0248618784530388, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3864354', 'n_tokens_mistral': 1160, 'n_tokens_neox': 959, 'n_words': 318}