Skip to content

Feature: add_predictor#31

Merged
mmyrte merged 15 commits into
mainfrom
feature/add_predictor
Jun 11, 2026
Merged

Feature: add_predictor#31
mmyrte merged 15 commits into
mainfrom
feature/add_predictor

Conversation

@mmyrte

@mmyrte mmyrte commented May 15, 2026

Copy link
Copy Markdown
Member

Reintroduces the db$add_predictor interface that simultaneously writes to pred_meta_t and pred_data_t. Incidentally, the dev env was upgraded to R 4.6 and roxygen 8.0.0 introduced, which makes it look like this PR is huge, but actually isn't.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reintroduces the db$add_predictor() convenience interface to write predictor metadata (pred_meta_t) and predictor values (pred_data_t) in one step, alongside an environment upgrade (R 4.6 + roxygen2 8.0.0) that regenerates documentation and workflows.

Changes:

  • Add add_predictor() (and evoland_db$add_predictor()) to upsert predictor metadata + data using the active id_run.
  • Tighten/coerce pred_meta_t types (incl. sources normalization) and update tinytests accordingly.
  • Update CI workflows and regenerate Rd files due to roxygen changes.

Reviewed changes

Copilot reviewed 13 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
rproject.toml Bumps declared R version for the dev environment.
R/util_download.R Clarifies that df_in can come from predictor/intervention metadata tables.
R/trans_models_t.R Minor formatting/roxygen adjustments (comma cleanup, doc tweak).
R/pred_meta_t.R Strengthens coercion for pred_meta_t fields and normalizes sources.
R/pred_data_t.R Adds add_predictor() and adjusts printing/fill behavior for predictor columns.
R/evoland_db.R Exposes add_predictor() as an R6 method on evoland_db.
R/evoland_db_views.R Roxygen alias formatting cleanup.
man/util_terra.Rd Roxygen-regenerated link target update for terra::SpatRaster.
man/util_download.Rd Mirrors util_download.R doc change in generated Rd.
man/pred_meta_t.Rd Mirrors pred_meta_t doc wording update in generated Rd.
man/pred_data_t.Rd Documents newly added add_predictor() alias/usage.
man/parquet_db.Rd Large roxygen formatting regeneration (method anchors/sections).
man/LearnerClassifGrrf.Rd Roxygen formatting + link target regeneration.
man/evoland_db.Rd Adds add_predictor() method to generated class docs + roxygen regeneration.
man/coords_t.Rd Roxygen-regenerated link target update for terra::SpatExtent.
inst/tinytest/test_pred_meta_t.R Extends pred_meta_t tests for missing sources behavior.
inst/tinytest/test_integ_trans_models_t.R Updates plot-data assertions to match regenerated outputs.
inst/tinytest/test_db_evoland.R Adds integration coverage for db$add_predictor() behavior.
DESCRIPTION Updates roxygen config metadata to roxygen2 8.0.0.
.github/workflows/R-CMD-check.yaml Adjusts matrix + cache paths; updates action versions (needs fixes).
.github/workflows/R-CMD-check-light.yml Updates checkout action version (needs fixes).
Files not reviewed (8)
  • man/LearnerClassifGrrf.Rd: Language not supported
  • man/coords_t.Rd: Language not supported
  • man/evoland_db.Rd: Language not supported
  • man/parquet_db.Rd: Language not supported
  • man/pred_data_t.Rd: Language not supported
  • man/pred_meta_t.Rd: Language not supported
  • man/util_download.Rd: Language not supported
  • man/util_terra.Rd: Language not supported
Comments suppressed due to low confidence (1)

R/pred_data_t.R:235

  • In set_pred_coltypes(), fill_value is parsed via type.convert(), but the assignment uses meta_row$fill_value (a character, because pred_meta_t$fill_value is cast to char). This can coerce numeric predictor columns to character when filling NAs, and it ignores the parsed fill_value value entirely. Use the parsed fill_value for assignment (and handle factors explicitly if you need level-safe filling).
    # if col is factor, fill_value being a character is safe
    # dt set() can add a new level if it's not already present
    fill_value <- meta_row$fill_value |> type.convert(as.is = TRUE)
    if (!is.na(fill_value)) {
      data.table::set(
        result,
        i = which(is.na(result[[col]])),
        j = col,
        value = meta_row$fill_value
      )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/pred_data_t.R
Comment thread R/pred_data_t.R Outdated
Comment thread R/pred_data_t.R
Comment thread R/pred_data_t.R
mmyrte and others added 3 commits May 26, 2026 11:32
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mmyrte mmyrte merged commit ff55f65 into main Jun 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants