# 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 order import ExploreOrder
from utility.datafilepath import g_singletonDataFilePath
from visualization import visualizeData
from utility.dumpload import DumpLoad
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import pandas as pd
#             plt.ylabel('Gap')
#             plt.xlabel('POI')
#             count += 1
        
       
#         plt.title('POI/Gap Correlation')
        return
    def disp_district_by_district_type(self):
        df = self.get_district_type_table()
        dt_list = self.get_district_type_list()
        size = df.shape[0]
        col_len = 8
        row_len = 8
        
        _, axarr = plt.subplots(row_len, col_len, sharex=True, sharey=True)
        for row in range(row_len):
            for col in range(col_len):
                index = row * col_len + col
                if index >= size:
                    break
                item = df.iloc[index]
                x_locations = np.arange(len(dt_list))
                axarr[row, col].bar(x_locations, item[dt_list])
                axarr[row, col].set_xlabel('start_district_' + str(item['start_district_id']))
        return
    
    def disp_gap_bytraffic(self):
        df = self.gapdf
        data_dir = g_singletonDataFilePath.getTrainDir()
        dumpfile_path = '../data_preprocessed/' + data_dir.split('/')[-2] + '_prevtraffic.df.pickle'

# 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/visualize_traindata.py
from order import ExploreOrder
from utility.datafilepath import g_singletonDataFilePath
from visualization import visualizeData
from utility.dumpload import DumpLoad
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import math
import pandas as pd

#             plt.ylabel('Gap')
#             plt.xlabel('POI')
#             count += 1
        
       
#         plt.title('POI/Gap Correlation')
        return
    def disp_district_by_district_type(self):
        df = self.get_district_type_table()
        dt_list = self.get_district_type_list()
        size = df.shape[0]
        col_len = 8
        row_len = 8
        
        _, axarr = plt.subplots(row_len, col_len, sharex=True, sharey=True)
        for row in range(row_len):
            for col in range(col_len):
                index = row * col_len + col
                if index >= size:
                    break
                item = df.iloc[index]
                x_locations = np.arange(len(dt_list))
                axarr[row, col].bar(x_locations, item[dt_list])
                axarr[row, col].set_xlabel('start_district_' + str(item['start_district_id']))
        return
    
    def disp_gap_bytraffic(self):
        df = self.gapdf
        data_dir = g_singletonDataFilePath.getTrainDir()
        dumpfile_path = '../data_preprocessed/' + data_dir.split('/')[-2] + '_prevtraffic.df.pickle'

        dumpload = DumpLoad(dumpfile_path)