rename queryrunner in tests

This commit is contained in:
Andy Eschbacher 2016-11-22 09:57:47 -05:00
parent 280a5193ef
commit 6fe4fc9668
3 changed files with 13 additions and 13 deletions

View File

@ -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]

View File

@ -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')

View File

@ -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',