<commit_before>/**
 *
 */
package ca.eandb.jmist.framework.shader.pixel;

import ca.eandb.jmist.framework.PixelShader;
import ca.eandb.jmist.framework.color.Color;
import ca.eandb.jmist.math.Box2;

/**
 * A pixel shader decorator that averages the results of another
 * pixel shader.
 * @author <NAME>
 */
public final class AveragingPixelShader implements PixelShader {

	/**
	 * Initializes the inner pixel shader.
	 * @param numSamples The number of samples to average when shading
	 * 		a pixel.
	 * @param pixelShader The pixel shader average the results from.
	 */
	public AveragingPixelShader(int numSamples, PixelShader pixelShader) {
		if (numSamples <= 0) {
			throw new IllegalArgumentException("numSamples <= 0");
		}
		this.numSamples = numSamples;
		this.pixelShader = pixelShader;
	}

	/* (non-Javadoc)
	 * @see ca.eandb.jmist.framework.PixelShader#shadePixel(ca.eandb.jmist.math.Box2)
	 */
	public Color shadePixel(Box2 bounds) {
		Color pixel = null;

		for (int i = 0; i < this.numSamples; i++) {
			pixel = add(pixel, pixelShader.shadePixel(bounds));
		}

		return pixel.divide(numSamples);
	}

	/**
	 * Adds two <code>Color</code>s.
	 * @param a The first <code>Color</code> (may be null).
	 * @param b The second <code>Color</code>.
	 * @return The sum of the two <code>Color</code>s.
	 */
	public Color add(Color a, Color b) {
		return (a != null) ? a.plus(b) : b;
	}

	/**
	 * The number of samples to average from the decorated pixel
	 * shader.
	 */
	private final int numSamples;

	/** The pixel shader from which to average the results. */
	private final PixelShader pixelShader;

	/**
	 * Serialization version ID.
	 */
	private static final long serialVersionUID = -1978147732952459483L;

}<commit_msg>Removed redundant method AveragingPixelShader.add and replaced it's use with ColorUtil.add.<commit_after>/**
 *
 */
package ca.eandb.jmist.framework.shader.pixel;

import ca.eandb.jmist.framework.PixelShader;
import ca.eandb.jmist.framework.color.Color;
import ca.eandb.jmist.framework.color.ColorUtil;
import ca.eandb.jmist.math.Box2;

/**
 * A pixel shader decorator that averages the results of another
 * pixel shader.
 * @author <NAME>
 */
public final class AveragingPixelShader implements PixelShader {

	/**
	 * Initializes the inner pixel shader.
	 * @param numSamples The number of samples to average when shading
	 * 		a pixel.
	 * @param pixelShader The pixel shader average the results from.
	 */
	public AveragingPixelShader(int numSamples, PixelShader pixelShader) {
		if (numSamples <= 0) {
			throw new IllegalArgumentException("numSamples <= 0");
		}
		this.numSamples = numSamples;
		this.pixelShader = pixelShader;
	}

	/* (non-Javadoc)
	 * @see ca.eandb.jmist.framework.PixelShader#shadePixel(ca.eandb.jmist.math.Box2)
	 */
	public Color shadePixel(Box2 bounds) {
		Color pixel = null;

		for (int i = 0; i < this.numSamples; i++) {
			pixel = ColorUtil.add(pixel, pixelShader.shadePixel(bounds));
		}

		return pixel.divide(numSamples);
	}

	/**
	 * The number of samples to average from the decorated pixel
	 * shader.
	 */
	private final int numSamples;

	/** The pixel shader from which to average the results. */
	private final PixelShader pixelShader;

	/**
	 * Serialization version ID.
	 */
	private static final long serialVersionUID = -1978147732952459483L;

}
{'fraction_non_alphanumeric': 0.11438892233594221, 'fraction_numerical': 0.015051173991571343, 'mean_word_length': 3.7539341917024323, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, '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': '7660715', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1042, 'n_words': 305}