From a6440f2ef7d98c7f2477806b9c8ce5efb9b165b8 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 16:39:35 -0400 Subject: [PATCH 1/4] reports error string --- .../crankshaft/crankshaft/clustering/moran.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 3282f5f..a524892 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -38,10 +38,9 @@ def moran(subquery, attr_name, if len(result) == 0: return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(2) ## collect attributes @@ -79,8 +78,8 @@ def moran_local(subquery, attr, # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(5) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) @@ -119,10 +118,9 @@ def moran_rate(subquery, numerator, denominator, if len(result) == 0: return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(2) ## collect attributes @@ -160,10 +158,9 @@ def moran_local_rate(subquery, numerator, denominator, # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(5) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(5) ## collect attributes From feab6f177e44eea131f421345505431ee756e414 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 17:52:41 -0400 Subject: [PATCH 2/4] clearer error message --- src/py/crankshaft/crankshaft/clustering/moran.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index a524892..8c5d909 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -39,7 +39,7 @@ def moran(subquery, attr_name, return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) @@ -79,7 +79,7 @@ def moran_local(subquery, attr, if len(result) == 0: return pu.empty_zipped_array(5) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) @@ -119,7 +119,7 @@ def moran_rate(subquery, numerator, denominator, return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) @@ -159,7 +159,7 @@ def moran_local_rate(subquery, numerator, denominator, if len(result) == 0: return pu.empty_zipped_array(5) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) From 6d6d7ef2ba56af7fa7cff77c4c25f2f59602ab9b Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 17:58:19 -0400 Subject: [PATCH 3/4] removing notices --- src/py/crankshaft/crankshaft/clustering/moran.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 8c5d909..7a97233 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -30,17 +30,13 @@ def moran(subquery, attr_name, query = pu.construct_neighbor_query(w_type, qvals) - plpy.notice('** Query: %s' % query) - try: result = plpy.execute(query) # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(2) - plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) ## collect attributes @@ -80,7 +76,6 @@ def moran_local(subquery, attr, return pu.empty_zipped_array(5) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) attr_vals = pu.get_attributes(result) @@ -110,17 +105,13 @@ def moran_rate(subquery, numerator, denominator, query = pu.construct_neighbor_query(w_type, qvals) - plpy.notice('** Query: %s' % query) - try: result = plpy.execute(query) # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(2) - plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) ## collect attributes @@ -160,7 +151,6 @@ def moran_local_rate(subquery, numerator, denominator, return pu.empty_zipped_array(5) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) ## collect attributes @@ -183,7 +173,6 @@ def moran_local_bv(subquery, attr1, attr2, """ Moran's I (local) Bivariate (untested) """ - plpy.notice('** Constructing query') qvals = OrderedDict([("id_col", id_col), ("attr1", attr1), @@ -202,7 +191,6 @@ def moran_local_bv(subquery, attr1, attr2, except plpy.SPIError: plpy.error("Error: areas of interest query failed, " \ "check input parameters") - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(4) ## collect attributes @@ -216,13 +204,9 @@ def moran_local_bv(subquery, attr1, attr2, lisa = ps.esda.moran.Moran_Local_BV(attr1_vals, attr2_vals, weight, permutations=permutations) - plpy.notice("len of Is: %d" % len(lisa.Is)) - # find clustering of significance lisa_sig = quad_position(lisa.q) - plpy.notice('** Finished calculations') - return zip(lisa.Is, lisa_sig, lisa.p_sim, weight.id_order) # Low level functions ---------------------------------------- From c229a8549101a127fa0abdcdde6c53833874d00a Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 18:02:56 -0400 Subject: [PATCH 4/4] adding better reporting to markov --- src/py/crankshaft/crankshaft/space_time_dynamics/markov.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py index bbf524d..ae788d7 100644 --- a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py +++ b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py @@ -56,9 +56,9 @@ def spatial_markov_trend(subquery, time_cols, num_classes=7, ) if len(query_result) == 0: return zip([None], [None], [None], [None], [None]) - except plpy.SPIError, err: + except plpy.SPIError, e: plpy.debug('Query failed with exception %s: %s' % (err, pu.construct_neighbor_query(w_type, qvals))) - plpy.error('Query failed, check the input parameters') + plpy.error('Analysis failed: %s' % e) return zip([None], [None], [None], [None], [None]) ## build weight