Small bug fixing in greenery catalog and energy_systems_factory.py
This commit is contained in:
parent
d5a4ffe0fa
commit
993233aff9
|
@ -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
|
||||
|
|
|
@ -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}]')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user