diff --git a/flood_adapt/object_model/interface/database.py b/flood_adapt/object_model/interface/database.py index c6eab2347..522a4c048 100644 --- a/flood_adapt/object_model/interface/database.py +++ b/flood_adapt/object_model/interface/database.py @@ -23,211 +23,161 @@ class IDatabase(ABC): site: ISite @abstractmethod - def __init__(self, database_path: Union[str, os.PathLike], site_name: str) -> None: - ... + def __init__( + self, database_path: Union[str, os.PathLike], site_name: str + ) -> None: ... @abstractmethod - def get_aggregation_areas(self) -> dict: - ... + def get_aggregation_areas(self) -> dict: ... @abstractmethod - def get_obs_points(self) -> GeoDataFrame: - ... + def get_obs_points(self) -> GeoDataFrame: ... @abstractmethod - def get_property_types(self) -> list: - ... + def get_property_types(self) -> list: ... @abstractmethod - def get_slr_scn_names(self) -> list: - ... + def get_slr_scn_names(self) -> list: ... @abstractmethod - def interp_slr(self, slr_scenario: str, year: float) -> float: - ... + def interp_slr(self, slr_scenario: str, year: float) -> float: ... @abstractmethod - def plot_slr_scenarios(self) -> str: - ... + def plot_slr_scenarios(self) -> str: ... @abstractmethod - def plot_wl(self, event: IEvent, input_wl_df: pd.DataFrame = None) -> str: - ... + def plot_wl(self, event: IEvent, input_wl_df: pd.DataFrame = None) -> str: ... @abstractmethod - def plot_river(self, event: IEvent, input_river_df: list[pd.DataFrame]) -> str: - ... + def plot_river(self, event: IEvent, input_river_df: list[pd.DataFrame]) -> str: ... @abstractmethod def plot_rainfall( self, event: IEvent, input_rainfall_df: pd.DataFrame = None - ) -> str: - ... + ) -> str: ... @abstractmethod - def plot_wind(self, event: IEvent, input_wind_df: pd.DataFrame = None) -> str: - ... + def plot_wind(self, event: IEvent, input_wind_df: pd.DataFrame = None) -> str: ... @abstractmethod - def get_buildings(self) -> GeoDataFrame: - ... + def get_buildings(self) -> GeoDataFrame: ... @abstractmethod - def get_projection(self, name: str) -> IProjection: - ... + def get_projection(self, name: str) -> IProjection: ... @abstractmethod - def save_projection(self, measure: IProjection) -> None: - ... + def save_projection(self, measure: IProjection) -> None: ... @abstractmethod - def edit_projection(self, measure: IProjection) -> None: - ... + def edit_projection(self, measure: IProjection) -> None: ... @abstractmethod - def delete_projection(self, name: str): - ... + def delete_projection(self, name: str): ... @abstractmethod - def copy_projection(self, old_name: str, new_name: str, new_description: str): - ... + def copy_projection(self, old_name: str, new_name: str, new_description: str): ... @abstractmethod - def get_event(self, name: str) -> IEvent: - ... + def get_event(self, name: str) -> IEvent: ... @abstractmethod - def save_event(self, measure: IEvent) -> None: - ... + def save_event(self, measure: IEvent) -> None: ... @abstractmethod - def write_to_csv(self, name: str, event: IEvent, df: pd.DataFrame) -> None: - ... + def write_to_csv(self, name: str, event: IEvent, df: pd.DataFrame) -> None: ... @abstractmethod - def write_cyc(self, event: IEvent, track: TropicalCyclone): - ... + def write_cyc(self, event: IEvent, track: TropicalCyclone): ... @abstractmethod - def edit_event(self, measure: IEvent) -> None: - ... + def edit_event(self, measure: IEvent) -> None: ... @abstractmethod - def delete_event(self, name: str): - ... + def delete_event(self, name: str): ... @abstractmethod - def copy_event(self, old_name: str, new_name: str, new_description: str): - ... + def copy_event(self, old_name: str, new_name: str, new_description: str): ... @abstractmethod - def get_measure(self, name: str) -> IMeasure: - ... + def get_measure(self, name: str) -> IMeasure: ... @abstractmethod - def save_measure(self, measure: IMeasure) -> None: - ... + def save_measure(self, measure: IMeasure) -> None: ... @abstractmethod - def edit_measure(self, measure: IMeasure): - ... + def edit_measure(self, measure: IMeasure): ... @abstractmethod - def delete_measure(self, name: str): - ... + def delete_measure(self, name: str): ... @abstractmethod - def copy_measure(self, old_name: str, new_name: str, new_description: str): - ... + def copy_measure(self, old_name: str, new_name: str, new_description: str): ... @abstractmethod - def get_strategy(self, name: str) -> IStrategy: - ... + def get_strategy(self, name: str) -> IStrategy: ... @abstractmethod - def save_strategy(self, measure: IStrategy) -> None: - ... + def save_strategy(self, measure: IStrategy) -> None: ... @abstractmethod - def delete_strategy(self, name: str): - ... + def delete_strategy(self, name: str): ... @abstractmethod - def get_scenario(self, name: str) -> IScenario: - ... + def get_scenario(self, name: str) -> IScenario: ... @abstractmethod - def save_scenario(self, measure: IScenario) -> None: - ... + def save_scenario(self, measure: IScenario) -> None: ... @abstractmethod - def edit_scenario(self, measure: IScenario) -> None: - ... + def edit_scenario(self, measure: IScenario) -> None: ... @abstractmethod - def delete_scenario(self, name: str): - ... + def delete_scenario(self, name: str): ... @abstractmethod - def get_benefit(self, name: str) -> IBenefit: - ... + def get_benefit(self, name: str) -> IBenefit: ... @abstractmethod - def save_benefit(self, benefit: IBenefit) -> None: - ... + def save_benefit(self, benefit: IBenefit) -> None: ... @abstractmethod - def edit_benefit(self, measure: IBenefit) -> None: - ... + def edit_benefit(self, measure: IBenefit) -> None: ... @abstractmethod - def delete_benefit(self, name: str) -> None: - ... + def delete_benefit(self, name: str) -> None: ... @abstractmethod - def check_benefit_scenarios(self, benefit: IBenefit) -> None: - ... + def check_benefit_scenarios(self, benefit: IBenefit) -> None: ... @abstractmethod - def create_benefit_scenarios(self, benefit: IBenefit) -> None: - ... + def create_benefit_scenarios(self, benefit: IBenefit) -> None: ... @abstractmethod - def run_benefit(self, benefit_name: Union[str, list[str]]) -> None: - ... + def run_benefit(self, benefit_name: Union[str, list[str]]) -> None: ... @abstractmethod - def get_model_boundary(self) -> dict[str, Any]: - ... + def get_model_boundary(self) -> dict[str, Any]: ... @abstractmethod - def get_projections(self) -> dict[str, Any]: - ... + def get_projections(self) -> dict[str, Any]: ... @abstractmethod - def get_events(self) -> dict[str, Any]: - ... + def get_events(self) -> dict[str, Any]: ... @abstractmethod - def get_measures(self) -> dict[str, Any]: - ... + def get_measures(self) -> dict[str, Any]: ... @abstractmethod - def get_strategies(self) -> dict[str, Any]: - ... + def get_strategies(self) -> dict[str, Any]: ... @abstractmethod - def get_scenarios(self) -> dict[str, Any]: - ... + def get_scenarios(self) -> dict[str, Any]: ... @abstractmethod - def get_benefits(self) -> dict[str, Any]: - ... + def get_benefits(self) -> dict[str, Any]: ... @abstractmethod - def get_outputs(self) -> dict[str, Any]: - ... + def get_outputs(self) -> dict[str, Any]: ... @abstractmethod - def run_scenario(self, scenario_name: Union[str, list[str]]) -> None: - ... + def run_scenario(self, scenario_name: Union[str, list[str]]) -> None: ... diff --git a/flood_adapt/object_model/interface/scenarios.py b/flood_adapt/object_model/interface/scenarios.py index f0478a4fa..610eaaf27 100644 --- a/flood_adapt/object_model/interface/scenarios.py +++ b/flood_adapt/object_model/interface/scenarios.py @@ -37,5 +37,4 @@ def save(self, filepath: Union[str, os.PathLike]): ... @abstractmethod - def run(self) -> None: - ... + def run(self) -> None: ... diff --git a/flood_adapt/object_model/interface/site.py b/flood_adapt/object_model/interface/site.py index 55674e072..005016ee1 100644 --- a/flood_adapt/object_model/interface/site.py +++ b/flood_adapt/object_model/interface/site.py @@ -191,9 +191,9 @@ class Obs_pointModel(BaseModel): name: Union[int, str] description: Optional[str] = "" - ID: Optional[ - int - ] = None # if the observation station is also a tide gauge, this ID should be the same as for obs_station + ID: Optional[int] = ( + None # if the observation station is also a tide gauge, this ID should be the same as for obs_station + ) lat: float lon: float @@ -242,9 +242,9 @@ class SiteModel(BaseModel): obs_point: Optional[list[Obs_pointModel]] = None benefits: BenefitsModel scs: Optional[SCSModel] = None # optional for the US to use SCS rainfall curves - standard_objects: Optional[ - StandardObjectModel - ] = StandardObjectModel() # optional for the US to use standard objects + standard_objects: Optional[StandardObjectModel] = ( + StandardObjectModel() + ) # optional for the US to use standard objects class ISite(ABC): diff --git a/tests/test_integrator/test_hazard_run.py b/tests/test_integrator/test_hazard_run.py index 78bcff682..b6b093d42 100644 --- a/tests/test_integrator/test_hazard_run.py +++ b/tests/test_integrator/test_hazard_run.py @@ -548,16 +548,16 @@ def test_multiple_rivers(test_db: None): # Overwrite river data of Event test_scenario.direct_impacts.hazard.event.attrs.river[0].source = "constant" test_scenario.direct_impacts.hazard.event.attrs.river[1].source = "shape" - test_scenario.direct_impacts.hazard.event.attrs.river[ - 0 - ].constant_discharge = UnitfulDischarge(value=2000.0, units="cfs") + test_scenario.direct_impacts.hazard.event.attrs.river[0].constant_discharge = ( + UnitfulDischarge(value=2000.0, units="cfs") + ) test_scenario.direct_impacts.hazard.event.attrs.river[1].shape_type = "gaussian" - test_scenario.direct_impacts.hazard.event.attrs.river[ - 1 - ].base_discharge = UnitfulDischarge(value=1000.0, units="cfs") - test_scenario.direct_impacts.hazard.event.attrs.river[ - 1 - ].shape_peak = UnitfulDischarge(value=2500.0, units="cfs") + test_scenario.direct_impacts.hazard.event.attrs.river[1].base_discharge = ( + UnitfulDischarge(value=1000.0, units="cfs") + ) + test_scenario.direct_impacts.hazard.event.attrs.river[1].shape_peak = ( + UnitfulDischarge(value=2500.0, units="cfs") + ) test_scenario.direct_impacts.hazard.event.attrs.river[1].shape_duration = 8 test_scenario.direct_impacts.hazard.event.attrs.river[1].shape_peak_time = 0 @@ -576,9 +576,9 @@ def test_multiple_rivers(test_db: None): test_scenario.direct_impacts.hazard.site.attrs.river[1].name = name test_scenario.direct_impacts.hazard.site.attrs.river[1].x_coordinate = x test_scenario.direct_impacts.hazard.site.attrs.river[1].y_coordinate = y - test_scenario.direct_impacts.hazard.site.attrs.river[ - 1 - ].mean_discharge = UnitfulDischarge(value=mean_discharge, units="cfs") + test_scenario.direct_impacts.hazard.site.attrs.river[1].mean_discharge = ( + UnitfulDischarge(value=mean_discharge, units="cfs") + ) test_scenario.direct_impacts.hazard.site.attrs.river[1].description = description # Change name of reference model