Skip to content

A mistyped grid_factors$dim1/dim2 is silently ignored #128

Description

@rogerssam

infer_row_col() falls through to pattern matching when the named columns are absent so a typo optimises a different grid with no warning and reports success.

library(speed)
df <- initialise_design_df(items = 4, nrows = 4, ncols = 4)

df$blk <- rep(1:4, each = 4)
df$pos <- rep(1:4, times = 4)
a <- speed(df, swap = "treatment", spatial_factors = ~ blk + pos,
           grid_factors = list(dim1 = "blk",  dim2 = "pos"),
           iterations = 500, seed = 3, quiet = TRUE)
b <- speed(df, swap = "treatment", spatial_factors = ~ blk + pos,
           grid_factors = list(dim1 = "blkk", dim2 = "pos"),   # typo
           iterations = 500, seed = 3, quiet = TRUE)
min(a$scores); min(b$scores)
#> [1] 3
#> [1] 1.333333      # silently used row/col instead

Expected: warn or error when dim1/dim2 are supplied but not found, rather than falling through. .verify_grid_by() already guards by= for exactly this reason but dim1/dim2 are unguarded.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions