Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package] remove unnecessary comments and fix typos in comments #4902

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions R-package/R/lgb.Dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ Dataset <- R6::R6Class(
if (length(private$raw_data@p) > 2147483647L) {
stop("Cannot support large CSC matrix")
}
# Are we using a dgCMatrix (sparsed matrix column compressed)
# Are we using a dgCMatrix (sparse matrix column compressed)
handle <- .Call(
LGBM_DatasetCreateFromCSC_R
, private$raw_data@p
Expand Down Expand Up @@ -462,15 +462,14 @@ Dataset <- R6::R6Class(
, info_len
)

# Check if info is not empty
if (info_len > 0L) {

# Get back fields
ret <- NULL
ret <- if (field_name == "group") {
integer(info_len) # Integer
integer(info_len)
} else {
numeric(info_len) # Numeric
numeric(info_len)
}

.Call(
Expand Down Expand Up @@ -501,9 +500,9 @@ Dataset <- R6::R6Class(

# Check for type of information
data <- if (field_name == "group") {
as.integer(data) # Integer
as.integer(data)
} else {
as.numeric(data) # Numeric
as.numeric(data)
}

# Store information privately
Expand Down Expand Up @@ -531,10 +530,8 @@ Dataset <- R6::R6Class(

},

# Slice dataset
slice = function(idxset) {

# Perform slicing
return(
Dataset$new(
data = NULL
Expand Down Expand Up @@ -617,7 +614,6 @@ Dataset <- R6::R6Class(

},

# Set reference
set_reference = function(reference) {

# setting reference to this same Dataset object doesn't require any changes
Expand Down Expand Up @@ -677,7 +673,6 @@ Dataset <- R6::R6Class(
info = NULL,
version = 0L,

# Get handle
get_handle = function() {

# Get handle and construct if needed
Expand All @@ -688,7 +683,6 @@ Dataset <- R6::R6Class(

},

# Set predictor
set_predictor = function(predictor) {

if (identical(private$predictor, predictor)) {
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/lgb.cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ lgb.stratified.folds <- function(y, k) {

## Create a vector of integers from 1:k as many times as possible without
## going over the number of samples in the class. Note that if the number
## of samples in a class is less than k, nothing is producd here.
## of samples in a class is less than k, nothing is produced here.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of my curiosity, why double ## here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason at all! According to the git blame, these lines were added 5 years ago

https://github.com/microsoft/LightGBM/blame/0df38106b48161e12204de5621e406cc6c19a3e6/R-package/R/lgb.cv.R#L512-L519

I'd support a PR changing them (and other instances like this) to a single #

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it! 🙂

seqVector <- rep(seq_len(k), numInClass[i] %/% k)

## Add enough random integers to get length(seqVector) == numInClass[i]
Expand Down
2 changes: 1 addition & 1 deletion R-package/R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ lgb.check.wrapper_param <- function(main_param_name, params, alternative_kwarg_v
return(params)
}

# if the main parameter wasn't proovided, prefer the first alias
# if the main parameter wasn't provided, prefer the first alias
if (length(aliases_provided) > 0L) {
first_param <- aliases_provided[1L]
params[[main_param_name]] <- params[[first_param]]
Expand Down