@@ -134,7 +134,7 @@ public InternalAggregation doReduce(InternalAggregations aggregations, Aggregati
134134 }
135135
136136 ChangePointBucket changePointBucket = null ;
137- if (change .changePoint () >= 0 ) {
137+ if (change .changePoint () != ChangeType . NO_CHANGE_POINT ) {
138138 changePointBucket = extractBucket (bucketsPaths ()[0 ], aggregations , change .changePoint ()).map (
139139 b -> new ChangePointBucket (b .getKey (), b .getDocCount (), b .getAggregations ())
140140 ).orElse (null );
@@ -299,7 +299,7 @@ static TestStats testTrendVs(TestStats H0, double[] values, double[] weights) {
299299 static TestStats testStepChangeVs (TestStats H0 , double [] values , double [] weights , int [] candidateChangePoints ) {
300300
301301 double vStep = Double .MAX_VALUE ;
302- int changePoint = - 1 ;
302+ int changePoint = ChangeType . NO_CHANGE_POINT ;
303303
304304 // Initialize running stats so that they are only missing the individual changepoint values
305305 RunningStats lowerRange = new RunningStats ();
@@ -336,7 +336,7 @@ static TestStats testStepChangeVs(TestStats H0, double[] values, double[] weight
336336 static TestStats testTrendChangeVs (TestStats H0 , double [] values , double [] weights , int [] candidateChangePoints ) {
337337
338338 double vChange = Double .MAX_VALUE ;
339- int changePoint = - 1 ;
339+ int changePoint = ChangeType . NO_CHANGE_POINT ;
340340
341341 // Initialize running stats so that they are only missing the individual changepoint values
342342 RunningStats lowerRange = new RunningStats ();
@@ -451,7 +451,7 @@ static TestStats testDistributionChange(
451451 ) {
452452
453453 double maxDiff = 0.0 ;
454- int changePoint = - 1 ;
454+ int changePoint = ChangeType . NO_CHANGE_POINT ;
455455
456456 // Initialize running stats so that they are only missing the individual changepoint values
457457 RunningStats lowerRange = new RunningStats ();
@@ -484,6 +484,9 @@ static TestStats testDistributionChange(
484484
485485 double pValue = 1 ;
486486 for (int cp : sampleData .changePoints ()) {
487+ if (cp == ChangeType .NO_CHANGE_POINT ) {
488+ continue ;
489+ }
487490 double [] x = Arrays .copyOfRange (sampleValues , 0 , cp );
488491 double [] y = Arrays .copyOfRange (sampleValues , cp , sampleValues .length );
489492 double statistic = KOLMOGOROV_SMIRNOV_TEST .kolmogorovSmirnovStatistic (x , y );
@@ -520,7 +523,7 @@ record TestStats(Type type, double pValue, double var, double nParams, int chang
520523 }
521524
522525 TestStats (Type type , double pValue , double var , double nParams , DataStats dataStats ) {
523- this (type , pValue , var , nParams , - 1 , dataStats );
526+ this (type , pValue , var , nParams , ChangeType . NO_CHANGE_POINT , dataStats );
524527 }
525528
526529 boolean accept (double pValueThreshold ) {
0 commit comments