<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.onthefly;

import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;

import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtNewMethod;
import net.imagej.ops.Contingent;
import net.imagej.ops.Op;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.basictypeaccess.array.ArrayDataAccess;
import net.imglib2.img.planar.PlanarImg;
import net.imglib2.type.numeric.RealType;

import org.scijava.ItemIO;
import org.scijava.Priority;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

/**
 * A class generator for specialized {@link Op}s.
 * <p>
 * This class uses <a href="http://www.javassist.org/">Javassist</a> to generate
 * optimized versions of arithmetic operations on-the-fly. To this end, the
 * {@link #conforms()} method has to match the parameters carefully, to ensure
 * that the {@link #run()} method will not have problems processing those
 * parameters.
 * </p>
 * <p>
 * When {@link #run()} is called, it first determines the exact data types of
 * its parameters -- verifying again that the op works for them -- and then
 * generates a new class, based on the exact parameter types, which it loads
 * into a new class loader -- to avoid polluting the current class loader -- and
 * executes it. To avoid unnecessary work, the generated classes are cached.
 * </p>
 * 
 * @author <NAME>
 */
public abstract class ArithmeticOp implements Op, Contingent {

	/** The 'add' op */
	@Plugin(type = Op.class, name = "add", priority = Priority.HIGH_PRIORITY)
	public static class AddOp extends ArithmeticOp {

		@Override
		public void run() {
			run("add", "+");
		}
	}

	/** The 'subtract' op */
	@Plugin(type = Op.class, name = "subtract", priority = Priority.HIGH_PRIORITY)
	public static class SubtractOp extends ArithmeticOp {

		@Override
		public void run() {
			run("subtract", "-");
		}
	}

	/** The 'multiply' op */
	@Plugin(type = Op.class, name = "multiply", priority = Priority.HIGH_PRIORITY)
	public static class MultiplyOp extends ArithmeticOp {

		@Override
		public void run() {
			run("multiply", "*");
		}
	}

	/** The 'divide' op */
	@Plugin(type = Op.class, name = "divide", priority = Priority.HIGH_PRIORITY)
	public static class DivideOp extends ArithmeticOp {
<commit_msg>ArithmeticOp: implement the proper op interfaces<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.onthefly;

import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;

import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtNewMethod;
import net.imagej.ops.Contingent;
import net.imagej.ops.Op;
import net.imagej.ops.Ops;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.basictypeaccess.array.ArrayDataAccess;
import net.imglib2.img.planar.PlanarImg;
import net.imglib2.type.numeric.RealType;

import org.scijava.ItemIO;
import org.scijava.Priority;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;

/**
 * A class generator for specialized {@link Op}s.
 * <p>
 * This class uses <a href="http://www.javassist.org/">Javassist</a> to generate
 * optimized versions of arithmetic operations on-the-fly. To this end, the
 * {@link #conforms()} method has to match the parameters carefully, to ensure
 * that the {@link #run()} method will not have problems processing those
 * parameters.
 * </p>
 * <p>
 * When {@link #run()} is called, it first determines the exact data types of
 * its parameters -- verifying again that the op works for them -- and then
 * generates a new class, based on the exact parameter types, which it loads
 * into a new class loader -- to avoid polluting the current class loader -- and
 * executes it. To avoid unnecessary work, the generated classes are cached.
 * </p>
 * 
 * @author <NAME>
 */
public abstract class ArithmeticOp implements Op, Contingent {

	/** The 'add' op */
	@Plugin(type = Op.class, name = "add", priority = Priority.HIGH_PRIORITY)
	public static class AddOp extends ArithmeticOp implements Ops.Add {

		@Override
		public void run() {
			run("add", "+");
		}
	}

	/** The 'subtract' op */
	@Plugin(type = Op.class, name = "subtract", priority = Priority.HIGH_PRIORITY)
	public static class SubtractOp extends ArithmeticOp implements Ops.Subtract {

		@Override
		public void run() {
			run("subtract", "-");
		}
	}

	/** The 'multiply' op */
	@Plugin(type = Op.class, name = "multiply", priority = Priority.HIGH_PRIORITY)
	public static class MultiplyOp extends ArithmeticOp implements Ops.Multiply {

		@Override
		public void run() {
			run("multiply", "*");
		}
	}

	/** The 'divide' op */
	@Plugin(type = Op.class, name = "divide", priority = Priority.HIGH_PRIORITY)
	public static class DivideOp extends ArithmeticOp implements Ops.Divide {

{'fraction_non_alphanumeric': 0.09511311086114235, 'fraction_numerical': 0.0037495313085864268, 'mean_word_length': 4.192731992212849, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '412931', 'n_tokens_mistral': 2470, 'n_tokens_neox': 2254, 'n_words': 915}