Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude all transitive dependencies of ssj besides commons-math3 and replace linear regression implementation #638

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already a dependency via ssj, I think it was just unused previously, but now we use it for SimpleRegression.

<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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses libraries from colt, which we can avoid by using SimpleRegression instead.

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]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit awkward, but the SimpleRegression methods that accept arrays of data expect double[n][2] instead of double[2][n], so I did not see a simpler approach.

}
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
Loading