Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update error message for empty dataframe #107

Merged
merged 5 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion nomenclature/processor/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ def apply(self, df: IamDataFrame, dsd: DataStructureDefinition) -> IamDataFrame:

if not processed_dfs:
raise ValueError(
f"The region aggregation for model {model} resulted in an empty dataset"
f"The region aggregation for model(s) {df.model} resulted in an empty "
"dataset."
phackstock marked this conversation as resolved.
Show resolved Hide resolved
)

return pyam.concat(processed_dfs)
Expand Down
4 changes: 4 additions & 0 deletions tests/data/region_processing/rename_only/model_b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
model: model_b
native_regions:
- region_a: region_A
- region_B
10 changes: 8 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ def test_region_processing_empty_raises():
pd.DataFrame(
[
["model_a", "scen_a", "region_foo", "Primary Energy", "EJ/yr", 1, 2],
["model_b", "scen_a", "region_foo", "Primary Energy", "EJ/yr", 1, 2],
],
columns=IAMC_IDX + [2005, 2010],
)
)

with pytest.raises(ValueError, match="The region aggregation for model model_a"):
with pytest.raises(
ValueError,
match=(
phackstock marked this conversation as resolved.
Show resolved Hide resolved
"region aggregation for model\(s\) \['model_a', 'model_b'\] resulted in an "
"empty dataset"
),
):
process(
test_df,
DataStructureDefinition(TEST_DATA_DIR / "region_processing/dsd"),
Expand Down