From b399e883ad4ad1e048573b408a99b8505b6e08ab Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Mon, 28 Nov 2016 20:10:51 +0000 Subject: [PATCH] fix paths; fix query --- src/pg/sql/21_gwr.sql | 4 ++-- src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py | 2 +- .../crankshaft/crankshaft/regression/{gwr.py => gwr_cs.py} | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) rename src/py/crankshaft/crankshaft/regression/{gwr.py => gwr_cs.py} (92%) diff --git a/src/pg/sql/21_gwr.sql b/src/pg/sql/21_gwr.sql index 59d62c1..2045792 100644 --- a/src/pg/sql/21_gwr.sql +++ b/src/pg/sql/21_gwr.sql @@ -4,8 +4,8 @@ CDB_GWR(subquery text, dep_var text, ind_vars text[], RETURNS table(v1 numeric, v2 numeric, v3 numeric, v4 numeric, v5 numeric, v6 numeric, rowid bigint) AS $$ -from crankshaft.regression import gwr +from crankshaft.regression import gwr_cs -return gwr(subquery, dep_var, ind_vars, fixed, kernel) +return gwr_cs.gwr(subquery, dep_var, ind_vars, fixed, kernel) $$ LANGUAGE plpythonu; diff --git a/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py b/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py index 1925cdb..a67db95 100644 --- a/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py +++ b/src/py/crankshaft/crankshaft/pysal_utils/pysal_utils.py @@ -202,7 +202,7 @@ def gwr_query(params): array_agg(ST_X({geom_col})) As x, array_agg(ST_Y({geom_col})) As y, array_agg({dep_var}) As dep_var, - %(ind_vars_select)s, + %(ind_vars_select)s array_agg({id_col}) As rowid FROM ({subquery}) As q WHERE diff --git a/src/py/crankshaft/crankshaft/regression/gwr.py b/src/py/crankshaft/crankshaft/regression/gwr_cs.py similarity index 92% rename from src/py/crankshaft/crankshaft/regression/gwr.py rename to src/py/crankshaft/crankshaft/regression/gwr_cs.py index 44a5091..950c9bb 100644 --- a/src/py/crankshaft/crankshaft/regression/gwr.py +++ b/src/py/crankshaft/crankshaft/regression/gwr_cs.py @@ -1,6 +1,8 @@ import numpy as np from gwr.base.gwr import GWR from gwr.base.sel_bw import Sel_BW +import plpy +import crankshaft.pysal_utils as pu def gwr(subquery, dep_var, ind_vars, @@ -22,8 +24,11 @@ def gwr(subquery, dep_var, ind_vars, 'ind_vars': ind_vars} try: - query_result = plpy.execute(pu.gwr_query(params)) + query = pu.gwr_query(params) + plpy.notice(query) + query_result = plpy.execute(query) except plpy.SPIError, err: + plpy.notice(query) plpy.error('Analysis failed: %s' % err) # TODO: should x, y be centroids? point on surface?