Bug fixing in remove_city_object method

This commit is contained in:
Guille Gutierrez 2023-06-09 11:21:45 -04:00
parent e14bc5c2bd
commit 08df06dc2e
3 changed files with 10 additions and 2 deletions

View File

@ -259,8 +259,8 @@ class City:
if city_object in self._buildings:
self._buildings.remove(city_object)
# regenerate hash map
self._city_objects_dictionary.clear()
self._city_objects_alias_dictionary.clear()
self._city_objects_dictionary = {}
self._city_objects_alias_dictionary = {}
for i, _building in enumerate(self._buildings):
self._city_objects_dictionary[_building.name] = i
for alias in _building.aliases:

View File

@ -20,6 +20,7 @@ class Weather:
_epw_file = {
'CA.02.5935': 'https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/CAN/BC/CAN_BC_Summerland.717680_CWEC/CAN_BC_Summerland.717680_CWEC.epw',
'CA.10.06': 'https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/CAN/PQ/CAN_PQ_Montreal.Intl.AP.716270_CWEC/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw',
'CA.10.13': 'https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/CAN/PQ/CAN_PQ_Montreal.Intl.AP.716270_CWEC/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw',
'CA.10.14': 'https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/CAN/PQ/CAN_PQ_Montreal.Intl.AP.716270_CWEC/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw',
'CA.10.16': 'https://energyplus-weather.s3.amazonaws.com/north_and_central_america_wmo_region_4/CAN/PQ/CAN_PQ_Montreal.Intl.AP.716270_CWEC/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw',
'DE.01.082': 'https://energyplus-weather.s3.amazonaws.com/europe_wmo_region_6/DEU/DEU_Stuttgart.107380_IWEC/DEU_Stuttgart.107380_IWEC.epw',

View File

@ -148,6 +148,13 @@ class TestGeometryFactory(TestCase):
self.assertEqual(8, len(city.building_alias('rue Sherbrooke Ouest (MTL+MTO+WMT)')))
self.assertEqual(17, len(city.buildings), 'wrong number of buildings')
self.assertIsNotNone(city.city_object('15'), 'Building name 15 is missing in the city')
city.remove_city_object(city.city_object('15'))
self.assertIsNone(city.city_object('15'), 'Building name 15 wasn\'t removed')
for building in city.buildings:
_building = city.city_object(building.name)
self.assertEqual(_building.name, building.name, 'hash map it\'s unsync')
def test_map_neighbours(self):
"""
Test neighbours map creation