Skip to content

Commit

Permalink
More test cleanups.
Browse files Browse the repository at this point in the history
Related to #89
  • Loading branch information
tdunning committed Jul 15, 2017
1 parent f2f6970 commit b19ae1d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/com/tdunning/math/stats/TDigestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ public String call() throws Exception {
for (Future<String> result : executor.invokeAll(tasks)) {
out.write(result.get());
}
} catch (Throwable e) {
e.printStackTrace();
throw e;
} finally {
executor.shutdownNow();
executor.awaitTermination(5, TimeUnit.SECONDS);
Expand Down Expand Up @@ -707,6 +710,24 @@ public void testThreePointExample() {
// System.out.println();
}

@Test
public void testSingletonInACrowd() {
final double compression = 100;
TDigest dist = factory(compression).create();
for (int i = 0; i < 10000; i++) {
dist.add(10);
}
dist.add(20);
dist.compress();
assertEquals(10.0, dist.quantile(0), 0);
assertEquals(10.0, dist.quantile(0.5), 0);
assertEquals(10.0, dist.quantile(0.8), 0);
assertEquals(10.0, dist.quantile(0.9), 0);
assertEquals(10.0, dist.quantile(0.99), 0);
assertEquals(10.0, dist.quantile(0.999), 0);
assertEquals(20.0, dist.quantile(1), 0);
}

@Test
public void testIntEncoding() {
Random gen = getRandom();
Expand Down

0 comments on commit b19ae1d

Please sign in to comment.