diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index c446e47..ede6f76 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -25,7 +25,7 @@ jobs: - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} - {os: ubuntu-latest, r: 'release'} - {os: ubuntu-latest, r: 'oldrel-1'} - - {os: ubuntu-latest, r: '4.0.0'} + - {os: ubuntu-latest, r: '4.1.0'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index 04ae3b6..f2c3448 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: BioCroField -Version: 0.3.0-0 +Version: 0.3.0-1 Title: Tools for BioCro Field Data Description: A collection of tools for processing field data related to BioCro crop growth simulations. @@ -12,7 +12,7 @@ Authors@R: c( License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -Depends: R (>= 4.0.0) +Depends: R (>= 4.1.0) Imports: rmarkdown, BioCro diff --git a/NEWS.md b/NEWS.md index cb42153..af5bf0a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,8 @@ for the next release. `biomass_table`. - Values of `time` are now calculated using `BioCro::add_time_to_weather_data` to ensure they are always consistent with BioCro's time definition. +- Values of partitioned leaf mass can be set to `NA` when creating a + `harvest_point`, which is treated as if the leaf mass had not been provided. # BioCroField VERSION 0.3.0 diff --git a/R/harvest_point.R b/R/harvest_point.R index 29f50fa..823d50a 100644 --- a/R/harvest_point.R +++ b/R/harvest_point.R @@ -190,6 +190,7 @@ harvest_point <- function( # Do not allow a leaf with zero area but nonzero mass if (!is.na(partitioning_leaf_area) && partitioning_leaf_area == 0 && !is.null(partitioning_component_weights[['leaf']]) && + !is.na(partitioning_component_weights[['leaf']]) && partitioning_component_weights[['leaf']] > 0) { stop("It is not possible for a leaf with zero area to have a nonzero mass") } @@ -197,6 +198,7 @@ harvest_point <- function( # Do not allow a leaf with zero mass but nonzero area if (!is.na(partitioning_leaf_area) && partitioning_leaf_area > 0 && !is.null(partitioning_component_weights[['leaf']]) && + !is.na(partitioning_component_weights[['leaf']]) && partitioning_component_weights[['leaf']] == 0) { stop("It is not possible for a leaf with zero mass to have a nonzero area") } diff --git a/tests/testthat/test-harvest_point.R b/tests/testthat/test-harvest_point.R index 4294c06..4629837 100644 --- a/tests/testthat/test-harvest_point.R +++ b/tests/testthat/test-harvest_point.R @@ -156,12 +156,12 @@ test_that("Missing density parameters are automatically calculated", { harvest_point(row_spacing = 0.75, plant_spacing = 0.2)$planting_density, 26980 ) - + expect_equal( harvest_point(row_spacing = 0.75, planting_density = 26980)$plant_spacing, 0.2 ) - + expect_equal( harvest_point(plant_spacing = 0.2, planting_density = 26980)$row_spacing, 0.75 @@ -218,3 +218,9 @@ test_that("Additional arguments must have length 1 and be numeric, character, or "The following inputs should have length 1, but do not: construct" ) }) + +test_that("Partitioned leaf mass can be NA when leaf area is numeric", { + expect_no_error( + harvest_point(partitioning_component_weights = list(leaf = NA), partitioning_leaf_area = 1) + ) +}) diff --git a/tests/testthat/test-process.R b/tests/testthat/test-process.R index aac269d..7cdd549 100644 --- a/tests/testthat/test-process.R +++ b/tests/testthat/test-process.R @@ -122,6 +122,8 @@ test_that("LMA is calculated only when possible", { expect_na(hpp$LMA) expect_na(process(harvest_point(partitioning_leaf_area = 1))$LMA) + + expect_na(process(harvest_point(partitioning_component_weights = list(leaf = NA), partitioning_leaf_area = 1))$LMA) expect_na(process(harvest_point(partitioning_component_weights = list(leaf = 1)))$LMA)