From 8d786423c6650246c2bd7300b3ffd2b153f13e85 Mon Sep 17 00:00:00 2001 From: Ardt Klapwijk <59741981+ArdtK@users.noreply.github.com> Date: Wed, 25 Oct 2023 08:00:47 +0200 Subject: [PATCH] Feature/85 add construction costs walls to measures (#102) * fix: typo comment * fix: correct symbol name * chore: rename "storage" to "raise" throughout KOSWAT * chore: rename "purchased_soil" to "purchased_land" throughout KOSWAT * chore: rename "ground_purchase" to "land_purchase" throughout KOSWAT * fix: typo comment * fix: correct symbol name * chore: rename "storage" to "raise" throughout KOSWAT * chore: rename "ground_purchase" to "land_purchase" throughout KOSWAT * chore: rename "purchased_soil" to "purchased_land" throughout KOSWAT * chore: rename "purchase_land" to "land_purchase" throughout KOSWAT * test: typo fix * fix: rename "raise" to "surtax" throughout KOSWAT * fix: rename "raise" to "surtax" throughout KOSWAT * fix: reverted wrong changes from "Raises" to "Surtaxs" * fix: reverted wrong changes from "Raises" to "Surtaxs" --- .../io/ini/koswat_general_ini_fom.py | 22 ++++---- .../configuration/io/koswat_costs_importer.py | 14 +++--- .../settings/costs/koswat_costs.py | 10 ++-- ...s_settings.py => surtax_costs_settings.py} | 14 +++--- .../settings/koswat_general_settings.py | 2 +- koswat/cost_report/cost_report_protocol.py | 2 +- .../io/ini/test_read_ini_configurations.py | 50 +++++++++---------- .../test_characteristic_points.py | 2 +- 8 files changed, 57 insertions(+), 59 deletions(-) rename koswat/configuration/settings/costs/{storage_costs_settings.py => surtax_costs_settings.py} (76%) diff --git a/koswat/configuration/io/ini/koswat_general_ini_fom.py b/koswat/configuration/io/ini/koswat_general_ini_fom.py index c8d4da8a..19935faa 100644 --- a/koswat/configuration/io/ini/koswat_general_ini_fom.py +++ b/koswat/configuration/io/ini/koswat_general_ini_fom.py @@ -7,7 +7,7 @@ from koswat.configuration.settings.koswat_general_settings import ( InfraCostsEnum, - StorageFactorEnum, + SurtaxFactorEnum, ) from koswat.core.io.ini.koswat_ini_fom_protocol import KoswatIniFomProtocol @@ -56,22 +56,22 @@ def from_config(cls, ini_config: ConfigParser) -> KoswatIniFomProtocol: class ReinforcementProfileSectionFomBase(KoswatIniFomProtocol, abc.ABC): - soil_storage_factor: StorageFactorEnum - constructive_storage_factor: StorageFactorEnum - purchased_soil_storage_factor: Optional[StorageFactorEnum] + soil_surtax_factor: SurtaxFactorEnum + constructive_surtax_factor: SurtaxFactorEnum + land_purchase_surtax_factor: Optional[SurtaxFactorEnum] def _set_properties_from_dict(self, properties_dict: dict) -> None: - self.soil_storage_factor = StorageFactorEnum[ + self.soil_surtax_factor = SurtaxFactorEnum[ properties_dict["opslagfactor_grond"].upper() ] - self.constructive_storage_factor = StorageFactorEnum[ + self.constructive_surtax_factor = SurtaxFactorEnum[ properties_dict.get( - "opslagfactor_constructief", StorageFactorEnum.NORMAAL.name + "opslagfactor_constructief", SurtaxFactorEnum.NORMAAL.name ).upper() ] - self.purchased_soil_storage_factor = StorageFactorEnum[ + self.land_purchase_surtax_factor = SurtaxFactorEnum[ properties_dict.get( - "opslagfactor_grondaankoop", StorageFactorEnum.NORMAAL.name + "opslagfactor_grondaankoop", SurtaxFactorEnum.NORMAAL.name ).upper() ] @@ -172,7 +172,7 @@ def from_config(cls, ini_config: ConfigParser) -> KoswatIniFomProtocol: class InfrastructureSectionFom(KoswatIniFomProtocol): infrastructuur: bool - opslagfactor_wegen: StorageFactorEnum + opslagfactor_wegen: SurtaxFactorEnum infrakosten_0dh: InfraCostsEnum buffer_buitendijks: float wegen_klasse2_breedte: float @@ -185,7 +185,7 @@ class InfrastructureSectionFom(KoswatIniFomProtocol): def from_config(cls, ini_config: ConfigParser) -> KoswatIniFomProtocol: _section = cls() _section.infrastructuur = ini_config.getboolean("infrastructuur") - _section.opslagfactor_wegen = StorageFactorEnum[ + _section.opslagfactor_wegen = SurtaxFactorEnum[ ini_config["opslagfactor_wegen"].upper() ] _section.infrakosten_0dh = InfraCostsEnum[ini_config["infrakosten_0dh"].upper()] diff --git a/koswat/configuration/io/koswat_costs_importer.py b/koswat/configuration/io/koswat_costs_importer.py index 38676902..f570672c 100644 --- a/koswat/configuration/io/koswat_costs_importer.py +++ b/koswat/configuration/io/koswat_costs_importer.py @@ -8,7 +8,7 @@ DikeProfileCostsSettings, InfrastructureCostsSettings, KoswatCostsSettings, - StorageCostsSettings, + SurtaxCostsSettings, ) from koswat.core.io.ini.koswat_ini_reader import KoswatIniReader from koswat.core.io.koswat_importer_protocol import KoswatImporterProtocol @@ -42,13 +42,13 @@ def import_from(self, from_path: Path) -> KoswatCostsSettings: _costs_settings.infrastructure_costs = self._get_infrastructure_costs_settings( _costs_fom ) - _costs_settings.storage_costs = self._get_storage_costs( + _costs_settings.surtax_costs = self._get_surtax_costs( _costs_fom, ) return _costs_settings - def _get_storage_costs(self, fom_costs: KoswatCostsIniFom) -> StorageCostsSettings: - _settings = StorageCostsSettings() + def _get_surtax_costs(self, fom_costs: KoswatCostsIniFom) -> SurtaxCostsSettings: + _settings = SurtaxCostsSettings() _fom_settings = ( fom_costs.storing_costs_incl_tax_section if self.include_taxes @@ -63,9 +63,9 @@ def _get_storage_costs(self, fom_costs: KoswatCostsIniFom) -> StorageCostsSettin _settings.roads_easy = _fom_settings.wegen_makkelijk _settings.roads_normal = _fom_settings.wegen_normaal _settings.roads_hard = _fom_settings.wegen_moeilijk - _settings.ground_purchase_easy = _fom_settings.grond_makkelijk - _settings.ground_purchase_normal = _fom_settings.grondaankoop_normaal - _settings.ground_purchas_hard = _fom_settings.grondaankoop_moeilijk + _settings.land_purchase_easy = _fom_settings.grond_makkelijk + _settings.land_purchase_normal = _fom_settings.grondaankoop_normaal + _settings.land_purchase_hard = _fom_settings.grondaankoop_moeilijk return _settings def _get_infrastructure_costs_settings( diff --git a/koswat/configuration/settings/costs/koswat_costs.py b/koswat/configuration/settings/costs/koswat_costs.py index a3088cec..9b60ccfe 100644 --- a/koswat/configuration/settings/costs/koswat_costs.py +++ b/koswat/configuration/settings/costs/koswat_costs.py @@ -7,8 +7,8 @@ from koswat.configuration.settings.costs.infastructure_costs_settings import ( InfrastructureCostsSettings, ) -from koswat.configuration.settings.costs.storage_costs_settings import ( - StorageCostsSettings, +from koswat.configuration.settings.costs.surtax_costs_settings import ( + SurtaxCostsSettings, ) @@ -16,18 +16,18 @@ class KoswatCostsSettings(KoswatConfigProtocol): price_year: int dike_profile_costs: DikeProfileCostsSettings infrastructure_costs: InfrastructureCostsSettings - storage_costs: StorageCostsSettings + surtax_costs: SurtaxCostsSettings def __init__(self) -> None: self.price_year = math.nan self.dike_profile_costs = None self.infrastructure_costs = None - self.storage_costs = None + self.surtax_costs = None def is_valid(self) -> bool: return ( not math.isnan(self.price_year) and self.dike_profile_costs.is_valid() and self.infrastructure_costs.is_valid() - and self.storage_costs.is_valid() + and self.surtax_costs.is_valid() ) diff --git a/koswat/configuration/settings/costs/storage_costs_settings.py b/koswat/configuration/settings/costs/surtax_costs_settings.py similarity index 76% rename from koswat/configuration/settings/costs/storage_costs_settings.py rename to koswat/configuration/settings/costs/surtax_costs_settings.py index c88cc66d..705847e6 100644 --- a/koswat/configuration/settings/costs/storage_costs_settings.py +++ b/koswat/configuration/settings/costs/surtax_costs_settings.py @@ -7,7 +7,7 @@ def _valid_float_prop(config_property: float) -> bool: return config_property is not None and not math.isnan(config_property) -class StorageCostsSettings(KoswatConfigProtocol): +class SurtaxCostsSettings(KoswatConfigProtocol): ground_easy: float ground_normal: float ground_hard: float @@ -17,9 +17,9 @@ class StorageCostsSettings(KoswatConfigProtocol): roads_easy: float roads_normal: float roads_hard: float - ground_purchase_easy: float - ground_purchase_normal: float - ground_purchas_hard: float + land_purchase_easy: float + land_purchase_normal: float + land_purchase_hard: float def __init__(self) -> None: self.ground_easy = math.nan @@ -31,9 +31,9 @@ def __init__(self) -> None: self.roads_easy = math.nan self.roads_normal = math.nan self.roads_hard = math.nan - self.ground_purchase_easy = math.nan - self.ground_purchase_normal = math.nan - self.ground_purchas_hard = math.nan + self.land_purchase_easy = math.nan + self.land_purchase_normal = math.nan + self.land_purchase_hard = math.nan def is_valid(self) -> bool: return all(_valid_float_prop(_prop) for _prop in self.__dict__.values()) diff --git a/koswat/configuration/settings/koswat_general_settings.py b/koswat/configuration/settings/koswat_general_settings.py index 3b391f72..2c4caad7 100644 --- a/koswat/configuration/settings/koswat_general_settings.py +++ b/koswat/configuration/settings/koswat_general_settings.py @@ -3,7 +3,7 @@ import enum -class StorageFactorEnum(enum.Enum): +class SurtaxFactorEnum(enum.Enum): MAKKELIJK = 0 NORMAAL = 1 MOEILIJK = 2 diff --git a/koswat/cost_report/cost_report_protocol.py b/koswat/cost_report/cost_report_protocol.py index 6a68ba45..b47c8c54 100644 --- a/koswat/cost_report/cost_report_protocol.py +++ b/koswat/cost_report/cost_report_protocol.py @@ -4,7 +4,7 @@ @runtime_checkable class CostReportProtocol(Protocol): """ - A `Protocol` defining the properties of a report in Koswawt. + A `Protocol` defining the properties of a report in Koswat. """ total_cost: float diff --git a/tests/configuration/io/ini/test_read_ini_configurations.py b/tests/configuration/io/ini/test_read_ini_configurations.py index 4aefae60..6476979a 100644 --- a/tests/configuration/io/ini/test_read_ini_configurations.py +++ b/tests/configuration/io/ini/test_read_ini_configurations.py @@ -27,7 +27,7 @@ ) from koswat.configuration.settings.koswat_general_settings import ( InfraCostsEnum, - StorageFactorEnum, + SurtaxFactorEnum, ) from koswat.core.io.file_object_model_protocol import FileObjectModelProtocol from koswat.core.io.ini.koswat_ini_fom_protocol import KoswatIniFomProtocol @@ -107,16 +107,16 @@ def test_koswat_ini_read_general_ini(self): # Grondmaatregel section assert isinstance(_ini_fom.grondmaatregel_section, SoilReinforcementSectionFom) assert ( - _ini_fom.grondmaatregel_section.soil_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.grondmaatregel_section.soil_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert ( - _ini_fom.grondmaatregel_section.constructive_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.grondmaatregel_section.constructive_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert ( - _ini_fom.grondmaatregel_section.purchased_soil_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.grondmaatregel_section.land_purchase_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert _ini_fom.grondmaatregel_section.min_bermhoogte == 0.5 assert _ini_fom.grondmaatregel_section.max_bermhoogte_factor == 0.4 @@ -126,15 +126,15 @@ def test_koswat_ini_read_general_ini(self): _ini_fom.kwelscherm_section, PipingwallReinforcementSectionFom ) assert ( - _ini_fom.kwelscherm_section.soil_storage_factor == StorageFactorEnum.NORMAAL + _ini_fom.kwelscherm_section.soil_surtax_factor == SurtaxFactorEnum.NORMAAL ) assert ( - _ini_fom.kwelscherm_section.constructive_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.kwelscherm_section.constructive_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert ( - _ini_fom.kwelscherm_section.purchased_soil_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.kwelscherm_section.land_purchase_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert _ini_fom.kwelscherm_section.min_lengte_kwelscherm == 4 assert _ini_fom.kwelscherm_section.overgang_cbwand_damwand == 99 @@ -145,16 +145,16 @@ def test_koswat_ini_read_general_ini(self): _ini_fom.stabiliteitswand_section, StabilitywallReinforcementSectionFom ) assert ( - _ini_fom.stabiliteitswand_section.soil_storage_factor - == StorageFactorEnum.MOEILIJK + _ini_fom.stabiliteitswand_section.soil_surtax_factor + == SurtaxFactorEnum.MOEILIJK ) assert ( - _ini_fom.stabiliteitswand_section.constructive_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.stabiliteitswand_section.constructive_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert ( - _ini_fom.stabiliteitswand_section.purchased_soil_storage_factor - == StorageFactorEnum.MOEILIJK + _ini_fom.stabiliteitswand_section.land_purchase_surtax_factor + == SurtaxFactorEnum.MOEILIJK ) assert _ini_fom.stabiliteitswand_section.versteiling_binnentalud == 2 assert _ini_fom.stabiliteitswand_section.min_lengte_stabiliteitswand == 5 @@ -163,16 +163,14 @@ def test_koswat_ini_read_general_ini(self): # Kistdam section assert isinstance(_ini_fom.kistdam_section, CofferdamReinforcementSectionFom) + assert _ini_fom.kistdam_section.soil_surtax_factor == SurtaxFactorEnum.MOEILIJK assert ( - _ini_fom.kistdam_section.soil_storage_factor == StorageFactorEnum.MOEILIJK + _ini_fom.kistdam_section.constructive_surtax_factor + == SurtaxFactorEnum.MOEILIJK ) assert ( - _ini_fom.kistdam_section.constructive_storage_factor - == StorageFactorEnum.MOEILIJK - ) - assert ( - _ini_fom.kistdam_section.purchased_soil_storage_factor - == StorageFactorEnum.NORMAAL + _ini_fom.kistdam_section.land_purchase_surtax_factor + == SurtaxFactorEnum.NORMAAL ) assert _ini_fom.kistdam_section.min_lengte_kistdam == 5 assert _ini_fom.kistdam_section.max_lengte_kistdam == 25 @@ -195,7 +193,7 @@ def test_koswat_ini_read_general_ini(self): assert _ini_fom.infrastructuur_section.infrastructuur == False assert ( _ini_fom.infrastructuur_section.opslagfactor_wegen - == StorageFactorEnum.NORMAAL + == SurtaxFactorEnum.NORMAAL ) assert _ini_fom.infrastructuur_section.infrakosten_0dh == InfraCostsEnum.GEEN assert _ini_fom.infrastructuur_section.buffer_buitendijks == 0 diff --git a/tests/dike/characteristic_points/test_characteristic_points.py b/tests/dike/characteristic_points/test_characteristic_points.py index 2ecc996a..aadbff9c 100644 --- a/tests/dike/characteristic_points/test_characteristic_points.py +++ b/tests/dike/characteristic_points/test_characteristic_points.py @@ -46,7 +46,7 @@ def test_initialize(self): ), ], ) - def test_add_side_poitns_raises_error_when_exact_points_given( + def test_add_side_points_raises_error_when_exact_points_given( self, side_func: Callable, points_to_add: Optional[List[float]],