replacing dict with ordered dict

This commit is contained in:
Andy Eschbacher 2016-06-21 17:31:17 -04:00
parent 3c066d65fc
commit 1912d57891

View File

@ -7,6 +7,7 @@ Moran's I geostatistics (global clustering & outliers presence)
import pysal as ps import pysal as ps
import plpy import plpy
from collections import OrderedDict
# crankshaft module # crankshaft module
import crankshaft.pysal_utils as pu import crankshaft.pysal_utils as pu
@ -21,11 +22,11 @@ def moran(subquery, attr_name,
core clusters with PySAL. core clusters with PySAL.
Andy Eschbacher Andy Eschbacher
""" """
qvals = {"id_col": id_col, qvals = OrderedDict([("id_col", id_col),
"attr1": attr_name, ("attr1", attr_name),
"geom_col": geom_col, ("geom_col", geom_col),
"subquery": subquery, ("subquery", subquery),
"num_ngbrs": num_ngbrs} ("num_ngbrs", num_ngbrs)])
query = pu.construct_neighbor_query(w_type, qvals) query = pu.construct_neighbor_query(w_type, qvals)
@ -65,11 +66,11 @@ def moran_local(subquery, attr,
# geometries with attributes that are null are ignored # geometries with attributes that are null are ignored
# resulting in a collection of not as near neighbors # resulting in a collection of not as near neighbors
qvals = {"id_col": id_col, qvals = OrderedDict([("id_col", id_col),
"attr1": attr, ("attr1", attr_name),
"geom_col": geom_col, ("geom_col", geom_col),
"subquery": subquery, ("subquery", subquery),
"num_ngbrs": num_ngbrs} ("num_ngbrs", num_ngbrs)])
query = pu.construct_neighbor_query(w_type, qvals) query = pu.construct_neighbor_query(w_type, qvals)
@ -101,12 +102,12 @@ def moran_rate(subquery, numerator, denominator,
Moran's I Rate (global) Moran's I Rate (global)
Andy Eschbacher Andy Eschbacher
""" """
qvals = {"id_col": id_col, qvals = OrderedDict([("id_col", id_col),
"attr1": numerator, ("attr1", numerator),
"attr2": denominator, ("attr2", denominator)
"geom_col": geom_col, ("geom_col", geom_col),
"subquery": subquery, ("subquery", subquery),
"num_ngbrs": num_ngbrs} ("num_ngbrs", num_ngbrs)])
query = pu.construct_neighbor_query(w_type, qvals) query = pu.construct_neighbor_query(w_type, qvals)
@ -145,13 +146,14 @@ def moran_local_rate(subquery, numerator, denominator,
# geometries with values that are null are ignored # geometries with values that are null are ignored
# resulting in a collection of not as near neighbors # resulting in a collection of not as near neighbors
query = pu.construct_neighbor_query(w_type, qvals = OrderedDict([("id_col", id_col),
{"id_col": id_col, ("numerator", numerator),
"numerator": numerator, ("denominator", denominator),
"denominator": denominator, ("geom_col": geom_col),
"geom_col": geom_col, ("subquery", subquery),
"subquery": subquery, ("num_ngbrs", num_ngbrs)])
"num_ngbrs": num_ngbrs})
query = pu.construct_neighbor_query(w_type, qvals)
try: try:
result = plpy.execute(query) result = plpy.execute(query)
@ -186,12 +188,12 @@ def moran_local_bv(subquery, attr1, attr2,
""" """
plpy.notice('** Constructing query') plpy.notice('** Constructing query')
qvals = {"num_ngbrs": num_ngbrs, qvals = OrderedDict([("id_col", id_col),
"attr1": attr1, ("attr1", attr1),
"attr2": attr2, ("attr2", attr2),
"subquery": subquery, ("geom_col": geom_col),
"geom_col": geom_col, ("subquery", subquery),
"id_col": id_col} ("num_ngbrs", num_ngbrs)])
query = pu.construct_neighbor_query(w_type, qvals) query = pu.construct_neighbor_query(w_type, qvals)