Skip to content

Commit

Permalink
Exclude all transitive dependencies of ssj besides commons-math3
Browse files Browse the repository at this point in the history
…and replace linear regression implementation (#638)
  • Loading branch information
dwnusbaum authored Aug 19, 2024
1 parent 47443bc commit 6077688
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
19 changes: 8 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,11 @@
<groupId>ca.umontreal.iro.simul</groupId>
<artifactId>ssj</artifactId>
<version>3.3.2</version>
<!-- Dependencies are unused, provided by Jenkins core, have unusual licenses, unclear artifact ownership, and/or are obsolete. We only use SmoothingCubicSpline, which does not require dependencies. -->
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<!-- Provided by Jenkins core -->
<exclusion>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
</exclusion>
<exclusion>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -104,6 +96,11 @@
<groupId>io.jenkins.plugins</groupId>
<artifactId>plugin-util-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>display-url-api</artifactId>
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/hudson/tasks/junit/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import jenkins.util.SystemProperties;
import org.apache.commons.math3.stat.regression.SimpleRegression;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.bind.JavaScriptMethod;
import umontreal.ssj.functionfit.LeastSquares;
import umontreal.ssj.functionfit.SmoothingCubicSpline;

/**
Expand Down Expand Up @@ -248,7 +248,13 @@ private void createLinearTrend(
if (history.size() < 3) {
return;
}
double[] cs = LeastSquares.calcCoefficients(lrX, lrY);

SimpleRegression sr = new SimpleRegression(true);
for (int i = 0; i < lrX.length; i++) {
sr.addData(lrX[i], lrY[i]);
}
double intercept = sr.getIntercept();
double slope = sr.getSlope();

ObjectNode lrSeries = MAPPER.createObjectNode();
series.add(lrSeries);
Expand All @@ -273,7 +279,7 @@ private void createLinearTrend(
}
for (int index = 0; index < history.size(); ++index) {
// Use float to reduce JSON size.
lrData.add((float) (Math.round((cs[0] + index * cs[1]) * roundMul) / roundMul));
lrData.add((float) (Math.round((intercept + index * slope) * roundMul) / roundMul));
}
}

Expand Down

0 comments on commit 6077688

Please sign in to comment.