Class RegressionTesting

java.lang.Object
ubic.gemma.core.util.RegressionTesting

public class RegressionTesting extends Object
Tools to help make regression testing easier — comparing matrices, arrays, and collections within a tolerance.

In-tree port of ubic.basecode.util.RegressionTesting (Renovations Phase 3 baseCode util batch 3). The cern.colt-heavy overloads (DoubleArrayList, DoubleMatrix1D, DoubleMatrix2D) and the file I/O helpers (readTestResult, writeTestResult, readTestResultFromFile) were dropped — none are called from Gemma. The remaining overloads kept here cover every Gemma call site: closeEnough(double[], double[], double), closeEnough(DoubleMatrix, DoubleMatrix, double), and containsSame(Collection, Collection). Other simple overloads (Object[], int[], double[] containsSame, sameArray) are retained because they're self-contained and trivial.

Author:
pavlidis
  • Method Details

    • closeEnough

      public static boolean closeEnough(double[] expected, double[] actual, double tolerance)
      Parameters:
      expected - expected values
      actual - actual values
      tolerance - permitted delta between the values
      Returns:
      true if all paired values agree within tolerance
    • closeEnough

      public static boolean closeEnough(DoubleMatrix<?,?> expected, DoubleMatrix<?,?> actual, double tolerance)
      Test whether two DoubleMatrixes are 'close enough' to call equal.
      Returns:
      true if all the values in both matrices are within 'tolerance' of each other.
    • closeEnough

      public static boolean closeEnough(Object[] a, Object[] b)
      Test whether two object arrays are the same (element-wise, ordered).
    • containsSame

      public static boolean containsSame(Collection<? extends Object> a, Collection<? extends Object> b)
      Test whether two collections contain the same items.
    • containsSame

      public static boolean containsSame(double[] a, double[] b)
      Test whether two double arrays contain the same items in any order (tolerance is ZERO).
    • containsSame

      public static boolean containsSame(Object[] a, Object[] b)
      Test whether two object arrays contain the same items in any order. The arrays are treated as Sets — repeats are not considered.
    • sameArray

      public static boolean sameArray(int[] a, int[] b)
      Test whether two int arrays contain the same items in the same order.