org.testng.internal.junit.ArrayAsserts Java Examples
The following examples show how to use
org.testng.internal.junit.ArrayAsserts.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SvnServerParserTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
@Test public void testMessageParse2() throws IOException { try (InputStream stream = new ByteArrayInputStream("( 2 ( edit-pipeline svndiff1 absent-entries depth mergeinfo log-revprops ) 15:svn://localhost ) test ".getBytes(StandardCharsets.UTF_8))) { final SvnServerParser parser = new SvnServerParser(stream); ClientInfo req = MessageParser.parse(ClientInfo.class, parser); Assert.assertEquals(req.getProtocolVersion(), 2); Assert.assertEquals(req.getUrl().toString(), "svn://localhost"); Assert.assertEquals(req.getRaClient(), ""); ArrayAsserts.assertArrayEquals(new String[]{ "edit-pipeline", "svndiff1", "absent-entries", "depth", "mergeinfo", "log-revprops" }, req.getCapabilities()); Assert.assertEquals(parser.readText(), "test"); } }
Example #2
Source File: SvnServerParserTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
@Test public void testMessageParse() throws IOException { try (InputStream stream = new ByteArrayInputStream("( 2 ( edit-pipeline svndiff1 absent-entries depth mergeinfo log-revprops ) 15:svn://localhost 31:SVN/1.8.8 (x86_64-pc-linux-gnu) ( ) ) test ".getBytes(StandardCharsets.UTF_8))) { final SvnServerParser parser = new SvnServerParser(stream); ClientInfo req = MessageParser.parse(ClientInfo.class, parser); Assert.assertEquals(req.getProtocolVersion(), 2); Assert.assertEquals(req.getUrl().toString(), "svn://localhost"); Assert.assertEquals(req.getRaClient(), "SVN/1.8.8 (x86_64-pc-linux-gnu)"); ArrayAsserts.assertArrayEquals(new String[]{ "edit-pipeline", "svndiff1", "absent-entries", "depth", "mergeinfo", "log-revprops" }, req.getCapabilities()); Assert.assertEquals(parser.readText(), "test"); } }
Example #3
Source File: AFCalculationResultUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test(dataProvider = "AFCalculationResults") private void test(final int[] mleCounts, final List<Allele> alleles, final double probabilityOfNoVariant, final double[] probabilityOfNoVariantByAllele) { final Map<Allele, Double> log10pRefByAllele = new HashMap<>(); for (int n = 1; n < alleles.size(); n++) { log10pRefByAllele.put(alleles.get(n), Math.log10(probabilityOfNoVariantByAllele[n-1])); } final AFCalculationResult result = new AFCalculationResult(mleCounts, alleles, Math.log10(probabilityOfNoVariant), log10pRefByAllele); ArrayAsserts.assertArrayEquals(result.getAlleleCountsOfMLE(), mleCounts); Assert.assertEquals(result.getAllelesUsedInGenotyping(), alleles); for (int n = 1; n < alleles.size(); n++) { Assert.assertEquals(result.getAlleleCountAtMLE(alleles.get(n)), mleCounts[n-1]); } Assert.assertEquals(result.log10ProbVariantPresent(), Math.log10(1 - probabilityOfNoVariant), 1.0e-10); }
Example #4
Source File: TargetCoverageSexGenotypeCalculatorUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Note: this test relies on the content of the test resource files */ @Test public void testGenotyperInitialization() { final Set<String> ploidyTags = genotyper.getSexGenotypeIdentifiers(); final int[] autosomalTargetPloidies = genotyper.getAutosomalTargetGermlinePloidies(); final Map<String, int[]> allosomalTargetPloidies = genotyper.getAllosomalTargetGermlinePloidiesMap(); /* assert all ploidy tags are present */ Assert.assertTrue(ploidyTags.equals(Arrays.stream(GENOTYPES).collect(Collectors.toSet()))); /* assert ploidy on autosomal targets */ ArrayAsserts.assertArrayEquals( IntStream.range(0, autosomalTargetPloidies.length).map(i -> AUTOSOME_PLOIDY).toArray(), autosomalTargetPloidies); /* assert ploidy on allosomal targets */ int[] expected; final List<Target> allosomalTargetList = genotyper.getAllosomalTargetList(); expected = allosomalTargetList.stream().mapToInt(t -> t.getContig().equals("X") ? SEX_XX_PLOIDY_ON_X : SEX_XX_PLOIDY_ON_Y).toArray(); ArrayAsserts.assertArrayEquals(expected, allosomalTargetPloidies.get("SEX_XX")); expected = allosomalTargetList.stream().mapToInt(t -> t.getContig().equals("X") ? SEX_XY_PLOIDY_ON_X : SEX_XY_PLOIDY_ON_Y).toArray(); ArrayAsserts.assertArrayEquals(expected, allosomalTargetPloidies.get("SEX_XY")); }
Example #5
Source File: GATKProtectedMathUtilsTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testNearestNeighborUniform1DInterpolate() { ArrayAsserts.assertArrayEquals(new double[]{0.0, 1.0, 2.0}, GATKProtectedMathUtils.nearestNeighborUniform1DInterpolate(new double[]{0.0, 1.0, 2.0}, 3), 1e-6); ArrayAsserts.assertArrayEquals(new double[]{0.0, 1.0, 1.0, 2.0}, GATKProtectedMathUtils.nearestNeighborUniform1DInterpolate(new double[]{0.0, 1.0, 2.0}, 4), 1e-6); ArrayAsserts.assertArrayEquals(new double[]{0.0, 0.0, 1.0, 1.0, 2.0, 2.0}, GATKProtectedMathUtils.nearestNeighborUniform1DInterpolate(new double[]{0.0, 1.0, 2.0}, 6), 1e-6); }
Example #6
Source File: SvnServerParserTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Test public void test2dString() throws IOException { try (InputStream stream = new ByteArrayInputStream("( ( 1:a ) ( 1:b ) )".getBytes(StandardCharsets.UTF_8))) { final SvnServerParser parser = new SvnServerParser(stream); final String[][] actual = MessageParser.parse(String[][].class, parser); ArrayAsserts.assertArrayEquals(new String[][]{ new String[]{"a"}, new String[]{"b"}, }, actual); } }
Example #7
Source File: ArtifactPriorUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test(dataProvider = "dataForGet") public void testGet(final double[] pi, final double[] expectedRevCompPi) { final double epsilon = 1e-6; final String context = "ATG"; final String revComp = "CAT"; final ArtifactPriorCollection priors = new ArtifactPriorCollection("sample"); priors.set(new ArtifactPrior(context, pi, 100, 10)); Optional<ArtifactPrior> priorRevComp = priors.get(revComp); ArrayAsserts.assertArrayEquals(expectedRevCompPi, priorRevComp.get().getPi(), epsilon); }
Example #8
Source File: MathUtilsUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSumArrayFunction(){ final int min = 0; final int max = 5; // use 1 + 2 + ... + n = n(n+1)/2 // [0,1,2] + [1,2,3] + ... + [4,5,6] = [0 + 1 + ... + 4, 1 + ... + 5, 2 + ... + 6] = [10, 15, 21 - 1] = [10, 15, 20] final double[] array1 = {10, 15, 20}; ArrayAsserts.assertArrayEquals(MathUtils.sumArrayFunction(min, max, i -> new double[]{(double) i, i + 1.0, i + 2.0}), array1, 1e-8); }
Example #9
Source File: Nd4jApacheAdapterUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void assertINDArrayToApacheMatrixCorrectness(final INDArray arr) { /* brute force result */ final RealMatrix expected = new BlockRealMatrix(arr.rows(), arr.columns()); for (int i = 0; i < arr.rows(); i++) { for (int j = 0; j < arr.columns(); j++) { expected.setEntry(i, j, arr.getDouble(i, j)); } } final RealMatrix result = Nd4jApacheAdapterUtils.convertINDArrayToApacheMatrix(arr); Assert.assertEquals(result.getColumnDimension(), expected.getColumnDimension()); Assert.assertEquals(result.getRowDimension(), expected.getRowDimension()); for (int i = 0; i < expected.getRowDimension(); i++) { ArrayAsserts.assertArrayEquals(result.getData()[i], expected.getData()[i], EPS); } }
Example #10
Source File: Nd4jIOUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void tsvTensorReadWriteAsserter(final INDArray arr) { final File outFile = createTempFile("Nd4j_tensor_tsv_test", ".tsv"); Nd4jIOUtils.writeNDArrayTensorToTextFile(arr, outFile, "TEST", null); final INDArray arrLoaded = Nd4jIOUtils.readNDArrayTensorFromTextFile(outFile); ArrayAsserts.assertArrayEquals(arr.shape(), arrLoaded.shape()); ArrayAsserts.assertArrayEquals(arr.dup().data().asDouble(), arrLoaded.dup().data().asDouble(), 1e-12); }
Example #11
Source File: Nd4jIOUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void binaryReadWriteAsserter(final INDArray arr) { final File outFile = createTempFile("Nd4j_binary_dump_test", ".nd4j"); Nd4jIOUtils.writeNDArrayToBinaryDumpFile(arr, outFile); final INDArray arrLoaded = Nd4jIOUtils.readNDArrayFromBinaryDumpFile(outFile); ArrayAsserts.assertArrayEquals(arr.shape(), arrLoaded.shape()); ArrayAsserts.assertArrayEquals(arr.dup().data().asDouble(), arrLoaded.dup().data().asDouble(), 1e-12); }
Example #12
Source File: Nd4jIOUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void tsvMatrixReadWriteAsserter(final INDArray arr) { final File outFile = createTempFile("Nd4j_matrix_tsv_test", ".tsv"); Nd4jIOUtils.writeNDArrayMatrixToTextFile(arr, outFile, "TEST", null, null); final INDArray arrLoaded = Nd4jIOUtils.readNDArrayMatrixFromTextFile(outFile); ArrayAsserts.assertArrayEquals(arr.shape(), arrLoaded.shape()); ArrayAsserts.assertArrayEquals(arr.dup().data().asDouble(), arrLoaded.dup().data().asDouble(), 1e-12); }
Example #13
Source File: ReadCountCollectionUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test(dataProvider = "getColumnOnSpecifiedTargetsTestData") public void testGetColumnOnSpecifiedTargets(final ReadCountCollection rcc, final int columnIndex, final List<Target> targets, final double[] expected) { final double[] result = rcc.getColumnOnSpecifiedTargets(columnIndex, targets, true); ArrayAsserts.assertArrayEquals(expected, result, 1e-12); }
Example #14
Source File: IntegerCopyNumberTransitionProbabilityCacheUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testStationaryProbabilities() { for (final int padding : PADDINGS) { for (final RealMatrix transitionMatrix : TRANSITION_MATRICES) { final IntegerCopyNumberTransitionProbabilityCache cache = new IntegerCopyNumberTransitionProbabilityCache( new IntegerCopyNumberTransitionMatrix(transitionMatrix, padding)); final double[] stationary = cache.getStationaryProbabilityVector().toArray(); final double[] stationaryFromMultiplication = cache.getTransitionProbabilityMatrix(Integer.MAX_VALUE) .getColumn(0); ArrayAsserts.assertArrayEquals(stationary, stationaryFromMultiplication, EPSILON); Assert.assertEquals(Arrays.stream(stationary).sum(), 1.0, EPSILON); } } }
Example #15
Source File: IntegerCopyNumberTransitionProbabilityCacheUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testBasicSoundness() { for (final RealMatrix transitionMatrix : TRANSITION_MATRICES) { final IntegerCopyNumberTransitionProbabilityCache cache = new IntegerCopyNumberTransitionProbabilityCache( new IntegerCopyNumberTransitionMatrix(transitionMatrix, 0)); for (final int dist : DISTANCES) { final RealMatrix transitionMatrixExponentiated = cache.getTransitionProbabilityMatrix(dist); /* assert positivity */ Assert.assertTrue(Arrays.stream(transitionMatrixExponentiated.getData()) .flatMapToDouble(Arrays::stream) .allMatch(d -> d >= 0)); /* assert conservation of probability */ for (int c = 0; c < transitionMatrix.getColumnDimension(); c++) { Assert.assertEquals(Arrays.stream(transitionMatrixExponentiated.getColumn(c)).sum(), 1.0, EPSILON); } /* assert correctness, T(2*d) = T(d)*T(d) */ assertEqualMatrices(cache.getTransitionProbabilityMatrix(2*dist), transitionMatrixExponentiated.multiply(transitionMatrixExponentiated)); } /* assert loss of initial state over long distances, i.e. all columns must be equal */ final RealMatrix longRangeTransitionMatrix = cache.getTransitionProbabilityMatrix(Integer.MAX_VALUE); final double[] firstColumn = longRangeTransitionMatrix.getColumn(0); final RealMatrix syntheticLongRangeTransitionMatrix = new Array2DRowRealMatrix(firstColumn.length, firstColumn.length); for (int i = 0; i < firstColumn.length; i++) { syntheticLongRangeTransitionMatrix.setColumn(i, firstColumn); } assertEqualMatrices(longRangeTransitionMatrix, syntheticLongRangeTransitionMatrix); final double[] stationary = cache.getStationaryProbabilityVector().toArray(); ArrayAsserts.assertArrayEquals(stationary, firstColumn, EPSILON); } }
Example #16
Source File: GATKProtectedMathUtilsTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testSumArrayFunction(){ final int min = 0; final int max = 5; // use 1 + 2 + ... + n = n(n+1)/2 // [0,1,2] + [1,2,3] + ... + [4,5,6] = [0 + 1 + ... + 4, 1 + ... + 5, 2 + ... + 6] = [10, 15, 21 - 1] = [10, 15, 20] final double[] array1 = { 10, 15, 20 }; ArrayAsserts.assertArrayEquals(GATKProtectedMathUtils.sumArrayFunction(min, max, i -> new double[]{ (double)i, i + 1.0, i + 2.0 }), array1, 1e-8); }
Example #17
Source File: EstimatedHistogramTest.java From HaloDB with Apache License 2.0 | 5 votes |
@Test public void testGetBuckets() { EstimatedHistogram estimatedHistogram = new EstimatedHistogram( new long[]{2, 4, 0}, new long[]{1, 2, 6, 0}); ArrayAsserts.assertArrayEquals(new long[]{1, 2, 6, 0}, estimatedHistogram.getBuckets(true)); ArrayAsserts.assertArrayEquals(new long[]{0, 0, 0, 0}, estimatedHistogram.getBuckets(false)); }
Example #18
Source File: Nd4jIOUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void assertIntArrayStringRepr(final int[] indices) { final String repr = getStringReprFromIntArray(indices); final int[] reconstructed = getIntArrayFromStringRepr(repr); ArrayAsserts.assertArrayEquals(indices, reconstructed); }
Example #19
Source File: Nd4jApacheAdapterUtilsUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 4 votes |
public void assertINDArrayToApacheVectorCorrectness(final INDArray arr) { final RealVector result = Nd4jApacheAdapterUtils.convertINDArrayToApacheVector(arr); final RealVector expected = new ArrayRealVector(arr.dup().data().asDouble()); Assert.assertEquals(result.getDimension(), expected.getDimension()); ArrayAsserts.assertArrayEquals(result.toArray(), expected.toArray(), EPS); }
Example #20
Source File: CoverageModelEMComputeBlockUnitTest.java From gatk-protected with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void assertNDArrayEquals(final INDArray arr1, final INDArray arr2) { ArrayAsserts.assertArrayEquals(arr1.dup().data().asDouble(), arr2.dup().data().asDouble(), EPSILON); }
Example #21
Source File: ArtifactPriorUnitTest.java From gatk with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testIO() throws IOException { final double[] pi = new double[NUM_STATES]; Arrays.fill(pi, 1.0/NUM_STATES); final int numExamples1 = 30; final int numExamples2 = 60; final int numExamples3 = 90; final int numAltExamples1 = 10; final int numAltExamples2 = 50; final int numAltExamples3 = 1; final String referenceContext1 = "ACT"; final String referenceContext2 = "GTA"; final String referenceContext3 = "CCC"; final ArtifactPriorCollection artifactPriorCollectionBefore = new ArtifactPriorCollection("sample"); artifactPriorCollectionBefore.set(new ArtifactPrior(referenceContext1, pi, numExamples1, numAltExamples1)); artifactPriorCollectionBefore.set(new ArtifactPrior(referenceContext2, pi, numExamples2, numAltExamples2)); artifactPriorCollectionBefore.set(new ArtifactPrior(referenceContext3, pi, numExamples3, numAltExamples3)); final File table = File.createTempFile("prior", ".tsv"); artifactPriorCollectionBefore.writeArtifactPriors(table); final ArtifactPriorCollection artifactPriorCollectionAfter = ArtifactPriorCollection.readArtifactPriors(table); final ArtifactPrior ap1 = artifactPriorCollectionAfter.get(referenceContext1).get(); ArrayAsserts.assertArrayEquals(ap1.getPi(), pi, EPSILON); Assert.assertEquals(ap1.getNumExamples(), numExamples1); Assert.assertEquals(ap1.getNumAltExamples(), numAltExamples1); ArtifactPrior ap2 = artifactPriorCollectionAfter.get(referenceContext2).get(); ArrayAsserts.assertArrayEquals(ap2.getPi(), pi, EPSILON); Assert.assertEquals(ap2.getNumExamples(), numExamples2); Assert.assertEquals(ap2.getNumAltExamples(), numAltExamples2); ArtifactPrior ap3 = artifactPriorCollectionAfter.get(referenceContext3).get(); ArrayAsserts.assertArrayEquals(ap3.getPi(), pi, EPSILON); Assert.assertEquals(ap3.getNumExamples(), numExamples3); Assert.assertEquals(ap3.getNumAltExamples(), numAltExamples3); }
Example #22
Source File: SvnLogTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
private void checkLogLimit(@NotNull SVNRepository repo, long r1, long r2, int limit, @NotNull String path, @NotNull LogEntry... expecteds) throws SVNException { final List<LogEntry> actual = new ArrayList<>(); repo.log(new String[]{path}, r1, r2, true, false, limit, logEntry -> actual.add(new LogEntry(logEntry))); ArrayAsserts.assertArrayEquals(expecteds, actual.toArray(new LogEntry[0])); }