Skip to content

Fix R CMD check lazy-load failure from duplicate R6 method registration#30

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/discuss-transition-probability-estimation
Open

Fix R CMD check lazy-load failure from duplicate R6 method registration#30
Copilot wants to merge 6 commits into
mainfrom
copilot/discuss-transition-probability-estimation

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

R CMD check (light) failed during package load because evoland_db_views.R attempted to add public methods that are now already declared in evoland_db.R. The failure was caused by duplicate R6 method registration at load time.

  • R6 method override compatibility

    • Updated evoland_db$set(...) calls in R/evoland_db_views.R to explicitly allow replacing predeclared methods:
      • trans_rates_dinamica_v
      • adjusted_trans_pot_v
      • alloc_params_clumpy_v
    • This keeps evoland_db.R as the canonical method declaration surface while preserving view-backed implementations in evoland_db_views.R.
  • Behavioral impact

    • No API shape changes.
    • Resolves class initialization/load error by making view implementations intentional overrides instead of duplicate adds.
evoland_db$set(
  "public",
  "trans_rates_dinamica_v",
  overwrite = TRUE,
  function(id_period) { ... }
)

@github-actions github-actions Bot 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.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

air

[air] reported by reviewdog 🐶

params[c("mean_patch_size", "patch_size_variance", "patch_isometry",
"frac_expander", "frac_patcher")],


[air] reported by reviewdog 🐶


[air] reported by reviewdog 🐶

id_coord = 1L,
value = 0.3


[air] reported by reviewdog 🐶

id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),


[air] reported by reviewdog 🐶

value = c(0.6, 0.2, 0.1, 0.5, 0.3, 0.4)


[air] reported by reviewdog 🐶

id_trans = c(1L, 2L),
rate = c(0.2, 0.1)


[air] reported by reviewdog 🐶

mean_t1 <- mean(raw_vals$value[raw_vals$id_trans == 1L]) # (0.6+0.1+0.3)/3
mean_t2 <- mean(raw_vals$value[raw_vals$id_trans == 2L]) # (0.2+0.5+0.4)/3


[air] reported by reviewdog 🐶

expect_true(abs(col_mean_t1_scaled - rates$rate[1L]) <=
abs(mean_t1 - rates$rate[1L]) + 1e-9)

