Skip to content

Commit

Permalink
feat: check if colnames are duplicated in R
Browse files Browse the repository at this point in the history
  • Loading branch information
bbayukari committed Oct 1, 2023
1 parent 87dfe95 commit d603be3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R-package/R/initialization.R
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ x_matrix_info.Initialization <- function(para, data) {
if (is.null(para$vn)) {
para$vn <- paste0("x", 1:para$nvars)
}

# If the colnames are duplicated, a error should be raised
if (length(unique(para$vn)) != length(para$vn)) {
stop("The colnames of x are duplicated!")

Check warning on line 350 in R-package/R/initialization.R

View check run for this annotation

Codecov / codecov/patch

R-package/R/initialization.R#L350

Added line #L350 was not covered by tests
}
para
}

Expand Down Expand Up @@ -478,6 +481,10 @@ y_matrix.glm <- function(para, data) {
if (is.null(para$y_vn)) {
para$y_vn <- colnames("y", 1:dim(data$y)[2])
}
# If the colnames are duplicated, a error should be raised
if (length(unique(para$y_vn)) != length(para$y_vn)) {
stop("The colnames of y are duplicated!")

Check warning on line 486 in R-package/R/initialization.R

View check run for this annotation

Codecov / codecov/patch

R-package/R/initialization.R#L486

Added line #L486 was not covered by tests
}
}
data$y <- as.matrix(data$y)
para$y_dim <- ncol(data$y)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
precision=pre)
data = np.concatenate((data0, data1))
train_data, test_data, train_labels, test_labels = train_test_split(data, labels, test_size=0.33, random_state=0)
mean = FrechetMean(metric=sphere.metric)
mean = FrechetMean(sphere)
mean.fit(train_data)
mean_estimate = mean.estimate_
log_train_data = sphere.metric.log(train_data, mean_estimate)
Expand Down

0 comments on commit d603be3

Please sign in to comment.