Skip to content

Commit

Permalink
Add type hints to Forecast.__init__ and update docstring (#574)
Browse files Browse the repository at this point in the history
* Add type hints to Forecast.__init__ and update docstring

* Update climada/engine/forecast.py

Co-authored-by: Lukas Riedel <34276446+peanutfun@users.noreply.github.com>

Co-authored-by: emanuel-schmid <schmide@ethz.ch>
Co-authored-by: Emanuel Schmid <51439563+emanuel-schmid@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 3, 2022
1 parent 5c51288 commit 67ed85f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions climada/engine/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import logging
import datetime as dt
from typing import Dict, Optional
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
Expand All @@ -35,6 +36,9 @@
from cartopy.io import shapereader
from mpl_toolkits.axes_grid1 import make_axes_locatable

from climada.hazard import Hazard
from climada.entity import Exposures
from climada.entity.impact_funcs import ImpactFuncSet
from climada.engine import ImpactCalc
import climada.util.plot as u_plot
from climada.util.config import CONFIG
Expand Down Expand Up @@ -130,7 +134,12 @@ class Forecast:
"""

def __init__(
self, hazard_dict, exposure, impact_funcs, haz_model="NWP", exposure_name=None
self,
hazard_dict: Dict[str, Hazard],
exposure: Exposures,
impact_funcs: ImpactFuncSet,
haz_model: str = "NWP",
exposure_name: Optional[str] = None
):
"""Initialization with hazard, exposure and vulnerability.
Expand All @@ -144,15 +153,18 @@ def __init__(
as long as the attribute Hazard.date is the same for all
events. Several run_datetime:Hazard combinations for the same
event can be provided.
exposure : Exposure
exposure : Exposures
impact_funcs : ImpactFuncSet
haz_model : str, optional
Short string specifying the model used to create the hazard,
if possible three big letters. Default is 'NWP' for numerical
weather prediction.
exposure_name : str, optional
string specifying the exposure (e.g. 'EU'), which is used to
name output files.
name output files. If ``None``, the name will be inferred from the Exposures
GeoDataframe ``region_id`` column, using the corresponding name of the region
with the lowest ISO 3166-1 numeric code. If that fails, it defaults to
``"custom"``.
"""
self.run_datetime = list(hazard_dict.keys())
self.hazard = list(hazard_dict.values())
Expand Down

0 comments on commit 67ed85f

Please sign in to comment.