Tabnine Logo
DoubleSubject$TolerantDoubleComparison.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
com.google.common.truth.DoubleSubject$TolerantDoubleComparison

Best Java code snippets using com.google.common.truth.DoubleSubject$TolerantDoubleComparison.of (Showing top 20 results out of 315)

origin: google/guava

 private static void assertEquivalent(double actual, double expected) {
  if (expected == POSITIVE_INFINITY) {
   assertThat(actual).isPositiveInfinity();
  } else if (expected == NEGATIVE_INFINITY) {
   assertThat(actual).isNegativeInfinity();
  } else if (Double.isNaN(expected)) {
   assertThat(actual).isNaN();
  } else {
   assertThat(actual).isWithin(ALLOWED_ERROR).of(expected);
  }
 }
}
origin: google/guava

 public void testMultipleQuantile() {
  ImmutableSet<Integer> indexes = ImmutableSet.of(50, 90, 99);
  Map<Integer, Double> referenceQuantiles =
    REFERENCE_ALGORITHM.multipleQuantiles(indexes, 100, dataset.clone());
  assertThat(referenceQuantiles.keySet()).isEqualTo(indexes);
  for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
   Map<Integer, Double> quantiles = algorithm.multipleQuantiles(indexes, 100, dataset.clone());
   assertWithMessage("Wrong keys from " + algorithm).that(quantiles.keySet()).isEqualTo(indexes);
   for (int i : indexes) {
    assertWithMessage("Mismatch between %s and %s at %s", algorithm, REFERENCE_ALGORITHM, i)
      .that(quantiles.get(i))
      .isWithin(ALLOWED_ERROR)
      .of(referenceQuantiles.get(i));
   }
  }
 }
}
origin: google/guava

public void testMappingWithSlope_maximalSlope() {
 double x1 = 1.2;
 double y1 = 3.4;
 double slope = Double.MAX_VALUE;
 LinearTransformation transformation = LinearTransformation.mapping(x1, y1).withSlope(slope);
 assertThat(transformation.isVertical()).isFalse();
 assertThat(transformation.isHorizontal()).isFalse();
 assertThat(transformation.slope()).isWithin(ALLOWED_ERROR).of(slope);
 // Note that we cannot test the actual mapping of points, as the results will be unreliable due
 // to loss of precision with this value of the slope.
}
origin: google/guava

@AndroidIncompatible // slow
public void testPercentiles_index_computeInPlace() {
 // Assert that the computation gives the correct result for all possible percentiles.
 for (int index = 0; index <= 100; index++) {
  double[] dataset = Doubles.toArray(PSEUDORANDOM_DATASET);
  assertThat(percentiles().index(index).computeInPlace(dataset))
    .named("quantile at index " + index)
    .isWithin(ALLOWED_ERROR)
    .of(expectedLargeDatasetPercentile(index));
 }
 // Assert that the dataset contains the same elements after the in-place computation (although
 // they may be reordered). We only do this for one index rather than for all indexes, as it is
 // quite expensives (quadratic in the size of PSEUDORANDOM_DATASET).
 double[] dataset = Doubles.toArray(PSEUDORANDOM_DATASET);
 @SuppressWarnings("unused")
 double actual = percentiles().index(33).computeInPlace(dataset);
 assertThat(dataset).usingExactEquality().containsExactlyElementsIn(PSEUDORANDOM_DATASET);
}
origin: google/guava

public void testSingleQuantile_median() {
 double referenceValue = REFERENCE_ALGORITHM.singleQuantile(1, 2, dataset.clone());
 for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
  assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
    .that(algorithm.singleQuantile(1, 2, dataset.clone()))
    .isWithin(ALLOWED_ERROR)
    .of(referenceValue);
 }
}
origin: google/guava

public void testMappingWithSlope_minimalSlope() {
 double x1 = 1.2;
 double y1 = 3.4;
 double slope = Double.MIN_VALUE;
 LinearTransformation transformation = LinearTransformation.mapping(x1, y1).withSlope(slope);
 assertThat(transformation.isVertical()).isFalse();
 assertThat(transformation.isHorizontal()).isFalse();
 assertThat(transformation.slope()).isWithin(ALLOWED_ERROR).of(slope);
 // Note that we cannot test the actual mapping of points, as the results will be unreliable due
 // to loss of precision with this value of the slope.
}
origin: google/guava

public void testScale_index_compute_longVarargs() {
 long[] dataset = Longs.toArray(SIXTEEN_SQUARES_LONGS);
 assertThat(Quantiles.scale(10).index(1).compute(dataset))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
 assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_LONGS);
}
origin: google/guava

