Add global configuration (#6414)
* Add management functions for global configuration: XGBSetGlobalConfig(), XGBGetGlobalConfig(). * Add Python interface: set_config(), get_config(), and config_context(). * Add unit tests for Python * Add R interface: xgb.set.config(), xgb.get.config() * Add unit tests for R Co-authored-by: Jiaming Yuan <jm.yuan@outlook.com>
This commit is contained in:
committed by
GitHub
parent
c2ba4fb957
commit
fb56da5e8b
16
tests/python/test_config.py
Normal file
16
tests/python/test_config.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import xgboost as xgb
|
||||
import pytest
|
||||
import testing as tm
|
||||
|
||||
|
||||
@pytest.mark.parametrize('verbosity_level', [0, 1, 2, 3])
|
||||
def test_global_config_verbosity(verbosity_level):
|
||||
def get_current_verbosity():
|
||||
return xgb.get_config()['verbosity']
|
||||
|
||||
old_verbosity = get_current_verbosity()
|
||||
with xgb.config_context(verbosity=verbosity_level):
|
||||
new_verbosity = get_current_verbosity()
|
||||
assert new_verbosity == verbosity_level
|
||||
assert old_verbosity == get_current_verbosity()
|
||||
Reference in New Issue
Block a user