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
f5925c3f
Unverified
Commit
f5925c3f
authored
Aug 25, 2021
by
James Lamb
Committed by
GitHub
Aug 25, 2021
Browse files
[R-package] remove unused code checking has_header in Dataset() (fixes #4553) (#4554)
parent
bd28a364
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
10 deletions
+42
-10
R-package/R/lgb.Dataset.R
R-package/R/lgb.Dataset.R
+0
-10
R-package/tests/testthat/test_dataset.R
R-package/tests/testthat/test_dataset.R
+42
-0
No files found.
R-package/R/lgb.Dataset.R
View file @
f5925c3f
...
@@ -171,16 +171,6 @@ Dataset <- R6::R6Class(
...
@@ -171,16 +171,6 @@ Dataset <- R6::R6Class(
}
}
# Check has header or not
has_header
<-
FALSE
if
(
!
is.null
(
private
$
params
$
has_header
)
||
!
is.null
(
private
$
params
$
header
))
{
params_has_header
<-
tolower
(
as.character
(
private
$
params
$
has_header
))
==
"true"
params_header
<-
tolower
(
as.character
(
private
$
params
$
header
))
==
"true"
if
(
params_has_header
||
params_header
)
{
has_header
<-
TRUE
}
}
# Generate parameter str
# Generate parameter str
params_str
<-
lgb.params2str
(
params
=
private
$
params
)
params_str
<-
lgb.params2str
(
params
=
private
$
params
)
...
...
R-package/tests/testthat/test_dataset.R
View file @
f5925c3f
...
@@ -310,3 +310,45 @@ test_that("lgb.Dataset: should be able to use and retrieve long feature names",
...
@@ -310,3 +310,45 @@ test_that("lgb.Dataset: should be able to use and retrieve long feature names",
expect_equal
(
col_names
[
1L
],
long_name
)
expect_equal
(
col_names
[
1L
],
long_name
)
expect_equal
(
nchar
(
col_names
[
1L
]),
1000L
)
expect_equal
(
nchar
(
col_names
[
1L
]),
1000L
)
})
})
test_that
(
"lgb.Dataset: should be able to create a Dataset from a text file with a header"
,
{
train_file
<-
tempfile
(
pattern
=
"train_"
,
fileext
=
".csv"
)
write.table
(
data.frame
(
y
=
rnorm
(
100L
),
x1
=
rnorm
(
100L
),
x2
=
rnorm
(
100L
))
,
file
=
train_file
,
sep
=
","
,
col.names
=
TRUE
,
row.names
=
FALSE
,
quote
=
FALSE
)
dtrain
<-
lgb.Dataset
(
data
=
train_file
,
params
=
list
(
header
=
TRUE
)
)
dtrain
$
construct
()
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"x1"
,
"x2"
))
expect_identical
(
dtrain
$
get_params
(),
list
(
header
=
TRUE
))
expect_identical
(
dtrain
$
dim
(),
c
(
100L
,
2L
))
})
test_that
(
"lgb.Dataset: should be able to create a Dataset from a text file without a header"
,
{
train_file
<-
tempfile
(
pattern
=
"train_"
,
fileext
=
".csv"
)
write.table
(
data.frame
(
y
=
rnorm
(
100L
),
x1
=
rnorm
(
100L
),
x2
=
rnorm
(
100L
))
,
file
=
train_file
,
sep
=
","
,
col.names
=
FALSE
,
row.names
=
FALSE
,
quote
=
FALSE
)
dtrain
<-
lgb.Dataset
(
data
=
train_file
,
params
=
list
(
header
=
FALSE
)
)
dtrain
$
construct
()
expect_identical
(
dtrain
$
get_colnames
(),
c
(
"Column_0"
,
"Column_1"
))
expect_identical
(
dtrain
$
get_params
(),
list
(
header
=
FALSE
))
expect_identical
(
dtrain
$
dim
(),
c
(
100L
,
2L
))
})
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