From fd215d9ae9f3c2b4c7deea673647a89c07ef582d Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Mon, 29 May 2023 12:49:27 -0400 Subject: [PATCH] erased merge methods and tests --- hub/city_model_structure/city.py | 32 +++------------------- hub/unittests/test_city_merge.py | 38 +++------------------------ hub/unittests/test_systems_factory.py | 2 +- 3 files changed, 7 insertions(+), 65 deletions(-) diff --git a/hub/city_model_structure/city.py b/hub/city_model_structure/city.py index 8262c9c7..ed996343 100644 --- a/hub/city_model_structure/city.py +++ b/hub/city_model_structure/city.py @@ -28,6 +28,7 @@ from hub.city_model_structure.level_of_detail import LevelOfDetail from hub.city_model_structure.parts_consisting_building import PartsConsistingBuilding from hub.helpers.geometry_helper import GeometryHelper from hub.helpers.location import Location +import hub.helpers.constants as cte from hub.city_model_structure.energy_system import EnergySystem import pandas as pd @@ -190,7 +191,7 @@ class City: return self.buildings[self._city_objects_dictionary[name]] return None - def building_alias(self, alias) -> Union[CityObject, None]: + def building_alias(self, alias) -> list[Building | list[Building]] | None: """ Retrieve the city CityObject with the given alias alias :alert: Building alias is not guaranteed to be unique @@ -445,34 +446,7 @@ class City: return copy.deepcopy(self) def merge(self, city) -> City: - _merge_city = self.copy - selected_city_object = None - building = None - # set initial minimum radiation to a higher number - min_radiation = 1999999 - for city_object in city.city_objects: - if city_object.type == 'building': - building = city_object - building_radiation = 0 - for surface in city_object.surfaces: - radiation = surface.global_irradiance - if 'year' not in radiation and 'month' not in radiation: - - continue - elif "year" in radiation: - building_radiation += radiation["year"].iloc[0] - elif "month" in radiation and "year" not in radiation: - surface.global_irradiance["year"] = pd.DataFrame({radiation["month"].sum()}) - building_radiation += radiation["year"].iloc[0] - if building_radiation < min_radiation: - min_radiation = building_radiation - selected_city_object = city_object - # merge the city object with the minimum radiation - if selected_city_object is not None: - _merge_city.add_city_object(selected_city_object) - else: - _merge_city.add_city_object(building) - return _merge_city + raise NotImplementedError('This method needs to be reimplemented') @property def level_of_detail(self) -> LevelOfDetail: diff --git a/hub/unittests/test_city_merge.py b/hub/unittests/test_city_merge.py index f43f7684..c128fa19 100644 --- a/hub/unittests/test_city_merge.py +++ b/hub/unittests/test_city_merge.py @@ -4,14 +4,11 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca """ -import subprocess + from pathlib import Path -from subprocess import SubprocessError, TimeoutExpired, CalledProcessError from unittest import TestCase -from hub.exports.exports_factory import ExportsFactory from hub.imports.geometry_factory import GeometryFactory -from hub.imports.results_factory import ResultFactory class TestCityMerge(TestCase): @@ -26,7 +23,6 @@ class TestCityMerge(TestCase): self._example_path = (Path(__file__).parent / 'tests_data').resolve() self._output_path = (Path(__file__).parent / 'tests_outputs').resolve() self._weather_file = (self._example_path / 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve() - self._climate_file = (self._example_path / 'New_York.cli').resolve() self._executable = 'sra' def _get_citygml(self, file): @@ -36,35 +32,7 @@ class TestCityMerge(TestCase): return city def test_merge(self): - city_1 = self._get_citygml('one_building_in_kelowna.gml') - city_2 = self._get_citygml('pluto_building.gml') - city = city_1.merge(city_2) - self.assertEqual(len(city_1.city_objects), 1, 'Wrong amount of city_objects found in city_1') - self.assertEqual(len(city_2.city_objects), 1, 'Wrong amount of city_objects found in city_2') - self.assertEqual(len(city.city_objects), 2, 'Wrong amount of city_objects found in city') + self.assertTrue(False, 'This test needs to be reimplemented') def test_merge_with_radiation(self): - city_one = self._get_citygml('one_building_in_kelowna.gml') - city_two = self._get_citygml('pluto_building.gml') - city_two.name = 'New_York' - city_two.climate_file = self._climate_file - try: - ExportsFactory(handler='sra', city=city_two, path=self._output_path, weather_file=self._weather_file, - target_buildings=city_two.buildings, weather_format='epw').export() - subprocess.run([self._executable, f'{str(self._output_path)}/{city_two.name}_sra.xml'], stdout=subprocess.DEVNULL) - except (SubprocessError, TimeoutExpired, CalledProcessError) as error: - raise Exception(error) - ResultFactory('sra', city_two, self._output_path).enrich() - merged_city = city_one.merge(city_two) - self.assertEqual(len(merged_city.buildings), 2) - self.assertEqual(round(merged_city.buildings[1].surfaces[0].global_irradiance['year'].iloc[0]), 254) - self.assertEqual(merged_city.buildings[0].surfaces[0].global_irradiance, {}) - self.assertEqual(merged_city.buildings[0].surfaces[2].global_irradiance, {}) - self.assertEqual( - city_one.buildings[0].surfaces[0].global_irradiance, - merged_city.buildings[0].surfaces[0].global_irradiance - ) - self.assertEqual( - city_two.buildings[0].surfaces[0].global_irradiance, - merged_city.buildings[1].surfaces[0].global_irradiance - ) + self.assertTrue(False, 'This test needs to be reimplemented') diff --git a/hub/unittests/test_systems_factory.py b/hub/unittests/test_systems_factory.py index 2dbeffbc..bc30f665 100644 --- a/hub/unittests/test_systems_factory.py +++ b/hub/unittests/test_systems_factory.py @@ -109,6 +109,6 @@ class TestSystemsFactory(TestCase): for building in self._city.buildings: self.assertLess(0, building.heating_consumption[cte.YEAR][0]) - self.assertLess(0, building.cooling_consumption[cte.YEAR][0]) + self.assertEqual(0, building.cooling_consumption[cte.YEAR][0]) self.assertLess(0, building.domestic_hot_water_consumption[cte.YEAR][0]) self.assertLess(0, building.onsite_electrical_production[cte.YEAR][0])