Skip to content

Instantly share code, notes, and snippets.

@andrewjennings
Created July 12, 2011 18:51
Show Gist options
  • Save andrewjennings/1078680 to your computer and use it in GitHub Desktop.
Save andrewjennings/1078680 to your computer and use it in GitHub Desktop.
Add options to Contiguity calculators
Index: calculators.py
===================================================================
--- calculators.py (revision 1396)
+++ calculators.py (working copy)
@@ -788,6 +788,8 @@
count = 0
for district in districts:
+ if district.geom.empty:
+ continue
if len(district.geom) == 1:
count += 1
else:
@@ -887,6 +889,7 @@
districts = plan.get_districts_at_version(version, include_geom=False)
calc = Contiguity()
+ calc.arg_dict = self.arg_dict
calc.compute(**kwargs)
self.result = { 'value': len(districts) == calc.result }
@@ -919,6 +922,7 @@
districts = plan.get_districts_at_version(version, include_geom=False)
calc = Contiguity()
+ calc.arg_dict = self.arg_dict
calc.compute(**kwargs)
count = len(districts) - calc.result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment