Skip to content

Commit

Permalink
Convert objects to data.table in fwrite to avoid failure in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kemihak committed Feb 22, 2024
1 parent 21345c0 commit f7bb3df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions R/createCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ createClusterRES <- function(area,
)
}

#' @importFrom data.table fwrite
#' @importFrom data.table fwrite as.data.table
.createCluster <- function(area,
cluster_name,
...,
Expand Down Expand Up @@ -403,7 +403,7 @@ createClusterRES <- function(area,
}

fwrite(
x = time_series, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(time_series), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "series", area, lower_cluster_name, "series.txt")
)

Expand All @@ -418,7 +418,7 @@ createClusterRES <- function(area,
if (is.null(prepro_data))
prepro_data <- matrix(data = c(rep(1, times = 365 * 2), rep(0, times = 365 * 4)), ncol = 6)
fwrite(
x = prepro_data, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(prepro_data), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "prepro", area, lower_cluster_name, "data.txt")
)

Expand All @@ -427,7 +427,7 @@ createClusterRES <- function(area,
prepro_modulation <- matrix(data = c(rep(1, times = 365 * 24 * 3), rep(0, times = 365 * 24 * 1)), ncol = 4)

fwrite(
x = prepro_modulation, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(prepro_modulation), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "prepro", area, lower_cluster_name, "modulation.txt")
)
}
Expand Down
8 changes: 4 additions & 4 deletions R/editCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ editClusterRES <- function(area,
)
}

#' @importFrom data.table fwrite
#' @importFrom data.table fwrite as.data.table
.editCluster <- function(area,
cluster_name,
...,
Expand Down Expand Up @@ -241,21 +241,21 @@ editClusterRES <- function(area,

if (!is.null(time_series)) {
fwrite(
x = time_series, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(time_series), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "series", area, lower_cluster_name, "series.txt")
)
}

if (!is.null(prepro_data)) {
fwrite(
x = prepro_data, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(prepro_data), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "prepro", area, lower_cluster_name, "data.txt")
)
}

if (!is.null(prepro_modulation)) {
fwrite(
x = prepro_modulation, row.names = FALSE, col.names = FALSE, sep = "\t",
x = as.data.table(prepro_modulation), row.names = FALSE, col.names = FALSE, sep = "\t",
file = file.path(inputPath, cluster_type, "prepro", area, lower_cluster_name, "modulation.txt")
)
}
Expand Down

0 comments on commit f7bb3df

Please sign in to comment.