<commit_before>import os
from unittest import TestCase

from cea import epwreader
from cea.demand import BuildingProperties
from cea.thermal_loads import calc_thermal_loads_new_ventilation
from cea.inputlocator import InputLocator
from cea.globalvar import GlobalVariables
from cea.maker import schedule_maker

import pandas as pd

class TestCalcThermalLoadsNewVentilation(TestCase):
    def test_calc_thermal_loads_new_ventilation(self):

        locator = InputLocator(r'C:\reference-case\baseline')
        gv = GlobalVariables()
        building_properties = BuildingProperties(locator, gv)

        weather_path = locator.get_default_weather()
        weather_data = epwreader.epw_reader(weather_path)[['drybulb_C', 'relhum_percent', 'windspd_ms']]

        list_uses = list(building_properties._prop_occupancy.drop('PFloor', axis=1).columns)

        # FIXME: the usage_schedules bit needs to be fixed!!
        date = pd.date_range(gv.date_start, periods=8760, freq='H')
        schedules = schedule_maker(date, locator, list_uses)
        usage_schedules = {'list_uses': list_uses,
                           'schedules': schedules}

        result = calc_thermal_loads_new_ventilation('B140577', building_properties, weather_data, usage_schedules, date,
                                                    gv, locator.get_temporary_folder(),
                                                    locator.get_temporary_folder())
        self.assertIsNone(result)
        self.assertTrue(os.path.exists(locator.get_temporary_file('B140577.csv')), 'Building csv not produced')
        self.assertTrue(os.path.exists(locator.get_temporary_file('B140577T.csv')), 'Building temp file not produced')

        # test the building csv file
        df = pd.read_csv(locator.get_temporary_file('B140577.csv'))

        #
        expected_columns = [u'DATE', u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'Epro_kWh', u'Name',
                            u'QCf_kWh', u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh', u'Qhs_kWh',
                            u'Qhsf_kWh', u'Qww_kWh', u'Qww_tankloss_kWh', u'Qwwf_kWh', u'Trcs_C', u'Trhs_C', u'Trww_C',
                            u'Tscs_C', u'Tshs_C', u'Tsww_C', u'Tww_tank_C', u'Vw_m3', u'mcpcs_kWC', u'mcphs_kWC',
                            u'mcpww_kWC', u'occ_pax']
        self.assertEqual(set(expected_columns), set(df.columns), 'Column list of building csv does not match')
        self.assertEqual(df.shape[0], 8760, 'Expected one row per hour in the year')


<commit_msg>add test results to test case<commit_after>import os
from unittest import TestCase

from cea import epwreader
from cea.demand import BuildingProperties
from cea.thermal_loads import calc_thermal_loads_new_ventilation
from cea.inputlocator import InputLocator
from cea.globalvar import GlobalVariables
from cea.maker import schedule_maker

import pandas as pd

class TestCalcThermalLoadsNewVentilation(TestCase):
    def test_calc_thermal_loads_new_ventilation(self):

        locator = InputLocator(r'C:\reference-case\baseline')
        gv = GlobalVariables()

        weather_path = locator.get_default_weather()
        weather_data = epwreader.epw_reader(weather_path)[['drybulb_C', 'relhum_percent', 'windspd_ms']]

        self.building_properties = BuildingProperties(locator, gv)
        list_uses = list(self.building_properties._prop_occupancy.drop('PFloor', axis=1).columns)

        # FIXME: the usage_schedules bit needs to be fixed!!
        date = pd.date_range(gv.date_start, periods=8760, freq='H')
        schedules = schedule_maker(date, locator, list_uses)
        usage_schedules = {'list_uses': list_uses,
                           'schedules': schedules}

        result = calc_thermal_loads_new_ventilation('B140577', self.building_properties, weather_data, usage_schedules,
                                                    date, gv, locator.get_temporary_folder(),
                                                    locator.get_temporary_folder())
        self.assertIsNone(result)
        self.assertTrue(os.path.exists(locator.get_temporary_file('B140577.csv')), 'Building csv not produced')
        self.assertTrue(os.path.exists(locator.get_temporary_file('B140577T.csv')), 'Building temp file not produced')

        # test the building csv file
        df = pd.read_csv(locator.get_temporary_file('B140577.csv'))

        #
        expected_columns = [u'DATE', u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'Epro_kWh', u'Name',
                            u'QCf_kWh', u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh', u'Qhs_kWh',
                            u'Qhsf_kWh', u'Qww_kWh', u'Qww_tankloss_kWh', u'Qwwf_kWh', u'Trcs_C', u'Trhs_C', u'Trww_C',
                            u'Tscs_C', u'Tshs_C', u'Tsww_C', u'Tww_tank_C', u'Vw_m3', u'mcpcs_kWC', u'mcphs_kWC',
                            u'mcpww_kWC', u'occ_pax']
        self.assertEqual(set(expected_columns), set(df.columns), 'Column list of building csv does not match')
        self.assertEqual(df.shape[0], 8760, 'Expected one row per hour in the year')

        value_columns = [u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'Epro_kWh', u'QCf_kWh', u'QHf_kWh',
                        u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh', u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh',
                        u'Qww_tankloss_kWh', u'Qwwf_kWh', u'Trcs_C', u'Trhs_C', u'Trww_C', u'Tscs_C', u'Tshs_C',
                        u'Tsww_C', u'Tww_tank_C', u'Vw_m3', u'mcpcs_kWC', u'mcphs_kWC', u'mcpww_kWC', u'occ_pax']
        values = [2335522.029999916, 51283.209999999264, 0.0, 2386803.5299999011, 0.0, 1600579.3699999989,
                  10583959.84999999, 0.0, 0.0, 969342.64000000141, 1600579.3699999989, 917820.5499999997,
                  1598211.1199999996, 8964857.8500000071, 9976.2799999999643, 8985748.6999999825, 16116, 52842, 99500.0,
                  11376, 63853, 525600, 525426.29999996931, 476000.19000000018, 319634, 148190, 184502.95000000024,
                  6827181.0]
        for i, column in enumerate(value_columns):
            self.assertAlmostEqual(values[i], df[column].sum(), 'Sum of column %s differs' % column)

{'fraction_non_alphanumeric': 0.11302527773305426, 'fraction_numerical': 0.061664788278860086, 'mean_word_length': 3.057478772044415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3100576', 'n_tokens_mistral': 2475, 'n_tokens_neox': 2187, 'n_words': 384}