<commit_before>/*
 * Zorbage: an algebraic data hierarchy for use in numeric processing.
 *
 * Copyright (C) 2016-2019 <NAME>
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package nom.bdezonia.zorbage.algorithm;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import nom.bdezonia.zorbage.algebras.G;
import nom.bdezonia.zorbage.type.data.float64.real.Float64Member;
import nom.bdezonia.zorbage.type.data.int4.SignedInt4Member;
import nom.bdezonia.zorbage.type.data.int4.UnsignedInt4Member;

/**
 * 
 * @author <NAME>
 *
 */
public class TestNumberWithin {

	@Test
	public void signedInteger() {

		SignedInt4Member elemA = G.INT4.construct();
		SignedInt4Member elemB = G.INT4.construct();
		SignedInt4Member elemTol = G.INT4.construct();
		for (int a = -8; a < 8; a++) {
			elemA.setV(a);
			for (int b = -8; b < 8; b++) {
				elemB.setV(b);
				for (int tol = 0; tol < 8; tol++) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.INT4, elemA, elemB, elemTol);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void unsignedInteger() {

		UnsignedInt4Member elemA = G.UINT4.construct();
		UnsignedInt4Member elemB = G.UINT4.construct();
		UnsignedInt4Member elemTol = G.UINT4.construct();
		for (int a = 0; a < 16; a++) {
			elemA.setV(a);
			for (int b = 0; b < 16; b++) {
				elemB.setV(b);
				for (int tol = 0; tol < 16; tol++) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.UINT4, elemA, elemB, elemTol);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void signedFloat() {

		Float64Member elemA = G.DBL.construct();
		Float64Member elemB = G.DBL.construct();
		Float64Member elemTol = G.DBL.construct();
		for (double a = -8; a < 8; a += 0.25) {
			elemA.setV(a);
			for (double b = -8; b < 8; b += 0.25) {
				elemB.setV(b);
				for (double tol = 0; tol < 8; tol += 0.25) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.DBL, elemA, elemB, elemTol);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void unsignedFloat() {

		Float64Member elemA = G.DBL.construct();
		Float64Member elemB = G.DBL.construct();
		Float64Member elemTol = G.DBL.construct();
		for (double a = 0; a < 16; a += 0.25) {
			elemA.setV(a);
			for (double b = 0; b < 16; b += 0.25) {
				elemB.setV(b);
				for (double tol = 0; tol < 16; tol += 0.25) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.DBL, elemA, elemB, elemTol);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}
}<commit_msg>Fix TestNumberWithin to adopt the new param passing conventions<commit_after>/*
 * Zorbage: an algebraic data hierarchy for use in numeric processing.
 *
 * Copyright (C) 2016-2019 <NAME>
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package nom.bdezonia.zorbage.algorithm;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import nom.bdezonia.zorbage.algebras.G;
import nom.bdezonia.zorbage.type.data.float64.real.Float64Member;
import nom.bdezonia.zorbage.type.data.int4.SignedInt4Member;
import nom.bdezonia.zorbage.type.data.int4.UnsignedInt4Member;

/**
 * 
 * @author <NAME>
 *
 */
public class TestNumberWithin {

	@Test
	public void signedInteger() {

		SignedInt4Member elemA = G.INT4.construct();
		SignedInt4Member elemB = G.INT4.construct();
		SignedInt4Member elemTol = G.INT4.construct();
		for (int a = -8; a < 8; a++) {
			elemA.setV(a);
			for (int b = -8; b < 8; b++) {
				elemB.setV(b);
				for (int tol = 0; tol < 8; tol++) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.INT4, elemTol, elemA, elemB);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void unsignedInteger() {

		UnsignedInt4Member elemA = G.UINT4.construct();
		UnsignedInt4Member elemB = G.UINT4.construct();
		UnsignedInt4Member elemTol = G.UINT4.construct();
		for (int a = 0; a < 16; a++) {
			elemA.setV(a);
			for (int b = 0; b < 16; b++) {
				elemB.setV(b);
				for (int tol = 0; tol < 16; tol++) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.UINT4, elemTol, elemA, elemB);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void signedFloat() {

		Float64Member elemA = G.DBL.construct();
		Float64Member elemB = G.DBL.construct();
		Float64Member elemTol = G.DBL.construct();
		for (double a = -8; a < 8; a += 0.25) {
			elemA.setV(a);
			for (double b = -8; b < 8; b += 0.25) {
				elemB.setV(b);
				for (double tol = 0; tol < 8; tol += 0.25) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.DBL, elemTol, elemA, elemB);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}

	@Test
	public void unsignedFloat() {

		Float64Member elemA = G.DBL.construct();
		Float64Member elemB = G.DBL.construct();
		Float64Member elemTol = G.DBL.construct();
		for (double a = 0; a < 16; a += 0.25) {
			elemA.setV(a);
			for (double b = 0; b < 16; b += 0.25) {
				elemB.setV(b);
				for (double tol = 0; tol < 16; tol += 0.25) {
					elemTol.setV(tol);
					boolean algo = NumberWithin.compute(G.DBL, elemTol, elemA, elemB);
					boolean test = Math.abs(a-b) <= tol;
					assertEquals(test, algo);
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.12023092369477911, 'fraction_numerical': 0.023092369477911646, 'mean_word_length': 3.3333333333333335, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 7, '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': '6816486', 'n_tokens_mistral': 3205, 'n_tokens_neox': 2661, 'n_words': 852}