more pep8 updates

This commit is contained in:
Andy Eschbacher 2016-09-21 15:57:49 -04:00
parent e924abbacc
commit 375f765531

View File

@ -50,7 +50,7 @@ def query_attr_select(params):
""" """
attr_string = "" attr_string = ""
template = "i.\"%(col)s\"::numeric As attr%(alias_num)s, " template = 'i."%(col)s"::numeric As attr%(alias_num)s, '
if 'time_cols' in params: if 'time_cols' in params:
# if markov analysis # if markov analysis
@ -90,7 +90,7 @@ def query_attr_where(params):
NULL AND idx_replace."time3" IS NOT NULL' NULL AND idx_replace."time3" IS NOT NULL'
""" """
attr_string = [] attr_string = []
template = "idx_replace.\"%s\" IS NOT NULL" template = 'idx_replace."%s" IS NOT NULL'
if 'time_cols' in params: if 'time_cols' in params:
# markov where clauses # markov where clauses
@ -110,7 +110,7 @@ def query_attr_where(params):
attr_string.append(template % params[attr]) attr_string.append(template % params[attr])
if len(attrs) == 2: if len(attrs) == 2:
attr_string.append("idx_replace.\"%s\" <> 0" % params[attrs[1]]) attr_string.append('idx_replace."%s" <> 0' % params[attrs[1]])
out = " AND ".join(attr_string) out = " AND ".join(attr_string)
@ -129,22 +129,23 @@ def knn(params):
"attr_where_i": attr_where.replace("idx_replace", "i"), "attr_where_i": attr_where.replace("idx_replace", "i"),
"attr_where_j": attr_where.replace("idx_replace", "j")} "attr_where_j": attr_where.replace("idx_replace", "j")}
query = "SELECT " \ query = '''
"i.\"{id_col}\" As id, " \ SELECT
"%(attr_select)s" \ i."{id_col}" As id,
"(SELECT ARRAY(SELECT j.\"{id_col}\" " \ %(attr_select)s
"FROM ({subquery}) As j " \ (SELECT ARRAY(SELECT j."{id_col}"
"WHERE " \ FROM ({subquery}) As j
"i.\"{id_col}\" <> j.\"{id_col}\" AND " \ WHERE
"%(attr_where_j)s " \ i."{id_col}" <> j."{id_col}" AND
"ORDER BY " \ %(attr_where_j)s
"j.\"{geom_col}\" <-> i.\"{geom_col}\" ASC " \ ORDER BY
"LIMIT {num_ngbrs})" \ j."{geom_col}" <-> i."{geom_col}" ASC
") As neighbors " \ LIMIT {num_ngbrs})
"FROM ({subquery}) As i " \ ) As neighbors
"WHERE " \ FROM ({subquery}) As i
"%(attr_where_i)s " \ WHERE %(attr_where_i)s
"ORDER BY i.\"{id_col}\" ASC;" % replacements ORDER BY i."{id_col}" ASC;
''' % replacements
return query.format(**params) return query.format(**params)
@ -161,19 +162,20 @@ def queen(params):
"attr_where_i": attr_where.replace("idx_replace", "i"), "attr_where_i": attr_where.replace("idx_replace", "i"),
"attr_where_j": attr_where.replace("idx_replace", "j")} "attr_where_j": attr_where.replace("idx_replace", "j")}
query = "SELECT " \ query = '''
"i.\"{id_col}\" As id, " \ SELECT
"%(attr_select)s" \ i."{id_col}" As id,
"(SELECT ARRAY(SELECT j.\"{id_col}\" " \ %(attr_select)s
"FROM ({subquery}) As j " \ (SELECT ARRAY(SELECT j."{id_col}"
"WHERE i.\"{id_col}\" <> j.\"{id_col}\" AND " \ FROM ({subquery}) As j
"ST_Touches(i.\"{geom_col}\", j.\"{geom_col}\") AND " \ WHERE i."{id_col}" <> j."{id_col}" AND
"%(attr_where_j)s)" \ ST_Touches(i."{geom_col}", j."{geom_col}") AND
") As neighbors " \ %(attr_where_j)s
"FROM ({subquery}) As i " \ ) As neighbors
"WHERE " \ FROM ({subquery}) As i
"%(attr_where_i)s " \ WHERE %(attr_where_i)s
"ORDER BY i.\"{id_col}\" ASC;" % replacements ORDER BY i."{id_col}" ASC;
''' % replacements
return query.format(**params) return query.format(**params)