4#ifndef XGBOOST_TEST_JSON_IO_H_
5#define XGBOOST_TEST_JSON_IO_H_
7#include <xgboost/linear_updater.h>
8#include <xgboost/json.h>
10#include "../helpers.h"
11#include "../../../src/gbm/gblinear_model.h"
14inline void TestUpdaterJsonIO(std::string updater_str) {
16 Json config_0 {Object() };
21 updater->Configure({{
"eta", std::to_string(3.14)}});
22 updater->SaveConfig(&config_0);
28 updater->LoadConfig(config_0);
29 Json config_1 { Object() };
30 updater->SaveConfig(&config_1);
32 ASSERT_EQ(config_0, config_1);
33 auto eta =
atof(get<String const>(config_1[
"linear_train_param"][
"eta"]).
c_str());
34 ASSERT_NEAR(eta, 3.14,
kRtEps);
static LinearUpdater * Create(const std::string &name, Context const *)
Create a linear updater given name.
Definition linear_updater.cc:14
float atof(const char *nptr)
A faster implementation of atof(). Unlike std::atof(), this function returns float type....
Definition strtonum.h:448
c_str(string)
Definition basic.py:110
namespace of xgboost
Definition base.h:90
Context MakeCUDACtx(std::int32_t device)
Make a context that uses CUDA if device >= 0.
Definition helpers.h:410
constexpr bst_float kRtEps
small eps gap for minimum split decision.
Definition base.h:319