Skip to content

Commit

Permalink
build upgrade
Browse files Browse the repository at this point in the history
turned off GenJavaDoc due to inability to resolve the plugin jar
See isarn#17
  • Loading branch information
SemanticBeeng committed Sep 7, 2021
1 parent 75a7523 commit d93a5df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 72 deletions.
44 changes: 11 additions & 33 deletions src/test/scala/org/isarnproject/sketches/TDigestTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ class TDigestTest extends AsyncWordSpec with Matchers {
}

def testSamplingPDF(td: TDigest, dist: RealDistribution): Boolean = {
val tdSamples = Array.fill(10000) {
td.samplePDF
}
val distSamples = Array.fill(10000) {
dist.sample
}
val tdSamples = Array.fill(10000) { td.samplePDF }
val distSamples = Array.fill(10000) { dist.sample }
val kst = new org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest()
val d = kst.kolmogorovSmirnovStatistic(tdSamples, distSamples)
val pass = d <= maxD
Expand All @@ -67,12 +63,8 @@ class TDigestTest extends AsyncWordSpec with Matchers {

def testSamplingPMF(td: TDigest, dist: IntegerDistribution): Boolean = {
td.nclusters should be <= (td.maxDiscrete)
val tdSamples = Array.fill(10000) {
td.samplePMF
}
val distSamples = Array.fill(10000) {
dist.sample.toDouble
}
val tdSamples = Array.fill(10000) { td.samplePMF }
val distSamples = Array.fill(10000) { dist.sample.toDouble }
val kst = new org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest()
val d = kst.kolmogorovSmirnovStatistic(tdSamples, distSamples)
val pass = d <= maxD
Expand All @@ -83,18 +75,14 @@ class TDigestTest extends AsyncWordSpec with Matchers {
def testDistribution(dist: RealDistribution, stdv: Double): Boolean = {
dist.reseedRandomGenerator(seed)

val td = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val td = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)

testTDvsDist(td, dist, stdv) && testSamplingPDF(td, dist)
}

def testMonotoneCDF(dist: RealDistribution): Boolean = {
dist.reseedRandomGenerator(seed)
val td = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val td = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)
val (xmin, xmax) = (td.clusters.keyMin.get, td.clusters.keyMax.get)
val step = (xmax - xmin) / 100000
val t = (xmin to xmax by step).iterator.map(x => td.cdf(x)).sliding(2).map(w => w(1) - w(0)).min
Expand All @@ -105,9 +93,7 @@ class TDigestTest extends AsyncWordSpec with Matchers {

def testMonotoneCDFI(dist: RealDistribution): Boolean = {
dist.reseedRandomGenerator(seed)
val td = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val td = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)
val (xmin, xmax) = (0.0, 1.0)
val step = (xmax - xmin) / 100000
val t = (xmin to xmax by step).iterator.map(q => td.cdfInverse(q)).sliding(2).map(w => w(1) - w(0)).min
Expand Down Expand Up @@ -145,12 +131,8 @@ class TDigestTest extends AsyncWordSpec with Matchers {
val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)

val td1 = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val td2 = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val td1 = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)
val td2 = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)

testTDvsDist(td1 ++ td2, dist, math.sqrt(dist.getNumericalVariance())) should be(true)
}
Expand Down Expand Up @@ -185,9 +167,7 @@ class TDigestTest extends AsyncWordSpec with Matchers {
"respect maxDiscrete parameter over ++" in {
import org.apache.commons.math3.distribution.GeometricDistribution
val gd = new GeometricDistribution(0.33)
val tdvec = Vector.fill(10) {
TDigest.sketch(gd.sample(100000), maxDiscrete = 50)
}
val tdvec = Vector.fill(10) { TDigest.sketch(gd.sample(100000), maxDiscrete = 50) }
val td = tdvec.reduce(_ ++ _)
val clust = td.clusters
clust.keys.map(_.toInt).map(_.toDouble) should beEqSeq(clust.keys)
Expand All @@ -207,9 +187,7 @@ class TDigestTest extends AsyncWordSpec with Matchers {
val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)

val tdo = TDigest.sketch(Iterator.fill(ss) {
dist.sample
}, delta = delta)
val tdo = TDigest.sketch(Iterator.fill(ss) { dist.sample }, delta = delta)

val tdi = roundTripSerDe(tdo)

Expand Down
52 changes: 13 additions & 39 deletions src/test/scala/org/isarnproject/sketches/java/JavaTDigestTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {
}

def testSamplingPDF(td: TDigest, dist: RealDistribution): Boolean = {
val tdSamples = Array.fill(10000) {
td.samplePDF
}
val distSamples = Array.fill(10000) {
dist.sample
}
val tdSamples = Array.fill(10000) { td.samplePDF }
val distSamples = Array.fill(10000) { dist.sample }
val kst = new org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest()
val d = kst.kolmogorovSmirnovStatistic(tdSamples, distSamples)
val pass = d <= maxD
Expand All @@ -67,12 +63,8 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {

def testSamplingPMF(td: TDigest, dist: IntegerDistribution): Boolean = {
td.nclusters should be <= (td.maxDiscrete)
val tdSamples = Array.fill(10000) {
td.samplePMF
}
val distSamples = Array.fill(10000) {
dist.sample.toDouble
}
val tdSamples = Array.fill(10000) { td.samplePMF }
val distSamples = Array.fill(10000) { dist.sample.toDouble }
val kst = new org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest()
val d = kst.kolmogorovSmirnovStatistic(tdSamples, distSamples)
val pass = d <= maxD
Expand All @@ -83,18 +75,14 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {
def testDistribution(dist: RealDistribution, stdv: Double): Boolean = {
dist.reseedRandomGenerator(seed)

val td = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val td = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)

testTDvsDist(td, dist, stdv) && testSamplingPDF(td, dist)
}

def testMonotoneCDF(dist: RealDistribution): Boolean = {
dist.reseedRandomGenerator(seed)
val td = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val td = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)
val (xmin, xmax) = (td.cent(0), td.cent(td.nclusters - 1))
val step = (xmax - xmin) / 100000
val t = (xmin to xmax by step).iterator.map(x => td.cdf(x)).sliding(2).map(w => w(1) - w(0)).min
Expand All @@ -105,9 +93,7 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {

def testMonotoneCDFI(dist: RealDistribution): Boolean = {
dist.reseedRandomGenerator(seed)
val td = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val td = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)
val (xmin, xmax) = (0.0, 1.0)
val step = (xmax - xmin) / 100000
val t = (xmin to xmax by step).iterator.map(q => td.cdfInverse(q)).sliding(2).map(w => w(1) - w(0)).min
Expand Down Expand Up @@ -144,12 +130,8 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {
val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)

val td1 = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val td2 = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val td1 = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)
val td2 = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)

testTDvsDist(TDigest.merge(td1, td2), dist, math.sqrt(dist.getNumericalVariance())) should be(true)
}
Expand Down Expand Up @@ -184,9 +166,7 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {
"respect maxDiscrete parameter over merge" in {
import org.apache.commons.math3.distribution.GeometricDistribution
val gd = new GeometricDistribution(0.33)
val tdvec = Vector.fill(10) {
TDigest.sketch(gd.sample(100000).map(_.toDouble), delta, 50)
}
val tdvec = Vector.fill(10) { TDigest.sketch(gd.sample(100000).map(_.toDouble), delta, 50) }
val td = tdvec.reduce((a, b) => TDigest.merge(a, b))
val clust = td.cent
clust.map(_.toInt).map(_.toDouble).toVector should beEqSeq(clust.toVector)
Expand All @@ -203,9 +183,7 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {

val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)
val data = Array.fill(ss) {
dist.sample
}
val data = Array.fill(ss) { dist.sample }
val td1 = TDigest.sketch(data, delta)
val td2 = new TDigest(td1)
(td2.equals(td1)) should be(true)
Expand Down Expand Up @@ -241,9 +219,7 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {

val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)
val data = Array.fill(ss) {
dist.sample
}
val data = Array.fill(ss) { dist.sample }

// test constructing empty t-digests
val td1 = new TDigest(0.5, 0, Array.empty[Double], Array.empty[Double])
Expand Down Expand Up @@ -287,9 +263,7 @@ class JavaTDigestTest extends AsyncWordSpec with Matchers {
val dist = new NormalDistribution()
dist.reseedRandomGenerator(seed)

val tdo = TDigest.sketch(Array.fill(ss) {
dist.sample
}, delta)
val tdo = TDigest.sketch(Array.fill(ss) { dist.sample }, delta)

val tdi = roundTripSerDe(tdo)

Expand Down

0 comments on commit d93a5df

Please sign in to comment.