diff --git a/src/py/crankshaft/test/test_clustering_kmeans.py b/src/py/crankshaft/test/test_clustering_kmeans.py index 879dab7..04f99f6 100644 --- a/src/py/crankshaft/test/test_clustering_kmeans.py +++ b/src/py/crankshaft/test/test_clustering_kmeans.py @@ -9,7 +9,7 @@ import numpy as np # sys.modules['plpy'] = plpy from helper import fixture_file from crankshaft.clustering import Kmeans -from crankshaft.query_runner import QueryRunner +from crankshaft.analysis_data_provider import AnalysisDataProvider import crankshaft.clustering as cc from crankshaft import random_seeds @@ -17,11 +17,11 @@ import json from collections import OrderedDict -class FakeQueryRunner(QueryRunner): +class FakeDataProvider(AnalysisDataProvider): def __init__(self, mocked_result): self.mocked_result = mocked_result - def get_spatial_kmeans(self, query): + def get_spatial_kmeans(self, w_type, params): return self.mocked_result def get_nonspatial_kmeans(self, query, standarize): @@ -45,7 +45,7 @@ class KMeansTest(unittest.TestCase): 'ids': d['ids']} for d in self.cluster_data] random_seeds.set_random_seeds(1234) - kmeans = Kmeans(FakeQueryRunner(data)) + kmeans = Kmeans(FakeDataProvider(data)) clusters = kmeans.spatial('subquery', 2) labels = [a[1] for a in clusters] c1 = [a for a in clusters if a[1] == 0] diff --git a/src/py/crankshaft/test/test_clustering_moran.py b/src/py/crankshaft/test/test_clustering_moran.py index 37cf7d0..5c8c5c9 100644 --- a/src/py/crankshaft/test/test_clustering_moran.py +++ b/src/py/crankshaft/test/test_clustering_moran.py @@ -3,18 +3,18 @@ import numpy as np from helper import fixture_file from crankshaft.clustering import Moran -from crankshaft.clustering import QueryRunner +from crankshaft.clustering import AnalysisDataProvider import crankshaft.pysal_utils as pu from crankshaft import random_seeds import json from collections import OrderedDict -class FakeQueryRunner(QueryRunner): +class FakeDataProvider(AnalysisDataProvider): def __init__(self, mock_data): self.mock_result = mock_data - def get_moran(self, query): + def get_moran(self, w_type, params): return self.mock_result @@ -67,7 +67,7 @@ class MoranTest(unittest.TestCase): ('neighbors', d['neighbors'])]) for d in self.neighbors_data] - moran = Moran(FakeQueryRunner(data)) + moran = Moran(FakeDataProvider(data)) random_seeds.set_random_seeds(1234) result = moran.local_stat('subquery', 'value', 'knn', 5, 99, 'the_geom', 'cartodb_id') @@ -86,7 +86,7 @@ class MoranTest(unittest.TestCase): 'neighbors': d['neighbors']} for d in self.neighbors_data] random_seeds.set_random_seeds(1234) - moran = Moran(FakeQueryRunner(data)) + moran = Moran(FakeDataProvider(data)) result = moran.local_rate_stat('subquery', 'numerator', 'denominator', 'knn', 5, 99, 'the_geom', 'cartodb_id') result = [(row[0], row[1]) for row in result] @@ -102,7 +102,7 @@ class MoranTest(unittest.TestCase): 'attr1': d['value'], 'neighbors': d['neighbors']} for d in self.neighbors_data] random_seeds.set_random_seeds(1235) - moran = Moran(FakeQueryRunner(data)) + moran = Moran(FakeDataProvider(data)) result = moran.global_stat('table', 'value', 'knn', 5, 99, 'the_geom', 'cartodb_id') diff --git a/src/py/crankshaft/test/test_space_time_dynamics.py b/src/py/crankshaft/test/test_space_time_dynamics.py index e58c7d4..20e659c 100644 --- a/src/py/crankshaft/test/test_space_time_dynamics.py +++ b/src/py/crankshaft/test/test_space_time_dynamics.py @@ -9,11 +9,11 @@ from helper import fixture_file from crankshaft.space_time_dynamics import Markov import crankshaft.space_time_dynamics as std from crankshaft import random_seeds -from crankshaft.query_runner import QueryRunner +from crankshaft.analysis_data_provider import AnalysisDataProvider import json -class FakeQueryRunner(QueryRunner): +class FakeDataProvider(AnalysisDataProvider): def __init__(self, data): self.mock_result = data @@ -85,7 +85,7 @@ class SpaceTimeTests(unittest.TestCase): 'attr15': d['y2009'], 'neighbors': d['neighbors']} for d in self.neighbors_data] # print(str(data[0])) - markov = Markov(FakeQueryRunner(data)) + markov = Markov(FakeDataProvider(data)) random_seeds.set_random_seeds(1234) result = markov.spatial_trend('subquery',