# Path: nilmtk/tests/testingtools.py
# def data_dir():
#     # Taken from http://stackoverflow.com/a/6098238/732596
#     current_file_path = os.path.dirname(inspect.getfile(inspect.currentframe()))
#     data_dir = os.path.join(current_file_path, '..', '..', 'data')
#     data_dir = os.path.abspath(data_dir)
#     assert os.path.isdir(data_dir), data_dir + " does not exist."
#     return data_dir
# 
# Path: nilmtk/measurement.py
# def measurement_columns(column_tuples):
#     """
#     Parameters
#     ----------
#     column_tuples : list of 2-tuples
#     
#     Returns
#     -------
#     pd.MultiIndex
#     """
#     for physical_quantity, ac_type in column_tuples:
#         check_physical_quantity(physical_quantity)
#         if physical_quantity in ['energy', 'cumulative energy', 'power']:
#             check_ac_type(ac_type)
#     return pd.MultiIndex.from_tuples(column_tuples, names=LEVEL_NAMES)
# 
# AC_TYPES = ['active', 'apparent', 'reactive']
# 
# Path: nilmtk/utils.py
# def flatten_2d_list(list2d):
#     list1d = []
#     for item in list2d:
#         if isinstance(item, str):
#             list1d.append(item)
#         else:
#             try:
#                 len(item)
#             except TypeError:
#                 list1d.append(item)
#             else:
#                 list1d.extend(item)
#     return list1d


import pandas as pd
import itertools
import numpy as np
from datetime import timedelta
from nilmtk.tests.testingtools import data_dir
from os.path import join
from collections import OrderedDict
from nilmtk.consts import JOULES_PER_KWH
from nilmtk.measurement import measurement_columns, AC_TYPES
from nilmtk.utils import flatten_2d_list
    elec_meter_metadata = {}
    for meter in range(1, N_METERS + 1):
        key = 'building1/elec/meter{:d}'.format(meter)
        print("Saving", key)
        store.put(key, dfs[meter], format='table')
        elec_meter_metadata[meter] = {
            'device_model': TEST_METER['model'],
            'submeter_of': 1,
            'data_location': key
        }

    # For mains meter, we need to specify that it is a site meter
    del elec_meter_metadata[1]['submeter_of']
    elec_meter_metadata[1]['site_meter'] = True

    # Save dataset-wide metadata
    store.root._v_attrs.metadata = {
        'meter_devices': {TEST_METER['model']: TEST_METER}}
    print(store.root._v_attrs.metadata)

    # Building metadata
    add_building_metadata(store, elec_meter_metadata)
    for key in store.keys():
        print(store[key])

    store.flush()
    store.close()


def create_random_hdf5():

# Path: nilmtk/tests/testingtools.py
# def data_dir():
#     # Taken from http://stackoverflow.com/a/6098238/732596
#     current_file_path = os.path.dirname(inspect.getfile(inspect.currentframe()))
#     data_dir = os.path.join(current_file_path, '..', '..', 'data')
#     data_dir = os.path.abspath(data_dir)
#     assert os.path.isdir(data_dir), data_dir + " does not exist."
#     return data_dir
# 
# Path: nilmtk/measurement.py
# def measurement_columns(column_tuples):
#     """
#     Parameters
#     ----------
#     column_tuples : list of 2-tuples
#     
#     Returns
#     -------
#     pd.MultiIndex
#     """
#     for physical_quantity, ac_type in column_tuples:
#         check_physical_quantity(physical_quantity)
#         if physical_quantity in ['energy', 'cumulative energy', 'power']:
#             check_ac_type(ac_type)
#     return pd.MultiIndex.from_tuples(column_tuples, names=LEVEL_NAMES)
# 
# AC_TYPES = ['active', 'apparent', 'reactive']
# 
# Path: nilmtk/utils.py
# def flatten_2d_list(list2d):
#     list1d = []
#     for item in list2d:
#         if isinstance(item, str):
#             list1d.append(item)
#         else:
#             try:
#                 len(item)
#             except TypeError:
#                 list1d.append(item)
#             else:
#                 list1d.extend(item)
#     return list1d


# Path: nilmtk/tests/generate_data.py
import pandas as pd
import itertools
import numpy as np
from datetime import timedelta
from nilmtk.tests.testingtools import data_dir
from os.path import join
from collections import OrderedDict
from nilmtk.consts import JOULES_PER_KWH
from nilmtk.measurement import measurement_columns, AC_TYPES
from nilmtk.utils import flatten_2d_list

    elec_meter_metadata = {}
    for meter in range(1, N_METERS + 1):
        key = 'building1/elec/meter{:d}'.format(meter)
        print("Saving", key)
        store.put(key, dfs[meter], format='table')
        elec_meter_metadata[meter] = {
            'device_model': TEST_METER['model'],
            'submeter_of': 1,
            'data_location': key
        }

    # For mains meter, we need to specify that it is a site meter
    del elec_meter_metadata[1]['submeter_of']
    elec_meter_metadata[1]['site_meter'] = True

    # Save dataset-wide metadata
    store.root._v_attrs.metadata = {
        'meter_devices': {TEST_METER['model']: TEST_METER}}
    print(store.root._v_attrs.metadata)

    # Building metadata
    add_building_metadata(store, elec_meter_metadata)
    for key in store.keys():
        print(store[key])

    store.flush()
    store.close()


def create_random_hdf5():

    FILENAME = join(data_dir(), 'random.h5')