Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions R/harvest_point.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ 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")
}

# 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")
}
Expand Down
10 changes: 8 additions & 2 deletions tests/testthat/test-harvest_point.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
})
2 changes: 2 additions & 0 deletions tests/testthat/test-process.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down