Support 32-bit Solaris target for R package
This commit is contained in:
parent
3550b16a34
commit
d83db4844b
@ -7,8 +7,8 @@ require(vcd, quietly = TRUE)
|
|||||||
|
|
||||||
float_tolerance = 5e-6
|
float_tolerance = 5e-6
|
||||||
|
|
||||||
# disable some tests for Win32
|
# disable some tests for 32-bit environment
|
||||||
win32_flag = .Platform$OS.type == "windows" && .Machine$sizeof.pointer != 8
|
flag_32bit = .Machine$sizeof.pointer != 8
|
||||||
|
|
||||||
set.seed(1982)
|
set.seed(1982)
|
||||||
data(Arthritis)
|
data(Arthritis)
|
||||||
@ -44,7 +44,7 @@ mbst.GLM <- xgboost(data = as.matrix(iris[, -5]), label = mlabel, verbose = 0,
|
|||||||
|
|
||||||
|
|
||||||
test_that("xgb.dump works", {
|
test_that("xgb.dump works", {
|
||||||
if (!win32_flag)
|
if (!flag_32bit)
|
||||||
expect_length(xgb.dump(bst.Tree), 200)
|
expect_length(xgb.dump(bst.Tree), 200)
|
||||||
dump_file = file.path(tempdir(), 'xgb.model.dump')
|
dump_file = file.path(tempdir(), 'xgb.model.dump')
|
||||||
expect_true(xgb.dump(bst.Tree, dump_file, with_stats = T))
|
expect_true(xgb.dump(bst.Tree, dump_file, with_stats = T))
|
||||||
@ -54,7 +54,7 @@ test_that("xgb.dump works", {
|
|||||||
# JSON format
|
# JSON format
|
||||||
dmp <- xgb.dump(bst.Tree, dump_format = "json")
|
dmp <- xgb.dump(bst.Tree, dump_format = "json")
|
||||||
expect_length(dmp, 1)
|
expect_length(dmp, 1)
|
||||||
if (!win32_flag)
|
if (!flag_32bit)
|
||||||
expect_length(grep('nodeid', strsplit(dmp, '\n')[[1]]), 188)
|
expect_length(grep('nodeid', strsplit(dmp, '\n')[[1]]), 188)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ test_that("xgb.model.dt.tree works with and without feature names", {
|
|||||||
names.dt.trees <- c("Tree", "Node", "ID", "Feature", "Split", "Yes", "No", "Missing", "Quality", "Cover")
|
names.dt.trees <- c("Tree", "Node", "ID", "Feature", "Split", "Yes", "No", "Missing", "Quality", "Cover")
|
||||||
dt.tree <- xgb.model.dt.tree(feature_names = feature.names, model = bst.Tree)
|
dt.tree <- xgb.model.dt.tree(feature_names = feature.names, model = bst.Tree)
|
||||||
expect_equal(names.dt.trees, names(dt.tree))
|
expect_equal(names.dt.trees, names(dt.tree))
|
||||||
if (!win32_flag)
|
if (!flag_32bit)
|
||||||
expect_equal(dim(dt.tree), c(188, 10))
|
expect_equal(dim(dt.tree), c(188, 10))
|
||||||
expect_output(str(dt.tree), 'Feature.*\\"Age\\"')
|
expect_output(str(dt.tree), 'Feature.*\\"Age\\"')
|
||||||
|
|
||||||
@ -283,7 +283,7 @@ test_that("xgb.model.dt.tree throws error for gblinear", {
|
|||||||
|
|
||||||
test_that("xgb.importance works with and without feature names", {
|
test_that("xgb.importance works with and without feature names", {
|
||||||
importance.Tree <- xgb.importance(feature_names = feature.names, model = bst.Tree)
|
importance.Tree <- xgb.importance(feature_names = feature.names, model = bst.Tree)
|
||||||
if (!win32_flag)
|
if (!flag_32bit)
|
||||||
expect_equal(dim(importance.Tree), c(7, 4))
|
expect_equal(dim(importance.Tree), c(7, 4))
|
||||||
expect_equal(colnames(importance.Tree), c("Feature", "Gain", "Cover", "Frequency"))
|
expect_equal(colnames(importance.Tree), c("Feature", "Gain", "Cover", "Frequency"))
|
||||||
expect_output(str(importance.Tree), 'Feature.*\\"Age\\"')
|
expect_output(str(importance.Tree), 'Feature.*\\"Age\\"')
|
||||||
|
|||||||
@ -117,14 +117,16 @@ std::string LoadSequentialFile(std::string fname) {
|
|||||||
size_t f_size_bytes = fs.st_size;
|
size_t f_size_bytes = fs.st_size;
|
||||||
buffer.resize(f_size_bytes + 1);
|
buffer.resize(f_size_bytes + 1);
|
||||||
int32_t fd = open(fname.c_str(), O_RDONLY);
|
int32_t fd = open(fname.c_str(), O_RDONLY);
|
||||||
|
#if defined(__linux__)
|
||||||
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||||
|
#endif // defined(__linux__)
|
||||||
ssize_t bytes_read = read(fd, &buffer[0], f_size_bytes);
|
ssize_t bytes_read = read(fd, &buffer[0], f_size_bytes);
|
||||||
if (bytes_read < 0) {
|
if (bytes_read < 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
ReadErr();
|
ReadErr();
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
#else
|
#else // defined(__unix__)
|
||||||
FILE *f = fopen(fname.c_str(), "r");
|
FILE *f = fopen(fname.c_str(), "r");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
std::string msg;
|
std::string msg;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user