Relax shotgun test. (#6918)

This commit is contained in:
Jiaming Yuan 2021-04-30 09:03:12 +08:00 committed by GitHub
parent 34df1f588b
commit 45ddc39c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,15 +57,13 @@ class TestLinear:
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),