| 407 | } |
| 408 | |
| 409 | auto MakeSimpleDMatrixForTest(bst_idx_t n_samples, bst_feature_t n_features, Json dconfig) { |
| 410 | HostDeviceVector<float> storage; |
| 411 | auto arr_int = RandomDataGenerator{n_samples, n_features, 0.5f}.GenerateArrayInterface(&storage); |
| 412 | |
| 413 | data::ArrayAdapter adapter{StringView{arr_int}}; |
| 414 | std::shared_ptr<DMatrix> Xy{ |
| 415 | DMatrix::Create(&adapter, std::numeric_limits<float>::quiet_NaN(), Context{}.Threads())}; |
| 416 | |
| 417 | DMatrixHandle p_fmat; |
| 418 | std::string s_dconfig; |
| 419 | Json::Dump(dconfig, &s_dconfig); |
| 420 | CHECK_EQ(XGDMatrixCreateFromDense(arr_int.c_str(), s_dconfig.c_str(), &p_fmat), 0); |
| 421 | |
| 422 | MakeLabelForTest(Xy, p_fmat); |
| 423 | return std::pair{p_fmat, Xy}; |
| 424 | } |
| 425 | |
| 426 | auto MakeQDMForTest(Context const *ctx, bst_idx_t n_samples, bst_feature_t n_features, |
| 427 | Json dconfig) { |
no test coverage detected