# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):
# 
# Path: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


from utility.datafilepath import g_singletonDataFilePath
from timeslot import singletonTimeslot
from exploredata import ExploreData
from time import time
from utility.dumpload import DumpLoad
from  districtid import singletonDistricId
import pandas as pd
import os


class ExploreTraffic(ExploreData ):
    def __init__(self):
        return
    def run(self):
#         self.__unittest()
        data_dir = g_singletonDataFilePath.getTest2Dir()
#         self.save_all_csv(data_dir+ 'traffic_data/')
#         self.combine_all_csv(data_dir + 'traffic_data/temp/', 'traffic_', 'traffic.csv')
        self.get_traffic_dict(data_dir)
        return
    def __unittest(self):
        #         self.combine_all_csv(g_singletonDataFilePath.getTrainDir() + 'weather_data/temp/', 'weather_', 'weather.csv')
#         self.save_one_csv(g_singletonDataFilePath.getTrainDir() + 'traffic_data/traffic_data_2016-01-04')
#         weatherdf = self.load_weatherdf(g_singletonDataFilePath.getTrainDir())
        data_dir = g_singletonDataFilePath.getTrainDir()
        traffic_dict = self.get_traffic_dict(data_dir)
        assert [0,0,0] == self.find_prev_traffic(pd.Series([1, '2016-01-01-2']), traffic_dict=traffic_dict,pre_num = 3).tolist()
        assert [2246,2081] == self.find_prev_traffic(pd.Series([1, '2016-01-01-9']), traffic_dict=traffic_dict,pre_num = 2).tolist()
        

# Path: utility/datafilepath.py
# class DataFilePath:
#     def __init__(self):
#     def getOrderDir_Train(self):  
#     def getOrderDir_Test1(self):  
#     def getTest1Dir(self):
#     def getTest2Dir(self):
#     def getTrainDir(self):
#     def getGapCsv_Train(self):
#     def getGapCsv_Test1(self):
#     def getTestset1Readme(self):
#     def getTestset2Readme(self):
#     def getGapFilename(self):
#     def getGapPredictionFileName(self):
#     def getPrevGapFileName(self):
#     def get_dir_name(self, data_dir):
# 
# Path: utility/dumpload.py
# class DumpLoad:
#     def __init__(self, pickle_filepath):
#         self.pickle_filepath = pickle_filepath
#         dir_path = os.path.dirname(pickle_filepath)
#         if not os.path.exists(dir_path):
#             os.makedirs(dir_path)
#         
#         return
#     def load(self):
#         with open(self.pickle_filepath, 'rb') as handle:
#             dataset = pickle.load(handle)
#         return dataset
#     def isExisiting(self):
#         return os.path.exists(self.pickle_filepath) 
#     def run(self):
#         self.dump((np.arange(10), np.arange(20)))
#         print(self.load())
#         return
#     
#     def dump(self, dataset):
#         with open(self.pickle_filepath, 'wb') as f:
#             pickle.dump(dataset, f, pickle.HIGHEST_PROTOCOL)
#         return


# Path: exploredata/traffic.py
from utility.datafilepath import g_singletonDataFilePath
from timeslot import singletonTimeslot
from exploredata import ExploreData
from time import time
from utility.dumpload import DumpLoad
from  districtid import singletonDistricId
import pandas as pd
import os



class ExploreTraffic(ExploreData ):
    def __init__(self):
        return
    def run(self):
#         self.__unittest()
        data_dir = g_singletonDataFilePath.getTest2Dir()
#         self.save_all_csv(data_dir+ 'traffic_data/')
#         self.combine_all_csv(data_dir + 'traffic_data/temp/', 'traffic_', 'traffic.csv')
        self.get_traffic_dict(data_dir)
        return
    def __unittest(self):
        #         self.combine_all_csv(g_singletonDataFilePath.getTrainDir() + 'weather_data/temp/', 'weather_', 'weather.csv')
#         self.save_one_csv(g_singletonDataFilePath.getTrainDir() + 'traffic_data/traffic_data_2016-01-04')
#         weatherdf = self.load_weatherdf(g_singletonDataFilePath.getTrainDir())
        data_dir = g_singletonDataFilePath.getTrainDir()
        traffic_dict = self.get_traffic_dict(data_dir)
        assert [0,0,0] == self.find_prev_traffic(pd.Series([1, '2016-01-01-2']), traffic_dict=traffic_dict,pre_num = 3).tolist()
        assert [2246,2081] == self.find_prev_traffic(pd.Series([1, '2016-01-01-9']), traffic_dict=traffic_dict,pre_num = 2).tolist()
        

        data_dir = g_singletonDataFilePath.getTest1Dir()