Skip to content

Defects found reviewing development (1109f11) #4

Done

Description

@achubaty

These come from a review of development at 1109f11, made for PredictiveEcology/LandR#302 and LandWeb.
R CMD check --as-cran is clean: 0 errors, 0 warnings, and 2 NOTEs (CRAN's new-submission note, and the prepInputsFireYear() example's NFDB download). The tests pass: 43 tests, with one interactive-only test skipped. Each moved function was compared with LandR c537fb3, and results are the same for the documented uses. The problems found:

  • prepInputsFireYear(): a non-numeric fireField gives a map that is entirely NA. standAge.R#L382-L385 coerces it with as.numeric(as.factor(yr)), which gives factor codes 1 to k, not years. The earliestYear filter at L390 then sets every cell to NA, and the only sign is the warning. The LandR version stopped with an error. as.numeric(as.character(yr)) would do what the warning says. No test covers this.
  • replaceAgeInFires() ignored a startTime after 2023. Fixed in replaceAgeInFires(): use a startTime after 2023 #3.
  • scanfiUrlRemap() was copied, not moved. At Stand age and disturbance-year functions move to forestInputs (re-exported, identical results) LandR#302, LandR keeps and exports its own copy, with its own manifest and its own option, LandR.scanfiMirror. This package reads forestInputs.scanfiMirror and falls back to the LandR option. That leaves two manifests to keep in sync until LandR's other SCANFI readers move here.
  • The prepInputsFireYear() example needs withr, which is only in Suggests. standAge.R#L335-L361: the @examplesIf condition only tests for CI, so the example fails where withr is not installed. Adding requireNamespace("withr", quietly = TRUE) to the condition fixes that. The example also downloads all of NFDB, which took 81 s in R CMD check.
  • replaceAgeInFires() documents firePerimeters as "the earliest fire date to allow" (standAge.R#L507). That text was copied from another parameter; the argument is the fire-year raster.
  • Suggests:
  • Leftover SCANFI v3 code. scanfi-access.R#L121-L133 holds a section header, an unused .scanfiV3FTPURL, and a comment for a function that isn't there.
  • The inputsTable() docs describe a fallback that doesn't exist. They say the mirror column is "used when url cannot be reached" (inputs.R#L7), but nothing reads that column. The SCANFI mirror goes through scanfiUrlRemap()'s own manifest.

🤖 Generated with Claude Code

Activity

  1. achubaty commented on Dec 3, 2026

    @achubaty
    ContributorAuthor

    More from the same review. These are smaller than the points above, and none changes results for the documented uses.

    • The mirror switch now depends on which package reads the file.
      • options(forestInputs.scanfiMirror = FALSE) turns the SCANFI mirror off for stand age only.
      • LandR's own SCANFI readers (species, biomass, land cover) still check only LandR.scanfiMirror (LandR scanfiMirror.R#L44), and keep using the mirror.
      • options(LandR.scanfiMirror = FALSE) turns it off for both, because forestInputs falls back to that option (scanfiMirror.R#L67-L69).
      • One option, read by both packages, would avoid the split. For example, LandR could call forestInputs' scanfiUrlRemap() instead of keeping its own copy.
    • Two documented prepInputsFireYear() changes have no test:
      • a RasterLayer rasterToMatch, now converted to a SpatRaster, which is also what the function returns;
      • fire polygons in a different CRS from rasterToMatch, now reprojected when terra::same.crs() is false (standAge.R#L366-L380).
        The LandR version stopped with an error on a RasterLayer grid whenever there were fires, so that path has not run in a release before.
    • prepInputsDisturbanceYear(polygon = ...) now stops with an error. The new polygonsBefore argument shares the polygon prefix with polygonAgreement, which polygon = used to match. Partial matching is fragile anyway, but a NEWS line would tell anyone who relied on it.
    • Cached calls recompute once. reproducible's Cache() key includes the function's code. prepInputsFireYear()'s code changed in the move, so a cached call, including the one inside prepInputsStandAgeMap(), runs again the first time after upgrading. A NEWS line would tell users with caching on to expect it.
    • inputsTable() metadata contradicts itself. The SCANFI age rows give access = public, but their notes say "Google Drive folder shared with collaborators" (inputs.csv#L12-L21). The public copies are the mirror URLs, which only the v2 rows have.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions