Refactor tests with data generator. (#5439)
This commit is contained in:
@@ -68,8 +68,7 @@ TEST(Adapter, CSCAdapterColsMoreThanRows) {
|
||||
}
|
||||
|
||||
TEST(c_api, DMatrixSliceAdapterFromSimpleDMatrix) {
|
||||
auto pp_dmat = CreateDMatrix(6, 2, 1.0);
|
||||
auto p_dmat = *pp_dmat;
|
||||
auto p_dmat = RandomDataGenerator(6, 2, 1.0).GenerateDMatix();
|
||||
|
||||
std::vector<int> ridx_set = {1, 3, 5};
|
||||
data::DMatrixSliceAdapter adapter(p_dmat.get(),
|
||||
@@ -91,8 +90,6 @@ TEST(c_api, DMatrixSliceAdapterFromSimpleDMatrix) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete pp_dmat;
|
||||
}
|
||||
|
||||
// A mock for JVM data iterator.
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace xgboost {
|
||||
TEST(EllpackPage, EmptyDMatrix) {
|
||||
constexpr int kNRows = 0, kNCols = 0, kMaxBin = 256;
|
||||
constexpr float kSparsity = 0;
|
||||
auto dmat = *CreateDMatrix(kNRows, kNCols, kSparsity);
|
||||
auto dmat = RandomDataGenerator(kNRows, kNCols, kSparsity).GenerateDMatix();
|
||||
auto& page = *dmat->GetBatches<EllpackPage>({0, kMaxBin}).begin();
|
||||
auto impl = page.Impl();
|
||||
ASSERT_EQ(impl->row_stride, 0);
|
||||
|
||||
@@ -220,8 +220,7 @@ TEST(SimpleDMatrix, FromFile) {
|
||||
TEST(SimpleDMatrix, Slice) {
|
||||
const int kRows = 6;
|
||||
const int kCols = 2;
|
||||
auto pp_dmat = CreateDMatrix(kRows, kCols, 1.0);
|
||||
auto p_dmat = *pp_dmat;
|
||||
auto p_dmat = RandomDataGenerator(kRows, kCols, 1.0).GenerateDMatix();
|
||||
auto &labels = p_dmat->Info().labels_.HostVector();
|
||||
auto &weights = p_dmat->Info().weights_.HostVector();
|
||||
auto &base_margin = p_dmat->Info().base_margin_.HostVector();
|
||||
@@ -257,8 +256,6 @@ TEST(SimpleDMatrix, Slice) {
|
||||
EXPECT_EQ(old_inst[j], new_inst[j]);
|
||||
}
|
||||
}
|
||||
|
||||
delete pp_dmat;
|
||||
};
|
||||
|
||||
TEST(SimpleDMatrix, SaveLoadBinary) {
|
||||
|
||||
Reference in New Issue
Block a user