mggg / GerryChain

Use MCMC to analyze districting plans and gerrymanders
https://mggg.github.io/GerryChain/
Other
132 stars 74 forks source link

Parse config error #159

Closed MuNaught closed 6 years ago

MuNaught commented 6 years ago

Upon creating a config file through the GUI with the most recent version of the chain repo, I am getting the following error: parseconfigerror

I made sure to fill in every field in the GUI to avoid potential UnboundLocalError exceptions. Here is the config file source that gave this error:

[GRAPH_SOURCE] gsource = C:/Users/pgirardet/Miniconda2/envs/vrdi/projects/yourstate/govt_VTDs/final_merged_shapefile.shp

[GRAPH_DATA] id = ID pop = POPULATION cd = DISTRICT area = tot_st_hou

[VALIDITY] colrefuse_new_splits,10 = refuse_new_splits,10

[EVALUATION_SCORES] col0 = efficiency_gap,dem_st_hou

[EVALUATION_SCORES_LOG] colwrite_hists = write_hists

[SAVEFILENAME] write_hists = hist.png write_flips = json filename.json write_p_values = report filename.txt

[MARKOV_CHAIN] num_steps = 1000000 proposal = propose_random_flip accept = always_accept

rdbliss commented 6 years ago

Efficiency gap requires two arguments. You have this line in your config:

col0 = efficiency_gap,dem_st_hou

That only provides the efficiency gap function one argument, when it needs two, like

col0 = efficiency_gap,dem_st_hou,rep_st_hou

Using the GUI, you need to select two options for efficiency gap. As for the code, this should have been caught somewhere. Thanks for the report!

MuNaught commented 6 years ago

Thanks, that fixed the parse config error. Now I'm just getting an UnboundLocalError: local variable 'validators' referenced before assignment error.

Not sure how to fix that one since I filled in something for all fields in the GUI.

rdbliss commented 6 years ago

OP's issue is fixed, and the new issue lives at #161. I'm leaving this open as a general reminder to that the config parser needs to be more robust and give meaningful error messages.

rdbliss commented 6 years ago

Kind of fixed. We're leaving the config parser "as-is" for now, so I'll close this.