From 993233aff9c8be049a81829d48c6b18af8dcf703 Mon Sep 17 00:00:00 2001 From: guille Date: Wed, 9 Mar 2022 17:02:12 -0500 Subject: [PATCH] Small bug fixing in greenery catalog and energy_systems_factory.py --- catalogs/data_model/greenery/vegetation.py | 2 +- catalogs/greenery/greenery_catalog.py | 18 +++++++++--------- catalogs/greenery_catalog_factory.py | 1 - exports/energy_systems_factory.py | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/catalogs/data_model/greenery/vegetation.py b/catalogs/data_model/greenery/vegetation.py index ec829f70..3bc8da2c 100644 --- a/catalogs/data_model/greenery/vegetation.py +++ b/catalogs/data_model/greenery/vegetation.py @@ -68,7 +68,7 @@ class Vegetation: """ percentage = 0.0 for plant_percentage in self._plant_percentages: - percentage += plant_percentage.percentage + percentage += float(plant_percentage.percentage) if percentage > 100: raise ValueError('the plant percentage in this vegetation is over 100%') return self._plant_percentages diff --git a/catalogs/greenery/greenery_catalog.py b/catalogs/greenery/greenery_catalog.py index aadb9754..243bc47b 100644 --- a/catalogs/greenery/greenery_catalog.py +++ b/catalogs/greenery/greenery_catalog.py @@ -73,13 +73,13 @@ class GreeneryCatalog(Catalog): _names['soils'].append(soil.name) else: _names = {category: []} - if category == 'vegetations': + if category.lower() == 'vegetations': for vegetation in self._data.vegetations: _names[category].append(vegetation.name) - elif category == 'plants': + elif category.lower() == 'plants': for plant in self._data.plants: _names[category].append(plant.name) - elif category == 'soils': + elif category.lower() == 'soils': for soil in self._data.soils: _names[category].append(soil.name) else: @@ -91,13 +91,13 @@ class GreeneryCatalog(Catalog): Get one complete entry from the greenery catalog """ for entry in self._data.vegetations: - if entry.name == name: + if entry.name.lower() == name.lower(): return entry for entry in self._data.plants: - if entry.name == name: + if entry.name.lower() == name.lower(): return entry for entry in self._data.soils: - if entry.name == name: + if entry.name.lower() == name.lower(): return entry raise IndexError(f"{name} doesn't exists in the catalog") @@ -105,11 +105,11 @@ class GreeneryCatalog(Catalog): if category is None: return self._data else: - if category == 'vegetations': + if category.lower() == 'vegetations': return self._data.vegetations - elif category == 'plants': + elif category.lower() == 'plants': return self._data.plants - elif category == 'soils': + elif category.lower() == 'soils': return self._data.soils else: raise ValueError(f'Unknown category [{category}]') diff --git a/catalogs/greenery_catalog_factory.py b/catalogs/greenery_catalog_factory.py index 3491d716..3b70687a 100644 --- a/catalogs/greenery_catalog_factory.py +++ b/catalogs/greenery_catalog_factory.py @@ -24,7 +24,6 @@ class GreeneryCatalogFactory: Return a greenery catalog using ecore as datasource :return: GreeneryCatalog """ - print('greenery') return GreeneryCatalog((self._path / 'ecore_greenery_catalog.xml').resolve()) @property diff --git a/exports/energy_systems_factory.py b/exports/energy_systems_factory.py index 6cdf5a2e..3103077a 100644 --- a/exports/energy_systems_factory.py +++ b/exports/energy_systems_factory.py @@ -16,7 +16,7 @@ class EnergySystemsExportFactory: def __init__(self, city, user_input, hp_model, output_path, data_type='heat', base_path=None): self._city = city if base_path is None: - base_path = base_path = Path(Path(__file__).parent.parent / 'data/energy_systems') + base_path = Path(Path(__file__).parent.parent / 'data/energy_systems') self._base_path = base_path self._user_input = user_input self._hp_model = hp_model @@ -29,8 +29,8 @@ class EnergySystemsExportFactory: of some objective function :return: None """ - HeatPumpExport(self._base_path, self._city, self._output_path)\ - .run_insel(self._user_input, self._hp_model, self._data_type) + HeatPumpExport(self._base_path, self._city, self._output_path).run_insel(self._user_input, self._hp_model, + self._data_type) def export(self): """