Comment thread R/alloc_clumpy.R
#' @return Integer >= 1L, sampled patch area in cells.
#' @keywords internal
sample_lognorm_area <- function(area_mean, area_var) {
if (is.na(area_mean) || area_mean <= 0) return(1L)

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.

[air] reported by reviewdog 🐶

Suggested change
if (is.na(area_mean) || area_mean <= 0) return(1L)
if (is.na(area_mean) || area_mean <= 0) {
return(1L)
}

Comment thread R/alloc_clumpy.R
Comment on lines +96 to +99
above = ifelse(rows > 1L, seq_len(n) - ncol_r, 0L),
below = ifelse(rows < nrow_r, seq_len(n) + ncol_r, 0L),
left = ifelse(cols > 1L, seq_len(n) - 1L, 0L),
right = ifelse(cols < ncol_r, seq_len(n) + 1L, 0L)

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.

[air] reported by reviewdog 🐶

Suggested change
above = ifelse(rows > 1L, seq_len(n) - ncol_r, 0L),
below = ifelse(rows < nrow_r, seq_len(n) + ncol_r, 0L),
left = ifelse(cols > 1L, seq_len(n) - 1L, 0L),
right = ifelse(cols < ncol_r, seq_len(n) + 1L, 0L)
above = ifelse(rows > 1L, seq_len(n) - ncol_r, 0L),
below = ifelse(rows < nrow_r, seq_len(n) + ncol_r, 0L),
left = ifelse(cols > 1L, seq_len(n) - 1L, 0L),
right = ifelse(cols < ncol_r, seq_len(n) + 1L, 0L)

Comment thread R/alloc_clumpy.R
n_cells <- nrow_r * ncol_r

ant_vec <- as.integer(terra::values(anterior_rast))
post_vec <- ant_vec # will be modified in-place

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.

[air] reported by reviewdog 🐶

Suggested change
post_vec <- ant_vec # will be modified in-place
post_vec <- ant_vec # will be modified in-place

Comment thread R/alloc_clumpy.R

# Cells currently in from_class (1-based raster index)
from_cells <- which(!is.na(ant_vec) & ant_vec == from_class)
if (length(from_cells) == 0L) next

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.

[air] reported by reviewdog 🐶

Suggested change
if (length(from_cells) == 0L) next
if (length(from_cells) == 0L) {
next
}

Comment thread R/alloc_clumpy.R
for (j in seq_along(to_classes)) {
id_trans_j <- trans_for_class$id_trans[j]
pots_j <- adj_pots[id_trans == id_trans_j, .(id_coord, value)]
if (nrow(pots_j) == 0L) next

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.

[air] reported by reviewdog 🐶

Suggested change
if (nrow(pots_j) == 0L) next
if (nrow(pots_j) == 0L) {
next
}

from_class = 1L,
to_class = 2L,
eccentricity = 0.5,
ncol = 4L

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.

[air] reported by reviewdog 🐶

Suggested change
ncol = 4L
ncol = 4L

ncol = 4L
)
expect_true(length(patch) <= 4L)
expect_true(1L %in% patch) # pivot always included

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.

[air] reported by reviewdog 🐶

Suggested change
expect_true(1L %in% patch) # pivot always included
expect_true(1L %in% patch) # pivot always included

# Pivot with wrong class → empty result
landscape_wrong <- as.integer(rep(2L, n))
patch_empty <- grow_patch_cpp(
landscape = landscape_wrong,

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.

[air] reported by reviewdog 🐶

Suggested change
landscape = landscape_wrong,
landscape = landscape_wrong,

Comment on lines +86 to +94
probs = probs,
nbr_above = nbrs$above,
nbr_below = nbrs$below,
nbr_left = nbrs$left,
nbr_right = nbrs$right,
pivot = 1L,
target_area = 4L,
from_class = 1L,
to_class = 2L,

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.

[air] reported by reviewdog 🐶

Suggested change
probs = probs,
nbr_above = nbrs$above,
nbr_below = nbrs$below,
nbr_left = nbrs$left,
nbr_right = nbrs$right,
pivot = 1L,
target_area = 4L,
from_class = 1L,
to_class = 2L,
probs = probs,
nbr_above = nbrs$above,
nbr_below = nbrs$below,
nbr_left = nbrs$left,
nbr_right = nbrs$right,
pivot = 1L,
target_area = 4L,
from_class = 1L,
to_class = 2L,

from_class = 1L,
to_class = 2L,
eccentricity = 0.5,
ncol = 4L

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.

[air] reported by reviewdog 🐶

Suggested change
ncol = 4L
ncol = 4L

Comment on lines +79 to +80
params[c("mean_patch_size", "patch_size_variance", "patch_isometry",
"frac_expander", "frac_patcher")],

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.

[air] reported by reviewdog 🐶

Suggested change
params[c("mean_patch_size", "patch_size_variance", "patch_isometry",
"frac_expander", "frac_patcher")],
params[c(
"mean_patch_size",
"patch_size_variance",
"patch_isometry",
"frac_expander",
"frac_patcher"
)],


# as_trans_pot_t: basic construction
tp <- as_trans_pot_t(data.frame(
id_trans = 1L,

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.

[air] reported by reviewdog 🐶

Suggested change
id_trans = 1L,
id_trans = 1L,

Comment on lines +11 to +12
id_coord = 1L,
value = 0.3

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.

[air] reported by reviewdog 🐶

Suggested change
id_coord = 1L,
value = 0.3
id_coord = 1L,
value = 0.3

Comment on lines +37 to +38
id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),

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.

[air] reported by reviewdog 🐶

Suggested change
id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),
id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),

id_trans = c(1L, 2L, 1L, 2L, 1L, 2L),
id_coord = c(1L, 1L, 2L, 2L, 3L, 3L),
id_period_post = 4L,
value = c(0.6, 0.2, 0.1, 0.5, 0.3, 0.4)

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.

[air] reported by reviewdog 🐶

Suggested change
value = c(0.6, 0.2, 0.1, 0.5, 0.3, 0.4)
value = c(0.6, 0.2, 0.1, 0.5, 0.3, 0.4)

Comment on lines +43 to +44
id_trans = c(1L, 2L),
rate = c(0.2, 0.1)

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.

[air] reported by reviewdog 🐶

Suggested change
id_trans = c(1L, 2L),
rate = c(0.2, 0.1)
id_trans = c(1L, 2L),
rate = c(0.2, 0.1)

Comment on lines +48 to +49
mean_t1 <- mean(raw_vals$value[raw_vals$id_trans == 1L]) # (0.6+0.1+0.3)/3
mean_t2 <- mean(raw_vals$value[raw_vals$id_trans == 2L]) # (0.2+0.5+0.4)/3

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.

[air] reported by reviewdog 🐶

Suggested change
mean_t1 <- mean(raw_vals$value[raw_vals$id_trans == 1L]) # (0.6+0.1+0.3)/3
mean_t2 <- mean(raw_vals$value[raw_vals$id_trans == 2L]) # (0.2+0.5+0.4)/3
mean_t1 <- mean(raw_vals$value[raw_vals$id_trans == 1L]) # (0.6+0.1+0.3)/3
mean_t2 <- mean(raw_vals$value[raw_vals$id_trans == 2L]) # (0.2+0.5+0.4)/3

Comment on lines +81 to +82
expect_true(abs(col_mean_t1_scaled - rates$rate[1L]) <=
abs(mean_t1 - rates$rate[1L]) + 1e-9)

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.

[air] reported by reviewdog 🐶

Suggested change
expect_true(abs(col_mean_t1_scaled - rates$rate[1L]) <=
abs(mean_t1 - rates$rate[1L]) + 1e-9)
expect_true(abs(col_mean_t1_scaled - rates$rate[1L]) <= abs(mean_t1 - rates$rate[1L]) + 1e-9)

Copilot AI changed the title feat: CLUMPY allocation backend + raw/adjusted transition potential architecture Fix R CMD check lazy-load failure from duplicate R6 method registration Jun 16, 2026
@mmyrte mmyrte marked this pull request as ready for review June 16, 2026 13:54
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