Revert "Disable JSON full serialization for now. (#6248)" (#6266)

This reverts commit 6d293020fb.
This commit is contained in:
Jiaming Yuan
2020-10-27 03:30:47 +08:00
committed by GitHub
parent d61b628bf5
commit bcfab4d726
4 changed files with 17 additions and 52 deletions

View File

@@ -175,16 +175,16 @@ test_that("cb.reset.parameters works as expected", {
})
test_that("cb.save.model works as expected", {
files <- c('xgboost_01.bin', 'xgboost_02.bin', 'xgboost.bin')
files <- c('xgboost_01.json', 'xgboost_02.json', 'xgboost.json')
for (f in files) if (file.exists(f)) file.remove(f)
bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0,
save_period = 1, save_name = "xgboost_%02d.bin")
expect_true(file.exists('xgboost_01.bin'))
expect_true(file.exists('xgboost_02.bin'))
b1 <- xgb.load('xgboost_01.bin')
save_period = 1, save_name = "xgboost_%02d.json")
expect_true(file.exists('xgboost_01.json'))
expect_true(file.exists('xgboost_02.json'))
b1 <- xgb.load('xgboost_01.json')
expect_equal(xgb.ntree(b1), 1)
b2 <- xgb.load('xgboost_02.bin')
b2 <- xgb.load('xgboost_02.json')
expect_equal(xgb.ntree(b2), 2)
xgb.config(b2) <- xgb.config(bst)
@@ -193,9 +193,9 @@ test_that("cb.save.model works as expected", {
# save_period = 0 saves the last iteration's model
bst <- xgb.train(param, dtrain, nrounds = 2, watchlist, eta = 1, verbose = 0,
save_period = 0, save_name = 'xgboost.bin')
expect_true(file.exists('xgboost.bin'))
b2 <- xgb.load('xgboost.bin')
save_period = 0, save_name = 'xgboost.json')
expect_true(file.exists('xgboost.json'))
b2 <- xgb.load('xgboost.json')
xgb.config(b2) <- xgb.config(bst)
expect_equal(bst$raw, b2$raw)