Skip to content

Commit 57df973

Browse files
committed
update function param of get_area_weighted_series_df to allow multiple regions
1 parent 341cc7f commit 57df973

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

groclient/client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ def reverse_geocode_points(self, points: list):
19951995
def get_area_weighted_series_df(
19961996
self,
19971997
series: Dict[str, int],
1998-
region_id: int,
1998+
region_ids: List[int],
19991999
weights: Optional[List[Dict[str, int]]] = None,
20002000
weight_names: Optional[List[str]] = None,
20012001
start_date: Optional[str] = None,
@@ -2011,8 +2011,8 @@ def get_area_weighted_series_df(
20112011
series: dict
20122012
A dictionary that maps required entity types to its value.
20132013
e.g. {"item_id": 321, "metric_id": 70029, "frequency_id": 3, "source_id": 3}
2014-
region_id: integer
2015-
The region for which the weighted series will be computed
2014+
region_ids: list of integer
2015+
The selected regions for which the weighted series will be computed
20162016
Supported region levels are (1, 2, 3, 4, 5, 8)
20172017
weights: list of dict
20182018
A list of dictionaries with each representing a weight object. Mutually exclusive with "weight_names".
@@ -2041,7 +2041,7 @@ def get_area_weighted_series_df(
20412041
self.access_token,
20422042
self.api_host,
20432043
series,
2044-
region_id,
2044+
region_ids,
20452045
weights,
20462046
weight_names,
20472047
start_date,

groclient/client_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ def test_get_area_weighted_series_df(self):
725725
"frequency_id": 3,
726726
"source_id": 3
727727
},
728-
"region_id": 1215,
728+
"region_ids": [1215],
729729
"weight_names": ["Wheat"],
730730
"start_date": "2023-10-01"
731731
}

groclient/lib.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -883,15 +883,15 @@ def validate_series_object(series_object):
883883

884884
def generate_payload_for_v2_area_weighting(
885885
series: Dict[str, int],
886-
region_id: int,
886+
region_ids: List[int],
887887
weights: Optional[List[Dict[str, int]]] = None,
888888
weight_names: Optional[List[str]] = None,
889889
start_date: Optional[str] = None,
890890
end_date: Optional[str] = None,
891891
method: Optional[str] = "sum",
892892
):
893893
payload = {
894-
"region_id": region_id,
894+
"region_ids": region_ids,
895895
"method": method,
896896
}
897897

@@ -959,7 +959,7 @@ def get_area_weighted_series_df(
959959
access_token: str,
960960
api_host: str,
961961
series: Dict[str, int],
962-
region_id: int,
962+
region_ids: List[int],
963963
weights: Optional[List[Dict[str, int]]] = None,
964964
weight_names: Optional[List[str]] = None,
965965
start_date: Optional[str] = None,
@@ -968,7 +968,7 @@ def get_area_weighted_series_df(
968968
) -> pd.DataFrame:
969969
payload = generate_payload_for_v2_area_weighting(
970970
series,
971-
region_id,
971+
region_ids,
972972
weights,
973973
weight_names,
974974
start_date,

groclient/lib_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ def test_get_area_weighted_series_df(mock_requests_post):
12281228
"frequency_id": 3,
12291229
"source_id": 3
12301230
},
1231-
"region_id": 1215,
1231+
"region_ids": [1215],
12321232
"weight_names": ["Corn", "Wheat"],
12331233
"start_date": "2023-10-01"
12341234
}

0 commit comments

Comments
 (0)