Skip to content

Build design grids from plot coordinates, and support designs spanning multiple grids - #119

Merged
rogerssam merged 30 commits into
mainfrom
bugfix/grid-orientation
Aug 8, 2026
Merged

Build design grids from plot coordinates, and support designs spanning multiple grids#119
rogerssam merged 30 commits into
mainfrom
bugfix/grid-orientation

Conversation

@rogerssam

@rogerssam rogerssam commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Grid-based metrics were computed from the order of rows in the data frame rather than each plot's row/col coordinates, so they described a layout that wasn't the design. Four functions each assumed an ordering — two row-major, two column-major. All now read coordinates via a single validated primitive.

That change made the grid contract strict, which exposed the rest:

  • Multi-environment trials were scored as one pooled grid, silently discarding plots whose coordinates collided (30 of 80 in the measured case) or counting adjacencies between plots at different sites (60 vs the correct 50). grid_factors gains an optional by argument naming the column that separates grids; adjacency, neighbour balance and piepho's evenness are computed per grid, and efficiency is reported one value per site.
  • calculate_efficiency_factor() returned a plausible-looking value (usually above 1, which is impossible) for designs whose treatment contrasts aren't estimable. It now refuses with a reason. The row-column model gained an intercept, which is what makes the rank test exact; verified against both published designs (0.834, 0.827) and brute-force contrast variances, no existing value changes.
  • summary() no longer dies on a design it can't place on one grid; it reports why each metric is unavailable.
  • Coordinate validation was hoisted out of the annealing loop, making whole runs 10–28% faster with bit-identical scores.
    objective_function_piepho() designs should be regenerated — it previously scrambled the treatment column against its coordinates.

Tests: 1787 pass, 0 fail, 0 warnings. Several existing tests asserted values for designs base R's own lm() confirms are non-estimable; those fixtures were replaced, keeping each test's original intent.

Merge order: PR #97 (feature/incidence) calls build_design_matrix(), which doesn't exist on main, so it must merge after this and be rebased onto it.

@rogerssam rogerssam changed the title Bugfix/grid orientation Build design grids from plot coordinates, and support designs spanning multiple grids Aug 7, 2026
@rogerssam
rogerssam merged commit 3d9b4e0 into main Aug 8, 2026
9 checks passed
@rogerssam
rogerssam deleted the bugfix/grid-orientation branch August 8, 2026 04:22
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.

1 participant