Relax test for shotgun. (#5835)

This commit is contained in:
Jiaming Yuan 2020-07-01 19:20:29 +08:00 committed by GitHub
parent 90a9c68874
commit eb067c1c34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,7 +57,15 @@ class TestLinear:
param['updater'] = 'shotgun' param['updater'] = 'shotgun'
param = dataset.set_params(param) param = dataset.set_params(param)
result = train_result(param, dataset.get_dmat(), num_rounds)['train'][dataset.metric] result = train_result(param, dataset.get_dmat(), num_rounds)['train'][dataset.metric]
assert tm.non_increasing(result) # shotgun is non-deterministic, so we relax the test by sampling
# result.
if len(result) > 2:
sampled_result = [score for i, score in enumerate(result)
if i % 2 == 0]
sampled_result[-1] = result[-1] # make sure the last one is used
else:
sampled_result = result
assert tm.non_increasing(sampled_result)
@given(parameter_strategy, strategies.integers(10, 50), @given(parameter_strategy, strategies.integers(10, 50),
tm.dataset_strategy, strategies.floats(1e-5, 2.0), tm.dataset_strategy, strategies.floats(1e-5, 2.0),