Skip to content

Commit

Permalink
ran black PyDocStyle fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kieran-Fishwick-TfN committed Oct 30, 2024
1 parent 5fa2e37 commit 269942c
Showing 1 changed file with 39 additions and 9 deletions.
48 changes: 39 additions & 9 deletions src/caf/distribute/gravity_model/multi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class MultiDistInput(BaseConfig):

@dataclass
class GMCalibParams:
"""Parameters required for the multi tld gravity mode calibrate method
"""Parameters required for the multi tld gravity mode calibrate method.
All of the arguements have defaults, i.e. you can create the default object with
no arguements. HOWEVER, read the parameter section below, it is important to
Expand Down Expand Up @@ -166,7 +166,7 @@ class GMCalibParams:

@dataclass
class MultiCostDistribution:
"""Cost distributions to be used for the multi-cost distribution gravity model
"""Cost distributions to be used for the multi-cost distribution gravity model.
Parameters
----------
Expand All @@ -192,7 +192,7 @@ def from_pandas(
lookup_cat_col: str = "category",
lookup_zone_col: str = "zone_id",
) -> MultiCostDistribution:
"""constructor using pandas dataframes
"""Build class using pandas dataframes.
Parameters
----------
Expand Down Expand Up @@ -266,7 +266,10 @@ def from_pandas(

@classmethod
def validate(cls, distributions: list[MGMCostDistribution]):
"""Validates the distributions passed
"""Checks the distributions passed.
Raises an error if duplicate zones are found across different
distributions.
Parameters
----------
Expand Down Expand Up @@ -298,17 +301,43 @@ def validate(cls, distributions: list[MGMCostDistribution]):
raise ValueError("duplicate found in the distribution zone definition")

Check warning on line 301 in src/caf/distribute/gravity_model/multi_area.py

View check run for this annotation

Codecov / codecov/patch

src/caf/distribute/gravity_model/multi_area.py#L301

Added line #L301 was not covered by tests

def __iter__(self) -> Iterator[MGMCostDistribution]:
"""Iterates through each distribution.
Yields
------
Iterator[MGMCostDistribution]
iterator for the cost distributions.
"""
yield from self.distributions

def __getitem__(self, x) -> MGMCostDistribution:
def __getitem__(self, x: int) -> MGMCostDistribution:
"""Retrieves the xth distribution.
Parameters
----------
x : int
index of the distribution to retreive
Returns
-------
MGMCostDistribution
the xth distrubtion.
"""
return self.distributions[x]

def __len__(self) -> int:
return len(self.distributions)
"""The number of distrubtions.
Returns
-------
int
The number of distrubtions.
"""
return len(self.distributions)

def copy(self) -> MultiCostDistribution:
"""
"""A wrapper around deepcopy.
Returns
-------
MultiCostDistribution
Expand Down Expand Up @@ -369,7 +398,7 @@ def from_pandas(
lookup_cat_col: str = "category",
lookup_zone_col: str = "zone_id",
) -> MGMCostDistribution:
"""constructor that uses pandas dataframes and series
"""Build using pandas dataframes and series.
Parameters
----------
Expand Down Expand Up @@ -574,6 +603,7 @@ def calibrate(
defines the detailed parameters, see `GMCalibParams` documentation for more info
*args,
**kwargs,
Returns
-------
dict[str | int, GravityModelCalibrateResults]:
Expand Down Expand Up @@ -832,7 +862,7 @@ def _gravity_function(
self._loop_start_time = timing.current_milli_time()

self.achieved_cost_dist: list[cost_utils.CostDistribution] = distributions
self.achieved_convergence: dict[str|int, float] = convergences
self.achieved_convergence: dict[str | int, float] = convergences
self.achieved_distribution = matrix

achieved_residuals = np.concatenate(residuals)
Expand Down

0 comments on commit 269942c

Please sign in to comment.