From 3013998e1b64d4688bd3fec8a4cf23980e50efe5 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Wed, 1 Jun 2016 12:19:08 -0400 Subject: [PATCH] make functions more flexible to case of weight type --- src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py b/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py index fa06e26..02b5e35 100644 --- a/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py +++ b/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py @@ -11,7 +11,7 @@ def construct_neighbor_query(w_type, query_vals): @param query_vals dict: values used to construct the query """ - if w_type == 'knn': + if w_type.lower() == 'knn': return knn(query_vals) else: return queen(query_vals) @@ -22,7 +22,7 @@ def get_weight(query_res, w_type='knn', num_ngbrs=5): Construct PySAL weight from return value of query @param query_res: query results with attributes and neighbors """ - if w_type == 'knn': + if w_type.lower() == 'knn': row_normed_weights = [1.0 / float(num_ngbrs)] * num_ngbrs weights = {x['id']: row_normed_weights for x in query_res} else: