Skip to content

Commit

Permalink
event: added kwargs in instantiate methods (#103)
Browse files Browse the repository at this point in the history
Co-authored-by: sjuhel <pro@sjuhel.org>
  • Loading branch information
spjuhel and sjuhel authored Apr 16, 2024
1 parent 634f15a commit fe4754a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions boario/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def _instantiate(
occurrence: int = 1,
duration: int = 1,
name: Optional[str] = None,
**kwargs,
):
return cls(impact=impact, occurrence=occurrence, duration=duration, name=name)

Expand All @@ -201,7 +202,7 @@ def from_series(
occurrence: int = 1,
duration: int = 1,
name: Optional[str] = None,
**kwarg,
**kwargs,
) -> Event:
"""Create an event for an impact given as a pd.Series.
Expand All @@ -215,7 +216,7 @@ def from_series(
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
name : Optional[str]
A possible name for the event, for convenience. Defaults to None.
**kwarg :
**kwargs :
Keyword arguments keyword arguments to pass to the instantiating method
(depends on the type of event).
Expand Down Expand Up @@ -260,7 +261,7 @@ def from_series(
occurrence=occurrence,
duration=duration,
name=name,
**kwarg,
**kwargs,
)

@classmethod
Expand All @@ -271,7 +272,7 @@ def from_dataframe(
occurrence: int = 1,
duration: int = 1,
name: Optional[str] = None,
**kwarg,
**kwargs,
) -> Event:
"""Convenience function for DataFrames. See :meth:`~boario.event.Event.from_series`. This constructor only apply ``.squeeze()`` to the given DataFrame.
Expand All @@ -285,7 +286,7 @@ def from_dataframe(
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
name : Optional[str]
A possible name for the event, for convenience. Defaults to None.
**kwarg :
**kwargs :
Keyword arguments
Other keyword arguments to pass to the instantiate method (depends on the type of event)
Expand All @@ -308,7 +309,7 @@ def from_dataframe(
occurrence=occurrence,
duration=duration,
name=name,
**kwarg,
**kwargs,
)

@classmethod
Expand Down Expand Up @@ -365,7 +366,7 @@ def from_scalar_industries(
occurrence: Optional[int] = 1,
duration: Optional[int] = 1,
name: Optional[str] = None,
**kwarg,
**kwargs,
) -> Event:
"""Creates an Event from a scalar and a list of industries affected.
Expand All @@ -390,7 +391,7 @@ def from_scalar_industries(
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
name : Optional[str]
A possible name for the event, for convenience. Defaults to None.
**kwarg :
**kwargs :
Keyword arguments
Other keyword arguments to pass to the instantiate method (depends on the type of event)
Expand Down Expand Up @@ -435,7 +436,7 @@ def from_scalar_industries(
occurrence=occurrence,
duration=duration,
name=name,
**kwarg,
**kwargs,
)

@classmethod
Expand All @@ -450,7 +451,7 @@ def from_scalar_regions_sectors(
occurrence: int = 1,
duration: int = 1,
name: Optional[str] = None,
**kwarg,
**kwargs,
) -> Event:
"""Creates an Event from a scalar, a list of regions and a list of sectors affected.
Expand All @@ -477,7 +478,7 @@ def from_scalar_regions_sectors(
The duration of the event (entire impact applied during this number of steps). Defaults to 1.
name : Optional[str], optional
A possible name for the event, for convenience. Defaults to None.
**kwarg :
**kwargs :
Keyword arguments
Other keyword arguments to pass to the instantiate method (depends on the type of event)
Expand Down Expand Up @@ -592,7 +593,7 @@ def from_scalar_regions_sectors(
occurrence=occurrence,
duration=duration,
name=name,
**kwarg,
**kwargs,
)

@property
Expand Down Expand Up @@ -847,6 +848,7 @@ def _instantiate(
occurrence: int = 1,
duration: int = 1,
name: Optional[str] = None,
**kwargs,
):
return cls(
impact=impact,
Expand Down Expand Up @@ -1236,6 +1238,7 @@ def _instantiate(
rebuild_tau: int,
rebuilding_sectors: dict[str, float] | pd.Series,
rebuilding_factor: float = 1.0,
**kwargs,
):
return cls(
impact=impact,
Expand Down Expand Up @@ -1415,6 +1418,7 @@ def _instantiate(
event_monetary_factor: Optional[int] = None,
recovery_time: int,
recovery_function: str = "linear",
**kwargs,
):
return cls(
impact=impact,
Expand Down

0 comments on commit fe4754a

Please sign in to comment.