diff --git a/src/py/crankshaft/crankshaft/__init__.py b/src/py/crankshaft/crankshaft/__init__.py index a03b040..a8060f8 100644 --- a/src/py/crankshaft/crankshaft/__init__.py +++ b/src/py/crankshaft/crankshaft/__init__.py @@ -3,4 +3,4 @@ import crankshaft.random_seeds import crankshaft.clustering import crankshaft.space_time_dynamics import crankshaft.segmentation -import query_runner +import analysis_data_provider diff --git a/src/py/crankshaft/crankshaft/query_runner.py b/src/py/crankshaft/crankshaft/analysis_data_provider.py similarity index 97% rename from src/py/crankshaft/crankshaft/query_runner.py rename to src/py/crankshaft/crankshaft/analysis_data_provider.py index 5775e72..ad572ec 100644 --- a/src/py/crankshaft/crankshaft/query_runner.py +++ b/src/py/crankshaft/crankshaft/analysis_data_provider.py @@ -2,7 +2,7 @@ import plpy -class QueryRunner: +class AnalysisDataProvider: def get_markov(self, query): try: data = plpy.execute(query) diff --git a/src/py/crankshaft/crankshaft/clustering/kmeans.py b/src/py/crankshaft/crankshaft/clustering/kmeans.py index 200dc52..e59c25b 100644 --- a/src/py/crankshaft/crankshaft/clustering/kmeans.py +++ b/src/py/crankshaft/crankshaft/clustering/kmeans.py @@ -1,15 +1,15 @@ from sklearn.cluster import KMeans import numpy as np -from crankshaft.query_runner import QueryRunner +from crankshaft.analysis_data_provider import AnalysisDataProvider class Kmeans: - def __init__(self, query_runner=None): - if query_runner is None: - self.query_runner = QueryRunner() + def __init__(self, data_provider=None): + if data_provider is None: + self.data_provider = AnalysisDataProvider() else: - self.query_runner = query_runner + self.data_provider = data_provider def spatial(self, query, no_clusters, no_init=20): """ @@ -23,7 +23,7 @@ class Kmeans: "FROM ({query}) As a " "WHERE the_geom IS NOT NULL").format(query=query) - data = self.query_runner.get_spatial_kmeans(full_query) + data = self.data_provider.get_spatial_kmeans(full_query) # Unpack query response xs = data[0]['xs'] diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index d2c99d6..7cc9ba5 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -8,7 +8,7 @@ Moran's I geostatistics (global clustering & outliers presence) import pysal as ps import plpy from collections import OrderedDict -from crankshaft.query_runner import QueryRunner +from crankshaft.analysis_data_provider import AnalysisDataProvider # crankshaft module import crankshaft.pysal_utils as pu @@ -17,11 +17,11 @@ import crankshaft.pysal_utils as pu class Moran: - def __init__(self, query_runner=None): - if query_runner is None: - self.query_runner = QueryRunner() + def __init__(self, data_provider=None): + if data_provider is None: + self.data_provider = AnalysisDataProvider() else: - self.query_runner = query_runner + self.data_provider = data_provider def global_stat(self, subquery, attr_name, w_type, num_ngbrs, permutations, geom_col, id_col): @@ -39,7 +39,7 @@ class Moran: query = pu.construct_neighbor_query(w_type, qvals) - result = self.query_runner.get_moran(query) + result = self.data_provider.get_moran(query) # collect attributes attr_vals = pu.get_attributes(result) @@ -71,7 +71,7 @@ class Moran: query = pu.construct_neighbor_query(w_type, qvals) - result = self.query_runner.get_moran(query) + result = self.data_provider.get_moran(query) attr_vals = pu.get_attributes(result) weight = pu.get_weight(result, w_type, num_ngbrs) @@ -100,7 +100,7 @@ class Moran: query = pu.construct_neighbor_query(w_type, qvals) - result = self.query_runner.get_moran(query) + result = self.data_provider.get_moran(query) # collect attributes numer = pu.get_attributes(result, 1) @@ -132,7 +132,7 @@ class Moran: query = pu.construct_neighbor_query(w_type, qvals) - result = self.query_runner.get_moran(query) + result = self.data_provider.get_moran(query) # collect attributes numer = pu.get_attributes(result, 1) @@ -165,7 +165,7 @@ class Moran: query = pu.construct_neighbor_query(w_type, qvals) - result = self.query_runner.get_moran(query) + result = self.data_provider.get_moran(query) # collect attributes attr1_vals = pu.get_attributes(result, 1) diff --git a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py index ea8dd32..51db0ef 100644 --- a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py +++ b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py @@ -7,15 +7,15 @@ import numpy as np import pysal as ps import plpy import crankshaft.pysal_utils as pu -from crankshaft.query_runner import QueryRunner +from crankshaft.analysis_data_provider import AnalysisDataProvider class Markov: - def __init__(self, query_runner=None): - if query_runner is None: - self.query_runner = QueryRunner() + def __init__(self, data_provider=None): + if data_provider is None: + self.data_provider = AnalysisDataProvider() else: - self.query_runner = query_runner + self.data_provider = data_provider def spatial_trend(self, subquery, time_cols, num_classes=7, w_type='knn', num_ngbrs=5, permutations=0, @@ -62,7 +62,7 @@ class Markov: query = pu.construct_neighbor_query(w_type, qvals) - query_result = self.query_runner.get_markov(query) + query_result = self.data_provider.get_markov(query) # build weight weights = pu.get_weight(query_result, w_type)