stat: unexport Panics testing helper
A+C: add Daniel Fireman
MODIFY
AUTHORS
AUTHORS
@@ -15,6 +15,7 @@ Chad Kunde <kunde21@gmail.com>
Chih-Wei Chang <bert.cwchang@gmail.com>
Chris Tessum <ctessum@gmail.com>
Dan Kortschak <dan.kortschak@adelaide.edu.au> <dan@kortschak.io>
+Daniel Fireman <danielfireman@gmail.com>
David Samborski <bloggingarrow@gmail.com>
Davor Kapsa <davor.kapsa@gmail.com>
Ekaterina Efimova <katerina.efimova@gmail.com>

MODIFY
CONTRIBUTORS
CONTRIBUTORS
@@ -23,6 +23,7 @@ Chad Kunde <kunde21@gmail.com>
Chih-Wei Chang <bert.cwchang@gmail.com>
Chris Tessum <ctessum@gmail.com>
Dan Kortschak <dan.kortschak@adelaide.edu.au> <dan@kortschak.io>
+Daniel Fireman <danielfireman@gmail.com>
David Samborski <bloggingarrow@gmail.com>
Davor Kapsa <davor.kapsa@gmail.com>
Ekaterina Efimova <katerina.efimova@gmail.com>

MODIFY
stat/stat_test.go
stat/stat_test.go
@@ -54,7 +54,7 @@ func TestCircularMean(t *testing.T) {
t.Errorf("Circular mean mismatch case %d: Expected %v, Found %v", i, test.ans, c)
}
}
- if !Panics(func() { CircularMean(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { CircularMean(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("CircularMean did not panic with x, wts length mismatch")
}
}
@@ -125,13 +125,13 @@ func TestCorrelation(t *testing.T) {
t.Errorf("Correlation mismatch case %d. Expected %v, Found %v", i, test.ans, c)
}
}
- if !Panics(func() { Correlation(make([]float64, 2), make([]float64, 3), make([]float64, 3)) }) {
+ if !panics(func() { Correlation(make([]float64, 2), make([]float64, 3), make([]float64, 3)) }) {
t.Errorf("Correlation did not panic with length mismatch")
}
- if !Panics(func() { Correlation(make([]float64, 2), make([]float64, 3), nil) }) {
+ if !panics(func() { Correlation(make([]float64, 2), make([]float64, 3), nil) }) {
t.Errorf("Correlation did not panic with length mismatch")
}
- if !Panics(func() { Correlation(make([]float64, 3), make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Correlation(make([]float64, 3), make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Correlation did not panic with weights length mismatch")
}
}
@@ -198,10 +198,10 @@ func TestCovariance(t *testing.T) {
}
// test the panic states
- if !Panics(func() { Covariance(make([]float64, 2), make([]float64, 3), nil) }) {
+ if !panics(func() { Covariance(make([]float64, 2), make([]float64, 3), nil) }) {
t.Errorf("Covariance did not panic with x, y length mismatch")
}
- if !Panics(func() { Covariance(make([]float64, 3), make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Covariance(make([]float64, 3), make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Covariance did not panic with x, weights length mismatch")
}
@@ -239,7 +239,7 @@ func TestCrossEntropy(t *testing.T) {
t.Errorf("Cross entropy mismatch case %d: Expected %v, Found %v", i, test.ans, c)
}
}
- if !Panics(func() { CrossEntropy(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { CrossEntropy(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("CrossEntropy did not panic with p, q length mismatch")
}
}
@@ -293,7 +293,7 @@ distribution`)
func TestExKurtosis(t *testing.T) {
// the example does a good job, this just has to cover the panic
- if !Panics(func() { ExKurtosis(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { ExKurtosis(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("ExKurtosis did not panic with x, weights length mismatch")
}
}
@@ -337,7 +337,7 @@ func TestGeometricMean(t *testing.T) {
t.Errorf("Geometric mean mismatch case %d: Expected %v, Found %v", i, test.ans, c)
}
}
- if !Panics(func() { GeometricMean(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { GeometricMean(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("GeometricMean did not panic with x, wts length mismatch")
}
}
@@ -374,7 +374,7 @@ func TestHarmonicMean(t *testing.T) {
t.Errorf("Harmonic mean mismatch case %d: Expected %v, Found %v", i, test.ans, c)
}
}
- if !Panics(func() { HarmonicMean(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { HarmonicMean(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("HarmonicMean did not panic with x, wts length mismatch")
}
}
@@ -469,7 +469,7 @@ func TestHistogram(t *testing.T) {
dividers: []float64{2, 3},
},
} {
- if !Panics(func() { Histogram(test.count, test.dividers, test.x, test.weights) }) {
+ if !panics(func() { Histogram(test.count, test.dividers, test.x, test.weights) }) {
t.Errorf("Histogram did not panic when %s", test.name)
}
}
@@ -571,7 +571,7 @@ func TestJensenShannon(t *testing.T) {
t.Errorf("JS mismatch case %v. Expected %v, found %v.", i, js1, js2)
}
}
- if !Panics(func() { JensenShannon(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { JensenShannon(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("JensenShannon did not panic with p, q length mismatch")
}
}
@@ -771,7 +771,7 @@ func TestKolmogorovSmirnov(t *testing.T) {
y: []float64{10, 3, 5, 6, 7, 8},
},
} {
- if !Panics(func() { KolmogorovSmirnov(test.x, test.xWeights, test.y, test.yWeights) }) {
+ if !panics(func() { KolmogorovSmirnov(test.x, test.xWeights, test.y, test.yWeights) }) {
t.Errorf("KolmogorovSmirnov did not panic when %s", test.name)
}
}
@@ -803,7 +803,7 @@ func ExampleKullbackLeibler() {
}
func TestKullbackLeibler(t *testing.T) {
- if !Panics(func() { KullbackLeibler(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { KullbackLeibler(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("KullbackLeibler did not panic with p, q length mismatch")
}
}
@@ -946,13 +946,13 @@ func TestChiSquare(t *testing.T) {
t.Errorf("ChiSquare distance mismatch in case %d. Expected %v, Found %v", i, test.res, resultpq)
}
}
- if !Panics(func() { ChiSquare(make([]float64, 2), make([]float64, 3)) }) {
+ if !panics(func() { ChiSquare(make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("ChiSquare did not panic with length mismatch")
}
}
-// Panics returns true if the called function panics during evaluation.
-func Panics(fun func()) (b bool) {
+// panics returns true if the called function panics during evaluation.
+func panics(fun func()) (b bool) {
defer func() {
err := recover()
if err != nil {
@@ -996,7 +996,7 @@ func TestBhattacharyya(t *testing.T) {
}
}
// Bhattacharyya should panic if the inputs have different length
- if !Panics(func() { Bhattacharyya(make([]float64, 2), make([]float64, 3)) }) {
+ if !panics(func() { Bhattacharyya(make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Bhattacharyya did not panic with length mismatch")
}
}
@@ -1033,7 +1033,7 @@ func TestHellinger(t *testing.T) {
t.Errorf("Hellinger distance is assymmetric in case %d.", i)
}
}
- if !Panics(func() { Hellinger(make([]float64, 2), make([]float64, 3)) }) {
+ if !panics(func() { Hellinger(make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Hellinger did not panic with length mismatch")
}
}
@@ -1056,7 +1056,7 @@ func ExampleMean() {
// The weights act as if there were more samples of that number
}
func TestMean(t *testing.T) {
- if !Panics(func() { Mean(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Mean(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Mean did not panic with x, weights length mismatch")
}
}
@@ -1089,7 +1089,7 @@ func TestMode(t *testing.T) {
t.Errorf("Mode count mismatch case %d. Expected %v, found %v", i, test.count, count)
}
}
- if !Panics(func() { Mode(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Mode(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Mode did not panic with x, weights length mismatch")
}
}
@@ -1137,16 +1137,16 @@ func TestMixedMoment(t *testing.T) {
t.Errorf("Moment mismatch case %d. Expected %v, found %v", i, test.ans, m)
}
}
- if !Panics(func() { BivariateMoment(1, 1, make([]float64, 3), make([]float64, 2), nil) }) {
+ if !panics(func() { BivariateMoment(1, 1, make([]float64, 3), make([]float64, 2), nil) }) {
t.Errorf("Moment did not panic with x, y length mismatch")
}
- if !Panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 3), nil) }) {
+ if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 3), nil) }) {
t.Errorf("Moment did not panic with x, y length mismatch")
}
- if !Panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 3)) }) {
+ if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
- if !Panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 1)) }) {
+ if !panics(func() { BivariateMoment(1, 1, make([]float64, 2), make([]float64, 2), make([]float64, 1)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
}
@@ -1175,10 +1175,10 @@ func TestMoment(t *testing.T) {
t.Errorf("Moment mismatch case %d. Expected %v, found %v", i, test.ans, m)
}
}
- if !Panics(func() { Moment(1, make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Moment(1, make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
- if !Panics(func() { Moment(1, make([]float64, 2), make([]float64, 3)) }) {
+ if !panics(func() { Moment(1, make([]float64, 2), make([]float64, 3)) }) {
t.Errorf("Moment did not panic with x, weights length mismatch")
}
}
@@ -1210,7 +1210,7 @@ func TestMomentAbout(t *testing.T) {
t.Errorf("MomentAbout mismatch case %d. Expected %v, found %v", i, test.ans, m)
}
}
- if !Panics(func() { MomentAbout(1, make([]float64, 3), 0, make([]float64, 2)) }) {
+ if !panics(func() { MomentAbout(1, make([]float64, 3), 0, make([]float64, 2)) }) {
t.Errorf("MomentAbout did not panic with x, weights length mismatch")
}
}
@@ -1292,7 +1292,7 @@ func TestCDF(t *testing.T) {
x: []float64{1, 2, 3},
},
} {
- if !Panics(func() { CDF(test.q, test.kind, test.x, test.weights) }) {
+ if !panics(func() { CDF(test.q, test.kind, test.x, test.weights) }) {
t.Errorf("did not panic as expected with %s for case %d kind %d percentile %v x %v weights %v", test.name, i, test.kind, test.q, test.x, test.weights)
}
}
@@ -1390,7 +1390,7 @@ func TestQuantile(t *testing.T) {
x: []float64{1, 2, 3},
},
} {
- if !Panics(func() { Quantile(test.p, test.c, test.x, test.w) }) {
+ if !panics(func() { Quantile(test.p, test.c, test.x, test.w) }) {
t.Errorf("Quantile did not panic when %s", test.name)
}
}
@@ -1449,7 +1449,7 @@ func TestSkew(t *testing.T) {
t.Errorf("Skew mismatch case %d. Expected %v, Found %v", i, test.ans, skew)
}
}
- if !Panics(func() { Skew(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Skew(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Skew did not panic with x, weights length mismatch")
}
}
@@ -1480,7 +1480,7 @@ func TestSortWeighted(t *testing.T) {
t.Errorf("SortWeighted mismatch case %d. Expected w %v, Found w %v", i, test.answ, test.w)
}
}
- if !Panics(func() { SortWeighted(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { SortWeighted(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("SortWeighted did not panic with x, weights length mismatch")
}
}
@@ -1530,16 +1530,16 @@ func TestSortWeightedLabeled(t *testing.T) {
t.Errorf("SortWeightedLabelled mismatch case %d. Expected w %v, Found w %v", i, test.answ, test.w)
}
}
- if !Panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), make([]float64, 3)) }) {
+ if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), make([]float64, 3)) }) {
t.Errorf("SortWeighted did not panic with x, labels length mismatch")
}
- if !Panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), nil) }) {
+ if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 2), nil) }) {
t.Errorf("SortWeighted did not panic with x, labels length mismatch")
}
- if !Panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 3), make([]float64, 2)) }) {
+ if !panics(func() { SortWeightedLabeled(make([]float64, 3), make([]bool, 3), make([]float64, 2)) }) {
t.Errorf("SortWeighted did not panic with x, weights length mismatch")
}
- if !Panics(func() { SortWeightedLabeled(make([]float64, 3), nil, make([]float64, 2)) }) {
+ if !panics(func() { SortWeightedLabeled(make([]float64, 3), nil, make([]float64, 2)) }) {
t.Errorf("SortWeighted did not panic with x, weights length mismatch")
}
}
@@ -1581,7 +1581,7 @@ func TestVariance(t *testing.T) {
t.Errorf("Variance mismatch case %d. Expected %v, Found %v", i, test.ans, variance)
}
}
- if !Panics(func() { Variance(make([]float64, 3), make([]float64, 2)) }) {
+ if !panics(func() { Variance(make([]float64, 3), make([]float64, 2)) }) {
t.Errorf("Variance did not panic with x, weights length mismatch")
}

MODIFY
stat/statmat_test.go
stat/statmat_test.go
@@ -87,13 +87,13 @@ func TestCovarianceMatrix(t *testing.T) {
}
}
- if !Panics(func() { CovarianceMatrix(nil, mat.NewDense(5, 2, nil), []float64{}) }) {
+ if !panics(func() { CovarianceMatrix(nil, mat.NewDense(5, 2, nil), []float64{}) }) {
t.Errorf("CovarianceMatrix did not panic with weight size mismatch")
}
- if !Panics(func() { CovarianceMatrix(mat.NewSymDense(1, nil), mat.NewDense(5, 2, nil), nil) }) {
+ if !panics(func() { CovarianceMatrix(mat.NewSymDense(1, nil), mat.NewDense(5, 2, nil), nil) }) {
t.Errorf("CovarianceMatrix did not panic with preallocation size mismatch")
}
- if !Panics(func() { CovarianceMatrix(nil, mat.NewDense(2, 2, []float64{1, 2, 3, 4}), []float64{1, -1}) }) {
+ if !panics(func() { CovarianceMatrix(nil, mat.NewDense(2, 2, []float64{1, 2, 3, 4}), []float64{1, -1}) }) {
t.Errorf("CovarianceMatrix did not panic with negative weights")
}
}
@@ -183,13 +183,13 @@ func TestCorrelationMatrix(t *testing.T) {
}
}
- if !Panics(func() { CorrelationMatrix(nil, mat.NewDense(5, 2, nil), []float64{}) }) {
+ if !panics(func() { CorrelationMatrix(nil, mat.NewDense(5, 2, nil), []float64{}) }) {
t.Errorf("CorrelationMatrix did not panic with weight size mismatch")
}
- if !Panics(func() { CorrelationMatrix(mat.NewSymDense(1, nil), mat.NewDense(5, 2, nil), nil) }) {
+ if !panics(func() { CorrelationMatrix(mat.NewSymDense(1, nil), mat.NewDense(5, 2, nil), nil) }) {
t.Errorf("CorrelationMatrix did not panic with preallocation size mismatch")
}
- if !Panics(func() { CorrelationMatrix(nil, mat.NewDense(2, 2, []float64{1, 2, 3, 4}), []float64{1, -1}) }) {
+ if !panics(func() { CorrelationMatrix(nil, mat.NewDense(2, 2, []float64{1, 2, 3, 4}), []float64{1, -1}) }) {
t.Errorf("CorrelationMatrix did not panic with negative weights")
}
}
@@ -256,7 +256,7 @@ func TestCorrCov(t *testing.T) {
t.Errorf("%d: covToCorr did not match direct Covariance calculation. Want: %v, got: %v. ", i, cov, covFromCorr)
}
- if !Panics(func() { corrToCov(mat.NewSymDense(2, nil), []float64{}) }) {
+ if !panics(func() { corrToCov(mat.NewSymDense(2, nil), []float64{}) }) {
t.Errorf("CorrelationMatrix did not panic with sigma size mismatch")
}
}

stat: unexport Panics testing helper

A+C: add Daniel Fireman