# Path: bamboo/tests/core/test_calculator.py
# class TestCalculator(TestBase):
# 
#     def setUp(self):
#         TestBase.setUp(self)
#         self.dataset = Dataset()
#         self.dataset.save(
#             self.test_dataset_ids['good_eats_with_calculations.csv'])
#         dframe = recognize_dates(
#             self.get_data('good_eats_with_calculations.csv'))
#         self.dataset.save_observations(dframe)
#         self.group = None
#         self.places = 5
# 
#     def _equal_msg(self, calculated, stored, formula):
#         return '(calculated %s) %s != (stored %s) %s ' % (type(calculated),
#                calculated, type(stored), stored) +\
#             '(within %s places), formula: %s' % (self.places, formula)
# 
#     def _test_calculator(self):
#         self.dframe = self.dataset.dframe()
# 
#         columns = self.dframe.columns.tolist()
#         self.start_num_cols = len(columns)
#         self.added_num_cols = 0
# 
#         column_labels_to_slugs = {
#             column_attrs[Dataset.LABEL]: (column_name) for
#             (column_name, column_attrs) in self.dataset.schema.items()
#         }
#         self.label_list, self.slugified_key_list = [
#             list(ary) for ary in zip(*column_labels_to_slugs.items())
#         ]
# 
#         for idx, formula in enumerate(self.calculations):
#             name = 'test-%s' % idx
# 
#             Parser.validate_formula(formula, self.dataset)
# 
#             calculation = Calculation()
#             calculation.save(self.dataset, formula, name, self.group)
#             self.now = now()
#             calculate_columns(self.dataset, [calculation])
# 
#             self.column_labels_to_slugs = self.dataset.schema.labels_to_slugs
# 
#             self._test_calculation_results(name, formula)


from collections import defaultdict
from bamboo.tests.core.test_calculator import TestCalculator
import pickle
import numpy as np




AGG_CALCS_TO_DEPS = {
    'pearson(gps_latitude, amount)': ['gps_latitude', 'amount'],
    'var(amount)': ['amount'],
    'std(amount)': ['amount'],
    'max(amount)': ['amount'],
    'mean(amount)': ['amount'],
    'median(amount)': ['amount'],
    'min(amount)': ['amount'],
    'sum(amount)': ['amount'],
    'sum(gps_latitude)': ['gps_latitude'],
    'ratio(amount, gps_latitude)': ['amount', 'gps_latitude'],
    'sum(risk_factor in ["low_risk"])': ['risk_factor'],
    'ratio(risk_factor in ["low_risk"], risk_factor in ["low_risk",'
    ' "medium_risk"])': ['risk_factor'],
    'ratio(risk_factor in ["low_risk"], 1)': ['risk_factor'],
    'count(risk_factor in ["low_risk"])': ['risk_factor'],
    'count()': [],
    'argmax(submit_date)': ['submit_date'],
    'newest(submit_date, amount)': ['amount', 'submit_date'],
}



# Path: bamboo/tests/core/test_calculator.py
# class TestCalculator(TestBase):
# 
#     def setUp(self):
#         TestBase.setUp(self)
#         self.dataset = Dataset()
#         self.dataset.save(
#             self.test_dataset_ids['good_eats_with_calculations.csv'])
#         dframe = recognize_dates(
#             self.get_data('good_eats_with_calculations.csv'))
#         self.dataset.save_observations(dframe)
#         self.group = None
#         self.places = 5
# 
#     def _equal_msg(self, calculated, stored, formula):
#         return '(calculated %s) %s != (stored %s) %s ' % (type(calculated),
#                calculated, type(stored), stored) +\
#             '(within %s places), formula: %s' % (self.places, formula)
# 
#     def _test_calculator(self):
#         self.dframe = self.dataset.dframe()
# 
#         columns = self.dframe.columns.tolist()
#         self.start_num_cols = len(columns)
#         self.added_num_cols = 0
# 
#         column_labels_to_slugs = {
#             column_attrs[Dataset.LABEL]: (column_name) for
#             (column_name, column_attrs) in self.dataset.schema.items()
#         }
#         self.label_list, self.slugified_key_list = [
#             list(ary) for ary in zip(*column_labels_to_slugs.items())
#         ]
# 
#         for idx, formula in enumerate(self.calculations):
#             name = 'test-%s' % idx
# 
#             Parser.validate_formula(formula, self.dataset)
# 
#             calculation = Calculation()
#             calculation.save(self.dataset, formula, name, self.group)
#             self.now = now()
#             calculate_columns(self.dataset, [calculation])
# 
#             self.column_labels_to_slugs = self.dataset.schema.labels_to_slugs
# 
#             self._test_calculation_results(name, formula)


# Path: bamboo/tests/core/test_aggregations.py
from collections import defaultdict
from bamboo.tests.core.test_calculator import TestCalculator
import pickle
import numpy as np





AGG_CALCS_TO_DEPS = {
    'pearson(gps_latitude, amount)': ['gps_latitude', 'amount'],
    'var(amount)': ['amount'],
    'std(amount)': ['amount'],
    'max(amount)': ['amount'],
    'mean(amount)': ['amount'],
    'median(amount)': ['amount'],
    'min(amount)': ['amount'],
    'sum(amount)': ['amount'],
    'sum(gps_latitude)': ['gps_latitude'],
    'ratio(amount, gps_latitude)': ['amount', 'gps_latitude'],
    'sum(risk_factor in ["low_risk"])': ['risk_factor'],
    'ratio(risk_factor in ["low_risk"], risk_factor in ["low_risk",'
    ' "medium_risk"])': ['risk_factor'],
    'ratio(risk_factor in ["low_risk"], 1)': ['risk_factor'],
    'count(risk_factor in ["low_risk"])': ['risk_factor'],
    'count()': [],
    'argmax(submit_date)': ['submit_date'],
    'newest(submit_date, amount)': ['amount', 'submit_date'],
}



class TestAggregations(TestCalculator):