Skip to content

Commit

Permalink
fix some checkmate errors from addField in test, field_id should be i…
Browse files Browse the repository at this point in the history
…nteger,and update readme example
  • Loading branch information
gerardhros committed Apr 16, 2024
1 parent 2a21c31 commit 955436c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions R/apus.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Apus <- R6::R6Class(
#' @description
#' Add a field to the apus object
#'
#' @param b_id_field (character) ID or (unique) name of the field
#' @param b_id_field (integer) ID of the field
#' @param b_area (number) The area of the field (ha)
#' @param b_lu (character) The cultivation code for this field
#' @param d_n_req (number) The required amount of Nitrogen for this field (kg N / ha / year)
Expand All @@ -83,8 +83,8 @@ Apus <- R6::R6Class(
addField = function(b_id_field, b_area, b_lu, d_n_req = NA, d_p_req = NA, d_k_req = NA, d_n_norm = NA, d_n_norm_man = NA, d_p_norm = NA, b_lu_yield = NA, b_lu_price = NA) {

# Check arguments ---------------------------------------------------------
checkmate::assert_character(b_id_field,len = 1)
checkmate::assert_numeric(b_area,lower = 0, upper = 100)
checkmate::assert_integerish(b_id_field,len = 1)
checkmate::assert_numeric(b_area,lower = 0, upper = 50000)
checkmate::assert_subset(b_lu,choices = apus::cultivations$b_lu)
checkmate::assert_numeric(d_n_req,lower = 0, upper = 400)
checkmate::assert_numeric(d_p_req,lower = 0, upper = 150)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ apus$addField(
# Add a second field
apus$addField(
b_id_field = 1L,
b_id_field = 2L,
b_area = 5000,
b_lu = 'nl_262',
d_n_req = 270,
Expand Down
2 changes: 1 addition & 1 deletion man/Apus.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-003-apus.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ test_that("Second field is added", {
field3 <- data.frame(
b_id_field = 3L,
b_area = 5000,
b_lu = 'nl_366',
b_lu = 'nl_372',
d_n_req = 370,
d_p_req = 130,
d_k_req = 50,
d_n_norm = 330,
d_n_norm_man = 300,
d_n_norm_man = 200,
d_p_norm = 80
)

Expand Down

0 comments on commit 955436c

Please sign in to comment.