From ccccf680662446974d7c71a14965baaac0b09d40 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Mon, 12 Sep 2016 11:39:21 -0400 Subject: [PATCH] fix module call --- src/pg/sql/16_getis.sql | 13 ++++++------- src/py/crankshaft/crankshaft/clustering/getis.py | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pg/sql/16_getis.sql b/src/pg/sql/16_getis.sql index 37f288b..23547f1 100644 --- a/src/pg/sql/16_getis.sql +++ b/src/pg/sql/16_getis.sql @@ -4,13 +4,12 @@ CREATE OR REPLACE FUNCTION CDB_GetisOrdsG( subquery TEXT, column_name TEXT, - w_type TEXT, - num_ngbrs INT, - permutations INT, - geom_col TEXT, - id_col TEXT) + w_type TEXT DEFAULT 'knn', + num_ngbrs INT DEFAULT 5, + geom_col TEXT DEFAULT 'the_geom', + id_col TEXT DEFAULT 'cartodb_id') RETURNS TABLE (z_val NUMERIC, p_val NUMERIC, rowid BIGINT) AS $$ - from crankshaft.clustering import getis - return getis_ord(subquery, column_name, w_type, num_ngbrs, permutations, geom_col, id_col) + from crankshaft.clustering import getis_ord + return getis_ord(subquery, column_name, w_type, num_ngbrs, geom_col, id_col) $$ LANGUAGE plpythonu; diff --git a/src/py/crankshaft/crankshaft/clustering/getis.py b/src/py/crankshaft/crankshaft/clustering/getis.py index 29a2c50..8cbbd56 100644 --- a/src/py/crankshaft/crankshaft/clustering/getis.py +++ b/src/py/crankshaft/crankshaft/clustering/getis.py @@ -15,7 +15,7 @@ import crankshaft.pysal_utils as pu # High level interface --------------------------------------- def getis_ord(subquery, attr, - w_type, num_ngbrs, permutations, geom_col, id_col): + w_type, num_ngbrs, geom_col, id_col): """ Getis-Ord's G Implementation building neighbors with a PostGIS database and Getis-Ord's G @@ -39,13 +39,13 @@ def getis_ord(subquery, attr, # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(3) - except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + except plpy.SPIError, err: + plpy.error('Query failed: %s' % err) attr_vals = pu.get_attributes(result) weight = pu.get_weight(result, w_type, num_ngbrs) # calculate LISA values - getis = ps.esda.getisord(attr_vals, weight, star=True) + getis = ps.esda.getisord.G_Local(attr_vals, weight, star=True) return zip(getis.z_sim, getis.p_sim, weight.id_order)