# Path: nilmtk/elecmeter.py
# class ElecMeter(Hashable, Electric):
#     def __init__(self, store=None, metadata=None, meter_id=None):
#     def key(self):
#     def instance(self):
#     def building(self):
#     def dataset(self):
#     def name(self):
#     def name(self, value):
#     def _identifier_attr(self, attr):
#     def get_timeframe(self):
#     def _check_store(self):
#     def upstream_meter(self, raise_warning=True):
#     def load_meter_devices(cls, store):
#     def save(self, destination, key):
#     def device(self):
#     def sample_period(self):
#     def is_site_meter(self):
#     def dominant_appliance(self):
#     def label(self, pretty=True):
#     def _pretty_label(self):
#     def available_ac_types(self, physical_quantity):
#     def available_physical_quantities(self):
#     def available_columns(self):
#     def __repr__(self):
#     def matches(self, key):
#     def load(self, **kwargs):
#     def _ac_type_to_columns(self, ac_type):
#     def _physical_quantity_to_columns(self, physical_quantity):
#     def _get_columns_with_best_ac_type(self, physical_quantity=None):
#     def _convert_physical_quantity_and_ac_type_to_cols(
#             self, physical_quantity=None, ac_type=None, columns=None,
#             **kwargs):
#     def dry_run_metadata(self):
#     def get_metadata(self):
#     def get_source_node(self, **loader_kwargs):
#     def total_energy(self, **loader_kwargs):
#     def dropout_rate(self, ignore_gaps=True, **loader_kwargs):
#     def good_sections(self, **loader_kwargs):
#     def _get_stat_from_cache_or_compute(self, nodes, results_obj, loader_kwargs):
#             def find_sections_to_compute():
#     def _compute_stat(self, nodes, loader_kwargs):
#     def key_for_cached_stat(self, stat_name):
#     def clear_cache(self, verbose=False):
#     def get_cached_stat(self, key_for_stat):


import unittest
import pandas as pd
import numpy as np
import nilmtk.measurement as measure
from nilmtk.elecmeter import ElecMeter, ElecMeterID
from nilmtk.exceptions import MeasurementError
                if cumulative:
                    columns.append(('cumulative energy', ac_type))
                else:
                    columns.append(('energy', ac_type))
        columns.append(('voltage', ''))

        # Create DataFrame
        N_COLS = len(columns)
        df = pd.DataFrame(np.arange(N_COLS).reshape((1,N_COLS)), 
                          columns=measure.measurement_columns(columns))

        # Try accessing columns
        i = 0
        for column in columns:
            series = df[column]
            self.assertIsInstance(series, pd.Series)
            self.assertEqual(series.name, column)
            self.assertEqual(series.shape, (1,))
            self.assertEqual(series.sum(), i)
            i += 1

    def test_select_best_ac_type(self):
        self.assertEqual(measure.select_best_ac_type(['reactive']), 'reactive')

        self.assertEqual(measure.select_best_ac_type(['active', 'reactive', 'apparent']), 'active')

        ElecMeter.meter_devices.update(
            {'test model': {'measurements': [{'physical_quantity': 'power', 
                                              'type': 'apparent'}]}})
        meter_id = ElecMeterID(1, 1, 'REDD')

# Path: nilmtk/elecmeter.py
# class ElecMeter(Hashable, Electric):
#     def __init__(self, store=None, metadata=None, meter_id=None):
#     def key(self):
#     def instance(self):
#     def building(self):
#     def dataset(self):
#     def name(self):
#     def name(self, value):
#     def _identifier_attr(self, attr):
#     def get_timeframe(self):
#     def _check_store(self):
#     def upstream_meter(self, raise_warning=True):
#     def load_meter_devices(cls, store):
#     def save(self, destination, key):
#     def device(self):
#     def sample_period(self):
#     def is_site_meter(self):
#     def dominant_appliance(self):
#     def label(self, pretty=True):
#     def _pretty_label(self):
#     def available_ac_types(self, physical_quantity):
#     def available_physical_quantities(self):
#     def available_columns(self):
#     def __repr__(self):
#     def matches(self, key):
#     def load(self, **kwargs):
#     def _ac_type_to_columns(self, ac_type):
#     def _physical_quantity_to_columns(self, physical_quantity):
#     def _get_columns_with_best_ac_type(self, physical_quantity=None):
#     def _convert_physical_quantity_and_ac_type_to_cols(
#             self, physical_quantity=None, ac_type=None, columns=None,
#             **kwargs):
#     def dry_run_metadata(self):
#     def get_metadata(self):
#     def get_source_node(self, **loader_kwargs):
#     def total_energy(self, **loader_kwargs):
#     def dropout_rate(self, ignore_gaps=True, **loader_kwargs):
#     def good_sections(self, **loader_kwargs):
#     def _get_stat_from_cache_or_compute(self, nodes, results_obj, loader_kwargs):
#             def find_sections_to_compute():
#     def _compute_stat(self, nodes, loader_kwargs):
#     def key_for_cached_stat(self, stat_name):
#     def clear_cache(self, verbose=False):
#     def get_cached_stat(self, key_for_stat):


# Path: nilmtk/tests/test_measurement.py
import unittest
import pandas as pd
import numpy as np
import nilmtk.measurement as measure
from nilmtk.elecmeter import ElecMeter, ElecMeterID
from nilmtk.exceptions import MeasurementError

                if cumulative:
                    columns.append(('cumulative energy', ac_type))
                else:
                    columns.append(('energy', ac_type))
        columns.append(('voltage', ''))

        # Create DataFrame
        N_COLS = len(columns)
        df = pd.DataFrame(np.arange(N_COLS).reshape((1,N_COLS)), 
                          columns=measure.measurement_columns(columns))

        # Try accessing columns
        i = 0
        for column in columns:
            series = df[column]
            self.assertIsInstance(series, pd.Series)
            self.assertEqual(series.name, column)
            self.assertEqual(series.shape, (1,))
            self.assertEqual(series.sum(), i)
            i += 1

    def test_select_best_ac_type(self):
        self.assertEqual(measure.select_best_ac_type(['reactive']), 'reactive')

        self.assertEqual(measure.select_best_ac_type(['active', 'reactive', 'apparent']), 'active')

        ElecMeter.meter_devices.update(
            {'test model': {'measurements': [{'physical_quantity': 'power', 
                                              'type': 'apparent'}]}})
        meter_id = ElecMeterID(1, 1, 'REDD')

        meter = ElecMeter(metadata={'device_model': 'test model'}, meter_id=meter_id)