replicahq / doppelganger

A Python package of tools to support population synthesizers
Apache License 2.0
165 stars 32 forks source link

Segmenting on an input variable that allows the None type causes a sorting error #42

Closed nikisix closed 6 years ago

nikisix commented 6 years ago

Traceback (most recent call last): File "doppelganger/scripts/download_allocate_generate.py", line 332, in main() File "doppelganger/scripts/download_allocate_generate.py", line 317, in main person_segmenter, household_segmenter File "doppelganger/scripts/download_allocate_generate.py", line 181, in create_bayes_net household_model.write(household_model_filename) File "/Users/six/code/doppelganger/doppelganger/bayesnets.py", line 92, in write json_string = self.to_json() File "/Users/six/code/doppelganger/doppelganger/bayesnets.py", line 100, in to_json return json.dumps(blob, indent=4, sort_keys=True) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/init.py", line 250, in dumps sort_keys=sort_keys, **kw).encode(obj) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 209, in encode chunks = list(chunks) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 434, in _iterencode for chunk in _iterencode_dict(o, _current_indent_level): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict for chunk in chunks: File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 361, in _iterencode_dict items = sorted(dct.items(), key=lambda kv: kv[0]) File "/Library/Python/2.7/site-packages/future-0.16.0-py2.7.egg/future/types/newstr.py", line 316, in gt raise TypeError(self.unorderable_err.format(type(other))) TypeError: unorderable types: str() and <type 'NoneType'>

nikisix commented 6 years ago

Also realized that in order to run a blank variable through the solver, it's marginal equivalent must also have a blank entry in the form of: "variablename"

As num_people and num_vehicles do not have blank counter parts in the ACS data (marginals) it's probably best if we either continue mapping blank pums elements to 0's or filter rows with blanks in a solver variable with no ACS equivalents.

nikisix commented 6 years ago

Moving this issue to: Solver variable bin lineup between inputs and marginals #43