Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Stream support to Stats and StatsAccumulator.
This adds: - A static method Stats.toStats() that returns a Collector<Number, StatsAccumulator, Stats>. - Stats.of overloads and StatsAccumulator.addAll overloads that take DoubleStream, IntStream, and LongStream. - A StatsAccumulator.addAll overload that takes StatsAccumulator. (In passing, this also improves the tests in a couple of ways. It removes the use of static initializer blocks in StatsTesting, which is contrary to best practice. And it fixes some tolerances on the assertions: the min() and max() ones should use exact equality, and the ones with INTEGER_MANY_VALUES and LONG_MANY_VALUES should scale up the tolerance to match the order of magnitude of the values. This latter change fixes the ErrorProne warnings that, in some cases, the tolerance was actually less than the difference between the expected value and the next nearest double. It just happened that everything was close enough before.) RELNOTES=Add Stream support to Stats and StatsAccumulator. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=274998178
- Loading branch information
Showing
10 changed files
with
624 additions
and
362 deletions.
There are no files selected for viewing
166 changes: 82 additions & 84 deletions
166
android/guava-tests/test/com/google/common/math/StatsAccumulatorTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.