Skip to content

Commit

Permalink
removed getwd() from default arg values in functions, man update
Browse files Browse the repository at this point in the history
  • Loading branch information
plecharpent committed Jul 7, 2023
1 parent 29c9790 commit f14eae8
Show file tree
Hide file tree
Showing 24 changed files with 65 additions and 74 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Description: Manipulating input and output files of the 'STICS' crop
or writing parameter names and values in both XML or text input files,
and getting data from output files. Advanced functionalities include
XML files generation from XML templates and/or spreadsheets, or text
files generation from XML files by using xslt transformation.
files generation from XML files by using 'xslt' transformation.
License: LGPL (>= 3)
URL: https://github.com/SticsRPacks/SticsRFiles,
https://doi.org/10.5281/zenodo.4443206
Expand Down
4 changes: 2 additions & 2 deletions R/gen_ini_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
#'
#' @export
#'
gen_ini_xml <- function(param_df = NULL,
gen_ini_xml <- function(param_df,
file = NULL,
out_dir = getwd(),
out_dir,
crop_tag = "Crop",
stics_version = "latest",
ini_in_file = lifecycle::deprecated(),
Expand Down
37 changes: 22 additions & 15 deletions R/gen_new_travail.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,25 @@

gen_new_travail <- function(workspace,
usm,
lai_forcing = 0,
codesuite = 0,
codoptim = 0,
out_dir = getwd()) {
lai_forcing = NULL,
codesuite = NULL,
codoptim = NULL,
out_dir = NULL) {

usm_data <- get_usm_data(workspace,
usm,
lai_forcing = 0,
codesuite = 0,
codoptim = 0)
lai_forcing = lai_forcing,
codesuite = codesuite,
codoptim = codoptim)

data_order <- c("codesimul", "codoptim", "codesuite", "nbplantes", "nom",
"datedebut", "datefin", "finit", "numsol", "nomsol",
"fstation",
"fclim1", "fclim2", "nbans", "culturean", "fplt1",
"ftec1", "flai1", "fplt2", "ftec2", "flai2")

if (is.null(out_dir)) out_dir <- workspace

out_file <- file.path(out_dir, "new_travail.usm")

p_table <- vector(mode = "character", length = 2 * length(data_order))
Expand All @@ -54,9 +56,9 @@ gen_new_travail <- function(workspace,

get_usm_data <- function(workspace,
usm,
lai_forcing = 0,
codesuite = 0,
codoptim = 0) {
lai_forcing = NULL,
codesuite = NULL,
codoptim = NULL) {

data <- list()

Expand All @@ -65,13 +67,18 @@ get_usm_data <- function(workspace,
usm, select = "usm",
select_value = usm)$usms.xml

# codesimul
# forcing codesimul
# 0: culture, 1: feuille, lai forcing
data$codesimul <- get_codesimul(lai_forcing)
if(!is.null(lai_forcing) & lai_forcing %in% c(0,1))
data$codesimul <- get_codesimul(lai_forcing)

data$codoptim <- codoptim
# forcing codoptim
if(!is.null(codoptim) & codoptim %in% c(0,1))
data$codoptim <- codoptim

data$codesuite <- codesuite
# forcing codesuite
if(!is.null(codesuite) & codesuite %in% c(0,1))
data$codesuite <- codesuite

# nbplantes
#data$nbplantes
Expand Down Expand Up @@ -110,7 +117,7 @@ get_usm_data <- function(workspace,
data$nbans <-
as.numeric(strsplit(x = data$fclim2, split = ".", fixed = TRUE)[[1]][2]) -
as.numeric(strsplit(x = data$fclim1, split = ".", fixed = TRUE)[[1]][2]) +
data$culturean
1

# culturean
# data$culturean
Expand Down
2 changes: 1 addition & 1 deletion R/gen_obs.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#' @export
#'
gen_obs <- function(df,
out_dir = getwd(),
out_dir,
usms_list = NULL,
obs_table = lifecycle::deprecated(),
out_path = lifecycle::deprecated()) {
Expand Down
9 changes: 2 additions & 7 deletions R/gen_sols_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
#'
#'
#'
gen_sols_xml <- function(file = file.path(getwd(), "sols.xml"),
param_df = NULL,
gen_sols_xml <- function(file,
param_df,
template = NULL,
stics_version = "latest",
sols_in_file = lifecycle::deprecated(),
Expand Down Expand Up @@ -111,11 +111,6 @@ gen_sols_xml <- function(file = file.path(getwd(), "sols.xml"),

xml_doc <- NULL

# Fix : default output file path if not provided
if (base::is.null(sols_out_file)) {
sols_out_file <- file.path(getwd(), "sols.xml")
}

if (!base::is.null(sols_in_file)) {
xml_doc <- xmldocument(sols_in_file)
}
Expand Down
4 changes: 2 additions & 2 deletions R/gen_sta_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
#' @export
#'
# TODO: refactor with gen_tec_file, gen_ini_file : same code
gen_sta_xml <- function(param_df = NULL,
gen_sta_xml <- function(param_df,
file = NULL,
out_dir = getwd(),
out_dir,
stics_version = "latest",
param_table = lifecycle::deprecated(),
sta_in_file = lifecycle::deprecated(),
Expand Down
2 changes: 1 addition & 1 deletion R/gen_tec_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

gen_tec_xml <- function(param_df = NULL,
file = NULL,
out_dir = getwd(),
out_dir,
stics_version = "latest",
na_values = NA,
param_table = lifecycle::deprecated(),
Expand Down
10 changes: 2 additions & 8 deletions R/gen_usms_xml.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#' @title Generate STICS usms xml file from a template or an input file
#'
#' @param file Path (including name) of the usms file to generate. Optional,
#' set to `file.path(getwd(), "usms.xml")`by default.
#' @param file Path (including name) of the usms file to generate.
#' @param param_df A table (df, tibble) containing the values of the parameters
#' to use (see details)
#' @param template Path of an USM xml file to be used as a template.
Expand Down Expand Up @@ -59,7 +58,7 @@
#' @export
#'

gen_usms_xml <- function(file = file.path(getwd(), "usms.xml"),
gen_usms_xml <- function(file,
param_df = NULL,
template = NULL,
stics_version = "latest",
Expand Down Expand Up @@ -99,11 +98,6 @@ gen_usms_xml <- function(file = file.path(getwd(), "usms.xml"),

xml_doc <- NULL

# Fix : default output file path if not provided
if (base::is.null(usms_out_file)) {
usms_out_file <- file.path(getwd(), "usms.xml")
}

# If a template file is provided
if (!base::is.null(usms_in_file)) {
xml_doc <- xmldocument(usms_in_file)
Expand Down
2 changes: 1 addition & 1 deletion R/get_climate_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#'
#' @export
#'
get_climate_txt <- function(workspace = getwd(),
get_climate_txt <- function(workspace,
file_name = "climat.txt",
preserve = TRUE,
dirpath = lifecycle::deprecated(),
Expand Down
2 changes: 1 addition & 1 deletion R/get_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ get_file <- function(workspace,
#'
#' @noRd
#'
get_file_ <- function(workspace = getwd(),
get_file_ <- function(workspace,
usm_name = NULL,
usms_filepath = NULL,
var_list = NULL,
Expand Down
4 changes: 3 additions & 1 deletion R/get_obs_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#'
#' @noRd
#'
get_obs_txt <- function(dirpath = getwd(), filename = NULL, mixed = NULL) {
get_obs_txt <- function(dirpath,
filename = NULL,
mixed = NULL) {
. <- NULL # to avoid CRAN note for pipe
if (is.null(mixed)) {
if (file.exists(file.path(dirpath, "new_travail.usm"))) {
Expand Down
2 changes: 1 addition & 1 deletion R/get_param_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#'
#'
#' @export
get_param_txt <- function(workspace = getwd(),
get_param_txt <- function(workspace,
param = NULL,
variety = NULL,
exact = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion R/set_param_txt.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#' param = "cailloux", layer = 2, value = 1)
#'
#'
set_param_txt <- function(workspace = getwd(),
set_param_txt <- function(workspace,
param,
value,
append = FALSE,
Expand Down
2 changes: 1 addition & 1 deletion R/static_help.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
static_help <- function(pkg,
links_level = 0,
topic = NULL,
out_dir = getwd(),
out_dir,
overwrite = TRUE) {
if (!dir.exists(out_dir)) dir.create(out_dir)

Expand Down
28 changes: 11 additions & 17 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
── SticsRFiles 1.1.3: NOTE

Build ID: SticsRFiles_1.1.3.tar.gz-c4b9e5e1c0f0486ab292c73748a6ed2a
Build ID: SticsRFiles_1.1.3.tar.gz-77acad5161384a8e90d3b0461507f39e
Platform: Windows Server 2022, R-devel, 64 bit
Submitted: 1h 9m 54.9s ago
Build time: 7m 41.8s
Submitted: 1h 41m 5.2s ago
Build time: 6m 34.7s

❯ checking CRAN incoming feasibility ... [17s] NOTE
Maintainer: 'Patrice Lecharpentier <patrice.lecharpentier@inrae.fr>'
Expand All @@ -22,12 +22,12 @@

── SticsRFiles 1.1.3: NOTE

Build ID: SticsRFiles_1.1.3.tar.gz-200502a17eab4563a2972360a9407d88
Build ID: SticsRFiles_1.1.3.tar.gz-7a811a73d6964b13ad859b175e690f20
Platform: Ubuntu Linux 20.04.1 LTS, R-release, GCC
Submitted: 1h 9m 54.9s ago
Build time: 57m 29.5s
Submitted: 1h 41m 5.2s ago
Build time: 33m 20.1s

❯ checking CRAN incoming feasibility ... [7s/26s] NOTE
❯ checking CRAN incoming feasibility ... [7s/25s] NOTE
Maintainer: ‘Patrice Lecharpentier <patrice.lecharpentier@inrae.fr>’

New submission
Expand All @@ -39,12 +39,12 @@

── SticsRFiles 1.1.3: NOTE

Build ID: SticsRFiles_1.1.3.tar.gz-16096564b3744da893ed5ebd16c3c81f
Build ID: SticsRFiles_1.1.3.tar.gz-c83b92714ee64a8b967a641231cec721
Platform: Fedora Linux, R-devel, clang, gfortran
Submitted: 1h 9m 54.9s ago
Build time: 54m 54.4s
Submitted: 1h 41m 5.2s ago
Build time: 31m 6.5s

❯ checking CRAN incoming feasibility ... [9s/33s] NOTE
❯ checking CRAN incoming feasibility ... [8s/29s] NOTE
Maintainer: ‘Patrice Lecharpentier <patrice.lecharpentier@inrae.fr>’

New submission
Expand All @@ -53,9 +53,3 @@
Skipping checking HTML validation: no command 'tidy' found

0 errors ✔ | 0 warnings ✔ | 2 notes ✖






4 changes: 2 additions & 2 deletions man/gen_ini_xml.Rd

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

2 changes: 1 addition & 1 deletion man/gen_obs.Rd

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

4 changes: 2 additions & 2 deletions man/gen_sols_xml.Rd

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

4 changes: 2 additions & 2 deletions man/gen_sta_xml.Rd

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

2 changes: 1 addition & 1 deletion man/gen_tec_xml.Rd

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

5 changes: 2 additions & 3 deletions man/gen_usms_xml.Rd

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

2 changes: 1 addition & 1 deletion man/get_climate_txt.Rd

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

2 changes: 1 addition & 1 deletion man/get_param_txt.Rd

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

2 changes: 1 addition & 1 deletion man/set_param_txt.Rd

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

0 comments on commit f14eae8

Please sign in to comment.