Skip to content

Commit 830ed78

Browse files
Copilottomasfryda
andauthored
Fix non-deterministic test data in GLMPredMojoControlVariablesTest (#16771)
* Initial plan * Use fixed seed and remove println in GLMPredMojoControlVariablesTest Co-authored-by: tomasfryda <61695433+tomasfryda@users.noreply.github.com> * Change SEED constant to 0x1CEDC0FFEEL Co-authored-by: tomasfryda <61695433+tomasfryda@users.noreply.github.com> * Change SEED to 0x1CEDCAFE (no L suffix needed) Co-authored-by: tomasfryda <61695433+tomasfryda@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tomasfryda <61695433+tomasfryda@users.noreply.github.com>
1 parent 31466fc commit 830ed78

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

h2o-algos/src/test/java/hex/glm/GLMPredMojoControlVariablesTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
public class GLMPredMojoControlVariablesTest extends TestUtil {
2929

3030
double _tol = 1e-6;
31+
private static final long SEED = 0x1CEDCAFE;
3132

3233
@Test
3334
public void testGaussianPredMojoControlVariables() {
@@ -212,7 +213,7 @@ public void testBinomialWithValidationFramePredMojoControlVariables() {
212213
private Frame[] createAndSplitData(int responseFactors, boolean positiveResponse,
213214
boolean convertResponseToNumeric, String suffix) {
214215
CreateFrame cf = new CreateFrame();
215-
Random generator = new Random();
216+
Random generator = new Random(SEED);
216217
int numRows = generator.nextInt(10000) + 15000 + 200;
217218
int numCols = generator.nextInt(17) + 3;
218219
cf.rows = numRows;
@@ -222,9 +223,7 @@ private Frame[] createAndSplitData(int responseFactors, boolean positiveResponse
222223
cf.response_factors = responseFactors;
223224
cf.positive_response = positiveResponse;
224225
cf.missing_fraction = 0;
225-
cf.seed = System.currentTimeMillis();
226-
System.out.println("Createframe parameters: rows: " + numRows + " cols:" + numCols +
227-
" seed: " + cf.seed + " family: " + suffix);
226+
cf.seed = SEED;
228227

229228
Frame trainData = cf.execImpl().get();
230229
if (convertResponseToNumeric) {
@@ -252,7 +251,7 @@ private Frame[] createAndSplitData(int responseFactors, boolean positiveResponse
252251
private Frame[] createAndSplitData3Way(int responseFactors, boolean positiveResponse,
253252
boolean convertResponseToNumeric, String suffix) {
254253
CreateFrame cf = new CreateFrame();
255-
Random generator = new Random();
254+
Random generator = new Random(SEED);
256255
int numRows = generator.nextInt(10000) + 15000 + 200;
257256
int numCols = generator.nextInt(17) + 3;
258257
cf.rows = numRows;
@@ -262,9 +261,7 @@ private Frame[] createAndSplitData3Way(int responseFactors, boolean positiveResp
262261
cf.response_factors = responseFactors;
263262
cf.positive_response = positiveResponse;
264263
cf.missing_fraction = 0;
265-
cf.seed = System.currentTimeMillis();
266-
System.out.println("Createframe parameters: rows: " + numRows + " cols:" + numCols +
267-
" seed: " + cf.seed + " family: " + suffix);
264+
cf.seed = SEED;
268265

269266
Frame trainData = cf.execImpl().get();
270267
if (convertResponseToNumeric) {

0 commit comments

Comments
 (0)