alarm-redist / redist

Simulation methods for legislative redistricting.
https://alarm-redist.github.io/redist/
GNU General Public License v2.0
66 stars 23 forks source link

Constant columns in `plans` messes up `summary(plans)` #138

Closed CoryMcCartan closed 2 years ago

CoryMcCartan commented 2 years ago

dev branch

Need to drop constant columns (or NaN r-hats in general)

CoryMcCartan commented 2 years ago

Fixed by 8b17c0e6

kuriwaki commented 2 years ago

@CoryMcCartan this commit will cause a unexplained error when a column is all NAs. Maybe add | all(is.na(x)) so NAs don't propogate?

library(redist)
library(dplyr)
data(iowa)
iowa_map <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.05)

sims <- redist_smc(iowa_map, nsims = 100, runs = 2) %>% 
    mutate(demv = NA)

summary(sims)
#> SMC: 200 sampled plans of 4 districts on 99 units
#> `adapt_k_thresh`=0.985 • `seq_alpha`=0.5
#> `est_label_mult`=1 • `pop_temper`=0
#> Plan diversity 80% range: 0.54 to 0.83
#> Error in `vectbl_as_col_location2()`:
#> ! Must extract column with a single valid subscript.
#> ✖ Subscript `col` can't be `NA`.

Created on 2022-06-03 by the reprex package (v2.0.1)

CoryMcCartan commented 2 years ago

Good catch, thanks. NA == NA is NA.