Skip to content

Commit

Permalink
Correcting comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre-Medina committed Dec 29, 2024
1 parent 983f696 commit eb2f45b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
31 changes: 29 additions & 2 deletions packages/electoralyze/electoralyze/region/redistribute/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,26 @@ def _get_remaining_area(
geometry: st.GeoDataFrame,
intersection_area: pl.DataFrame,
) -> pl.DataFrame:
"""Find remaining area which hasnt been assigned to another region."""
"""Find remaining area which hasn't been assigned to another region.
Returns
-------
pl.DataFrame, e.g.
```python
shape: (4, 3)
┌──────────┬──────────┬───────────────────┐
│ quadrant ┆ triangle ┆ intersection_area │
│ --- ┆ --- ┆ --- │
│ str ┆ str ┆ f64 │
╞══════════╪══════════╪═══════════════════╡
│ null ┆ A ┆ 2.0 │
│ O ┆ null ┆ 1.0 │
│ N ┆ null ┆ 1.0 │
│ P ┆ null ┆ 1.0 │
│ M ┆ null ┆ 1.0 │
└──────────┴──────────┴───────────────────┘
```
"""
alt_region_id = list(set(intersection_area.columns) - {region_id, "intersection_area"})[0]

intersected_area = intersection_area.group_by(region_id).agg(
Expand Down Expand Up @@ -265,7 +284,15 @@ def _get_region_mapping_file(
*,
mapping: MAPPING_OPTIONS,
) -> str:
"""Returns the path to the mapping file for the given region."""
"""Returns the path to the mapping file for the given region.
Returns
-------
str, path to the mapping file, e.g.
```python
".../data/regions/redistribute/intersection_area/quadrant/triangle.parquet"
```
"""
if region_from.id == region_to.id:
regions = [region_from.id] * 2
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def test_get_region_mapping_base(region_from: RegionABC, region_to: RegionABC, m
"sa_region, sa_subregion",
[
(region.SA2_2021, region.SA1_2021),
# (region.SA3_2021, region.SA2_2021),
# (region.SA4_2021, region.SA3_2021),
# (region.SA3_2021, region.SA2_2021), FIXME: Add more SA 2021 regions, issue #21
# (region.SA4_2021, region.SA3_2021), FIXME: Add more SA 2021 regions, issue #21
],
)
def test_SA_regions_are_subsets(sa_region: RegionABC, sa_subregion: RegionABC):
Expand Down

0 comments on commit eb2f45b

Please sign in to comment.