Skip to content

Commit

Permalink
Relax shotgun test. (dmlc#6918)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed May 3, 2021
1 parent 6d6230d commit 6e0ee55
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/python/test_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ def test_shotgun(self, param, num_rounds, dataset):
param['updater'] = 'shotgun'
param = dataset.set_params(param)
result = train_result(param, dataset.get_dmat(), num_rounds)['train'][dataset.metric]
# shotgun is non-deterministic, so we relax the test by sampling
# result.
# shotgun is non-deterministic, so we relax the test by only using first and last
# iteration.
if len(result) > 2:
sampled_result = [score for i, score in enumerate(result)
if i % 4 == 0]
sampled_result[-1] = result[-1] # make sure the last one is used
sampled_result = (result[0], result[-1])
else:
sampled_result = result
assert tm.non_increasing(sampled_result, 1e-3)
assert tm.non_increasing(sampled_result)

@given(parameter_strategy, strategies.integers(10, 50),
tm.dataset_strategy, strategies.floats(1e-5, 2.0),
Expand Down

0 comments on commit 6e0ee55

Please sign in to comment.