This file is kept locally and has not been pushed.
cleaned v0.7.0 (staging @ 800d53a)fixes/tests/ in this folder (the earlier local git branch has been removed)pkgload::load_all()helper-ipcc-reference.R implements each method directly from the source text, not from the package code. Every function cites the equation and the printed page.pdftotext and checked each transcription line by line. Page numbers come from the page footers.helper-critical-fixture.R patches the shipped example only as far as needed to run: crop_name, the dry yields, and the renamed livestock columns. Every patch is listed in that file, and none touches a value that a test asserts on. Test 09 checks the unpatched file.| # | Finding (review ids) | Control | Finding test | Package vs reference |
|---|---|---|---|---|
| 01 | NE requirements met with ME, no REM/REG (F02, C-01) | PASS: NEm = 0.386·BW^0.75 (Eq. 10.3, Table 10.4) | FAIL | Energy DMI is 0.55–0.63× IPCC Eq. 10.16 on a controlled diet at 64% DE (cows 0.63, steers 0.57, calves 0.55) |
| 02a | N retention units (C-02, H-04, F04, F07) | PASS: N intake = Eq. 10.32 | FAIL | Cow N retention 0.00016 vs 0.058 kg N/day (365× too small) |
| 02b | N excretion formula (same ids) | (as 02a) | FAIL | Cow 89.4 vs 68.2 kg N/yr (+31%). Steers 49.7 vs 43.3. Calves 12.8 vs 8.8 |
| 03 | SOC factors applied every year to the measured stock (F01, S-02) | PASS: Eq. 2.25 reference gives 0 when nothing changes | FAIL | 1 ha of unchanged cropland shows −7.02 t C/yr (Eq. 2.25 gives 0) |
| 04 | Burning counts CO2 and uses the N2O GWP for NOx (F03, F06) | PASS: EFs = Table 2.5 | FAIL | 1 t DM burnt: 1,802 vs 75 kg CO2e (24×) |
| 05 | Tree SOC never added (F02 code, S-01) | PASS: biomass_calculation() returns a data frame with no trees_non_feed_biomass element |
FAIL | +2.5 tree c_increase_soc changes the SOC total by 0 |
| 06 | Zero yield silently becomes 0 ha (LU-01, F04) | PASS: a normal pasture gets area > 0 | FAIL | 9 season rows, 14,231 kg DM of demand reported as 0 ha, with no warning |
| 07a | Leaching not multiplied by area (N-01) | PASS: out4 = per-ha rate × area |
FAIL | Pasture on 109 ha: 2.6 vs 278 kg N |
| 07b | Leaching coefficient 0.021*(P-3.9) (N-02) |
none | SKIP | Primary source not verified (see below) |
| 08 | Hidden lookup of inputs in the caller (F03 code) | PASS: explicit argument gives the same result | FAIL ×2 | n_balance() and ghg_emission() silently use another scenario's object from the caller |
| 09 | Shipped example does not run (F01, D-01, H-03, M-01) | none | FAIL ×3 | Column `crop_name` doesn't exist; object 'fat_milkcontent' not found; dm_content given as fractions (0.3) where the code expects %, with 0 for the concentrate |
Totals on v0.7.0 across 22 tests: 8 control PASS, 13 finding FAIL, 1 SKIP. No test errored for harness reasons. (An earlier version of this file said 9 and 12, which was a miscount.) Two guard tests for the proposed fixes were added later; see 07_fix_log.md.
IPCC 2019 Refinement, Vol. 4, Ch. 10 (PDF)
IPCC 2006, Vol. 4, Ch. 2 (PDF)
Code-contract standards (tests 06 and 08)
These aren't IPCC tests. They check against standard R package practice: signal a condition when a result is impossible (R Packages 2e), and don't make a result depend on objects in the caller's environment (Advanced R 2e §6.4).
herd_composition, which makes the gap smaller than an unscaled comparison would. That makes 02b a conservative test.vignettes/input-contract.Rmd:50-53) gives no units, so I left it as a documentation finding rather than a test.cd fixes
./run_all.sh
openxlsx must be installed; this run used a scratch library. The tests are written against the correct behaviour. When a finding is fixed, its test turns green and stays in the suite as a regression test.
Comments
Comments are GitHub Discussions on peetmate/cleaned-review; sign in with GitHub to post.