<commit_before>/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2014 - 2015 Board of Regents of the University of
 * Wisconsin-Madison, University of Konstanz and <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.
 * #L%
 */

package net.imagej.ops.geom;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;

import javax.imageio.ImageIO;

import net.imagej.ops.Ops;
import net.imagej.ops.features.AbstractFeatureTest;
import net.imglib2.RandomAccess;
import net.imglib2.RealPoint;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.roi.labeling.ImgLabeling;
import net.imglib2.roi.labeling.LabelRegion;
import net.imglib2.roi.labeling.LabelRegions;
import net.imglib2.roi.labeling.LabelingType;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.type.numeric.real.FloatType;

import org.junit.BeforeClass;
import org.junit.Test;

import ij.io.Opener;

/**
 * Tests for geom features
 * 
 * @author <NAME>, University of Konstanz
 * @author <NAME>, University of Konstanz
 */
public class GeomTest extends AbstractFeatureTest {

	private static LabelRegion<String> region2D;
	private static LabelRegion<String> region3D;
	private static Img<FloatType> img2d;

	@BeforeClass
	public static void setupBefore() throws MalformedURLException, IOException {
		img2d = getTestImage2D();
		region2D = createLabelRegion2D();
		region3D = createLabelRegion3D();
	}

	@Test
	public void createPolygon() {
		ops.geom().contour(region2D, true, true);
	}

	@Test
	public void testSize() {
		final double expected = expensiveTestsEnabled ? 355630.5 : 3460.5;
		assertEquals(Ops.Geometric.Size.NAME, expected, ops.geom().size(ops.geom().contour(
			region2D, true, true)).getRealDouble(), AbstractFeatureTest.BIG_DELTA);
	}

	@Test
	public void testBoundarySize2D() {
		final double expected = expensiveTestsEnabled ? 2658.990257670 : 262.977705423;
		assertEquals(Ops.Geometric.BoundarySize.NAME, expected, ops.geom().boundarysize(ops
			.geom().contour(region2D, true, true)).getRealDouble(),
			AbstractFeatureTest.BIG_DELTA);
	}

	@Test
	public void testCircularity() {
		final double expected = expensiveTestsEnabled ? 0.632083948 : 0.628797569;
		assertEquals(Ops.Geometric.Circularity.NAME, expected, ops.geom().circularity(ops
			.geom().contour(region2D, true, true)).getRealDouble(),
			AbstractFeatureTest.BIG_DELTA);<commit_msg>Override setup method in GeomTest<commit_after>/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2014 - 2015 Board of Regents of the University of
 * Wisconsin-Madison, University of Konstanz and <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.
 * #L%
 */

package net.imagej.ops.geom;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;

import javax.imageio.ImageIO;

import net.imagej.ops.Ops;
import net.imagej.ops.features.AbstractFeatureTest;
import net.imglib2.RandomAccess;
import net.imglib2.RealPoint;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.img.display.imagej.ImageJFunctions;
import net.imglib2.roi.labeling.ImgLabeling;
import net.imglib2.roi.labeling.LabelRegion;
import net.imglib2.roi.labeling.LabelRegions;
import net.imglib2.roi.labeling.LabelingType;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.type.numeric.real.FloatType;

import org.junit.BeforeClass;
import org.junit.Test;

import ij.io.Opener;

/**
 * Tests for geom features
 * 
 * @author <NAME>, University of Konstanz
 * @author <NAME>, University of Konstanz
 */
public class GeomTest extends AbstractFeatureTest {

	private static LabelRegion<String> region2D;
	private static LabelRegion<String> region3D;
	private static Img<FloatType> img2d;

	@BeforeClass
	public static void setupBefore() throws MalformedURLException, IOException {
		img2d = getTestImage2D();
		region2D = createLabelRegion2D();
		region3D = createLabelRegion3D();
	}
	
	@Override
	public void setup() {
		// no implementation is needed since the tests in this class will not use
		// the features provided in super#setup()
	}

	@Test
	public void createPolygon() {
		ops.geom().contour(region2D, true, true);
	}

	@Test
	public void testSize() {
		final double expected = expensiveTestsEnabled ? 355630.5 : 3460.5;
		assertEquals(Ops.Geometric.Size.NAME, expected, ops.geom().size(ops.geom().contour(
			region2D, true, true)).getRealDouble(), AbstractFeatureTest.BIG_DELTA);
	}

	@Test
	public void testBoundarySize2D() {
		final double expected = expensiveTestsEnabled ? 2658.990257670 : 262.977705423;
		assertEquals(Ops.Geometric.BoundarySize.NAME, expected, ops.geom().boundarysize(ops
			.geom().contour(region2D, true, true)).getRealDouble(),
			AbstractFeatureTest.BIG_DELTA);
	}

	@Test
	public void testCircularity() {
		final double expected = expensiveTestsEnabled ? 0.632083948 : 0.628797569;
		assertEquals(Ops.Geometric.Circularity.NAME, expected, ops.geom().circularity(ops
			.geom().contour(region2D, true, true)).getRealDouble(),
			AbstractFeatureTest.BIG_DELTA);
{'fraction_non_alphanumeric': 0.09080703505051765, 'fraction_numerical': 0.022951228639141823, 'mean_word_length': 4.878299120234604, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '4145572', 'n_tokens_mistral': 2622, 'n_tokens_neox': 2351, 'n_words': 757}