Skip to content

Commit

Permalink
fix foreach warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Feb 22, 2024
1 parent 381826b commit a5b7291
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ Suggests:
LinkingTo:
RcppArmadillo,
Rcpp
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export(vic_params)
export(vic_version)
import(magrittr)
importFrom(Rcpp,sourceCpp)
importFrom(foreach,"%do%")
importFrom(foreach,foreach)
importFrom(lubridate,day)
importFrom(lubridate,month)
importFrom(lubridate,year)
Expand Down
9 changes: 9 additions & 0 deletions R/VIC5-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @docType package
#' @importFrom Rcpp sourceCpp
#' @importFrom stats setNames convolve median
#' @importFrom foreach %do% foreach
#' @importFrom utils str read.table
#' @keywords internal
"_PACKAGE"
Expand All @@ -13,3 +14,11 @@
## usethis namespace: start
## usethis namespace: end
NULL

.onLoad <- function (libname, pkgname){
if(getRversion() >= "2.15.1") {
utils::globalVariables(
c(".", "i", "frocing")
)
}
}
2 changes: 1 addition & 1 deletion R/tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set_dimnames <- function(x, value) {

check_matrix <- function(x) {
if (is.vector(x)) {
lake %<>% t()
x %<>% t()
} else if (!is.null(x)) {
x %<>% as.matrix()
}
Expand Down
4 changes: 2 additions & 2 deletions R/vic_forcing.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ check_forcing <- function(forcing, soil = NULL) {
ngrid = ncol(forcing[[1]])
# Estimate forcing data that not supplied.
if ("PRESS" %in% forc_lack) {
forcing$PRESS = foreach(i = 1:ngrid, icount(), .c = cbind) %do% {
forcing$PRESS = foreach(i = 1:ngrid, .c = cbind) %do% {
cal_Pa(frocing$TEMP[, i], elev = soil[, "ELEV"])
}
}

if ("LW" %in% forc_lack) {
J <- get_J()
forcing$LW = foreach(i = 1:ngrid, icount(), .c = cbind) %do% {
forcing$LW = foreach(i = 1:ngrid, .c = cbind) %do% {
lat = soil[i, "LAT"]
cal_lw(forcing$TEMP[, i], forcing$VP[, i], forcing$SW[, i], lat, J)
}
Expand Down
2 changes: 1 addition & 1 deletion man/VIC5.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a5b7291

Please sign in to comment.