Skip to content

Commit

Permalink
Fix black
Browse files Browse the repository at this point in the history
  • Loading branch information
dladrichem committed Feb 6, 2024
1 parent 0008235 commit 522495f
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 87 deletions.
158 changes: 104 additions & 54 deletions flood_adapt/object_model/interface/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,161 +23,211 @@ 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:
...
22 changes: 15 additions & 7 deletions flood_adapt/object_model/interface/measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
UnitfulLength,
UnitfulLengthRefValue,
UnitfulVolume,
UnitTypesLength,
UnitTypesVolume,
)

Expand Down Expand Up @@ -74,14 +73,14 @@ def validate_polygon_file(
cls, polygon_file: Optional[str], values: Any
) -> Optional[str]:
if (
values.get("selection_type") not in [SelectionType.aggregation_area, SelectionType.all]
values.get("selection_type")
not in [SelectionType.aggregation_area, SelectionType.all]
and polygon_file is None
):
raise ValueError(
"If `selection_type` is not 'aggregation_area' or 'all', then `polygon_file` needs to be set."
)
return polygon_file



class ImpactMeasureModel(MeasureModel):
Expand Down Expand Up @@ -163,11 +162,16 @@ class GreenInfrastructureModel(HazardMeasureModel):
aggregation_area_name: Optional[str] = None
percent_area: Optional[float] = None


@validator("type", always=True)
def validate_type(cls, type: HazardType, values: Any) -> HazardType:
if type not in [HazardType.water_square, HazardType.greening, HazardType.total_storage]:
raise ValueError("Type must be one of 'water_square', 'greening', or 'total_storage'")
if type not in [
HazardType.water_square,
HazardType.greening,
HazardType.total_storage,
]:
raise ValueError(
"Type must be one of 'water_square', 'greening', or 'total_storage'"
)
return type

@validator("volume")
Expand All @@ -194,7 +198,10 @@ def validate_height(
def validate_percent_area(
cls, percent_area: Optional[float], values: Any
) -> Optional[float]:
if values.get("type", "") in [HazardType.total_storage , HazardType.water_square]:
if values.get("type", "") in [
HazardType.total_storage,
HazardType.water_square,
]:
if percent_area is not None:
raise ValueError(
"Percent area cannot be set for total storage or water square type measures"
Expand Down Expand Up @@ -232,6 +239,7 @@ def validate_aggregation_area_type(
)
return aggregation_area_type


class IMeasure(ABC):
"""This is a class for a FloodAdapt measure"""

Expand Down
3 changes: 2 additions & 1 deletion flood_adapt/object_model/interface/scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ def save(self, filepath: Union[str, os.PathLike]):
...

@abstractmethod
def run(self) -> None: ...
def run(self) -> None:
...
12 changes: 6 additions & 6 deletions flood_adapt/object_model/interface/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down
Loading

0 comments on commit 522495f

Please sign in to comment.