Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
b6db7e23
Commit
b6db7e23
authored
Mar 04, 2018
by
Rand Xie
Committed by
Guolin Ke
Mar 04, 2018
Browse files
[R] Use NA_real_ to initialize handle (#1255)
parent
98c6efe3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
R-package/R/lgb.Dataset.R
R-package/R/lgb.Dataset.R
+1
-1
R-package/R/utils.R
R-package/R/utils.R
+1
-1
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+16
-0
No files found.
R-package/R/lgb.Dataset.R
View file @
b6db7e23
...
...
@@ -167,7 +167,7 @@ Dataset <- R6Class(
if
(
!
is.null
(
private
$
reference
))
{
ref_handle
<-
private
$
reference
$
.__enclos_env__
$
private
$
get_handle
()
}
handle
<-
0.0
handle
<-
NA_real_
# Not subsetting
if
(
is.null
(
private
$
used_indices
))
{
...
...
R-package/R/utils.R
View file @
b6db7e23
...
...
@@ -7,7 +7,7 @@ lgb.is.Dataset <- function(x) {
}
lgb.is.null.handle
<-
function
(
x
)
{
is.null
(
x
)
||
x
==
0.0
is.null
(
x
)
||
is.na
(
x
)
}
lgb.encode.char
<-
function
(
arr
,
len
)
{
...
...
R-package/tests/testthat/test_dataset.R
View file @
b6db7e23
...
...
@@ -26,6 +26,8 @@ test_that("lgb.Dataset: basic construction, saving, loading", {
test_that
(
"lgb.Dataset: getinfo & setinfo"
,
{
dtest
<-
lgb.Dataset
(
test_data
)
dtest
$
construct
()
setinfo
(
dtest
,
'label'
,
test_label
)
labels
<-
getinfo
(
dtest
,
'label'
)
expect_equal
(
test_label
,
getinfo
(
dtest
,
'label'
))
...
...
@@ -66,3 +68,17 @@ test_that("lgb.Dataset: nrow is correct for a very sparse matrix", {
dtest
<-
lgb.Dataset
(
x
)
expect_equal
(
dim
(
dtest
),
dim
(
x
))
})
test_that
(
"lgb.Dataset: Dataset should be able to construct from matrix and return non-null handle"
,
{
rawData
<-
matrix
(
runif
(
1000
),
ncol
=
10
)
handle
<-
NA_real_
ref_handle
<-
NULL
handle
<-
lightgbm
:::
lgb.call
(
"LGBM_DatasetCreateFromMat_R"
,
ret
=
handle
,
rawData
,
nrow
(
rawData
)
,
ncol
(
rawData
)
,
lightgbm
:::
lgb.params2str
(
params
=
list
())
,
ref_handle
)
expect_false
(
is.na
(
handle
))
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment