Skip to content

Commit

Permalink
Feature/85 add construction costs walls to measures (#102)
Browse files Browse the repository at this point in the history
* 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"
  • Loading branch information
ArdtK authored Oct 25, 2023
1 parent f12f2c4 commit 8d78642
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 59 deletions.
22 changes: 11 additions & 11 deletions koswat/configuration/io/ini/koswat_general_ini_fom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
]

Expand Down Expand Up @@ -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
Expand All @@ -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()]
Expand Down
14 changes: 7 additions & 7 deletions koswat/configuration/io/koswat_costs_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions koswat/configuration/settings/costs/koswat_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
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,
)


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()
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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())
2 changes: 1 addition & 1 deletion koswat/configuration/settings/koswat_general_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import enum


class StorageFactorEnum(enum.Enum):
class SurtaxFactorEnum(enum.Enum):
MAKKELIJK = 0
NORMAAL = 1
MOEILIJK = 2
Expand Down
2 changes: 1 addition & 1 deletion koswat/cost_report/cost_report_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 24 additions & 26 deletions tests/configuration/io/ini/test_read_ini_configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand Down

0 comments on commit 8d78642

Please sign in to comment.