Fix changing locale. (#5314)

* Fix changing locale.

* Don't use locale guard.

As number parsing is implemented in house, we don't need locale.

* Update doc.
This commit is contained in:
Jiaming Yuan
2020-02-17 11:31:13 +08:00
committed by fis
parent 69fc8a632f
commit 088c43d666
3 changed files with 7 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ import os
import json
import testing as tm
import pytest
import locale
dpath = 'demo/data/'
dtrain = xgb.DMatrix(dpath + 'agaricus.txt.train')
@@ -300,6 +301,7 @@ class TestModels(unittest.TestCase):
'reg_loss_param']['scale_pos_weight']) == 0.5
def test_model_json_io(self):
loc = locale.getpreferredencoding(False)
model_path = 'test_model_json_io.json'
parameters = {'tree_method': 'hist', 'booster': 'gbtree'}
j_model = json_model(model_path, parameters)
@@ -313,6 +315,7 @@ class TestModels(unittest.TestCase):
assert isinstance(j_model['learner'], dict)
os.remove(model_path)
assert locale.getpreferredencoding(False) == loc
@pytest.mark.skipif(**tm.no_json_schema())
def test_json_schema(self):