public void testQuartiles_index_compute_doubleCollection() {
 assertThat(quartiles().index(1).compute(SIXTEEN_SQUARES_DOUBLES))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_QUARTILE_1);
}
origin: google/guava

public void testScale_index_computeInPlace_explicitVarargs() {
 assertThat(Quantiles.scale(10).index(5).computeInPlace(78.9, 12.3, 45.6))
   .isWithin(ALLOWED_ERROR)
   .of(45.6);
}
origin: google/guava

public void testScale_index_compute_doubleVarargs() {
 double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
 assertThat(Quantiles.scale(10).index(1).compute(dataset))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
 assertThat(dataset)
   .usingExactEquality()
   .containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES)
   .inOrder();
}
origin: google/guava

public void testScale_index_compute_longCollection() {
 assertThat(Quantiles.scale(10).index(1).compute(SIXTEEN_SQUARES_LONGS))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
}
origin: google/guava

public void testQuartiles_index_computeInPlace() {
 double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
 assertThat(quartiles().index(1).computeInPlace(dataset))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_QUARTILE_1);
 assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
}
origin: google/guava

public void testMedian_computeInPlace() {
 double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
 assertThat(median().computeInPlace(dataset)).isWithin(ALLOWED_ERROR).of(SIXTEEN_SQUARES_MEDIAN);
 assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
}
origin: google/guava

public void testPercentiles_index_compute_doubleCollection() {
 for (int index = 0; index <= 100; index++) {
  assertThat(percentiles().index(index).compute(PSEUDORANDOM_DATASET))
    .named("quantile at index " + index)
    .isWithin(ALLOWED_ERROR)
    .of(expectedLargeDatasetPercentile(index));
 }
}
origin: google/guava

public void testMedian_compute_doubleCollection() {
 assertThat(median().compute(SIXTEEN_SQUARES_DOUBLES))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_MEDIAN);
}
origin: google/guava

public void testScale_index_computeInPlace() {
 double[] dataset = Doubles.toArray(SIXTEEN_SQUARES_DOUBLES);
 assertThat(Quantiles.scale(10).index(1).computeInPlace(dataset))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
 assertThat(dataset).usingExactEquality().containsExactlyElementsIn(SIXTEEN_SQUARES_DOUBLES);
}
origin: google/guava

public void testScale_index_compute_intVarargs() {
 int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
 assertThat(Quantiles.scale(10).index(1).compute(dataset))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
 assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_INTEGERS);
}
origin: google/guava

public void testSingleQuantile_percentile99() {
 double referenceValue = REFERENCE_ALGORITHM.singleQuantile(99, 100, dataset.clone());
 for (QuantilesAlgorithm algorithm : NON_REFERENCE_ALGORITHMS) {
  assertWithMessage("Mismatch between %s and %s", algorithm, REFERENCE_ALGORITHM)
    .that(algorithm.singleQuantile(99, 100, dataset.clone()))
    .isWithin(ALLOWED_ERROR)
    .of(referenceValue);
 }
}
origin: google/guava

public void testScale_index_compute_integerCollection() {
 assertThat(Quantiles.scale(10).index(1).compute(SIXTEEN_SQUARES_INTEGERS))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
}
origin: google/guava

public void testScale_index_compute_doubleCollection() {
 assertThat(Quantiles.scale(10).index(1).compute(SIXTEEN_SQUARES_DOUBLES))
   .isWithin(ALLOWED_ERROR)
   .of(SIXTEEN_SQUARES_DECILE_1);
}
com.google.common.truthDoubleSubject$TolerantDoubleComparisonof

Javadoc

Fails if the subject was expected to be within the tolerance of the given value but was not or if it was expected not to be within the tolerance but was. The subject and tolerance are specified earlier in the fluent call chain.

Popular methods of DoubleSubject$TolerantDoubleComparison

    Popular in Java

    • Parsing JSON documents to java classes using gson
    • getExternalFilesDir (Context)
    • onRequestPermissionsResult (Fragment)
    • addToBackStack (FragmentTransaction)
    • BorderLayout (java.awt)
      A border layout lays out a container, arranging and resizing its components to fit in five regions:
    • Menu (java.awt)
    • TreeSet (java.util)
      TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
    • ImageIO (javax.imageio)
    • Response (javax.ws.rs.core)
      Defines the contract between a returned instance and the runtime when an application needs to provid
    • BasicDataSource (org.apache.commons.dbcp)
      Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
    • Best IntelliJ plugins
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now