Skip to content

Commit

Permalink
Fix pydantic warnings (#308)
Browse files Browse the repository at this point in the history
* Fix pydantic warnings

* Fix pandas SettingWithCopyWarning
  • Loading branch information
phackstock committed Jan 22, 2024
1 parent 0b00734 commit 8c62eec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions nomenclature/processor/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,13 @@ def _compare_and_merge(
difference = compare[
~np.isclose(compare["original"], compare["aggregated"], rtol=rtol)
]
difference["difference (%)"] = 100 * np.abs(
(difference["original"] - difference["aggregated"]) / difference["original"]
difference.insert(
len(difference.columns),
"difference (%)",
100
* np.abs(
(difference["original"] - difference["aggregated"]) / difference["original"]
),
)
difference = difference.sort_values("difference (%)", ascending=False)
if difference is not None and len(difference):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_region_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_mapping():
],
"exclude_regions": None,
}
assert obs.dict() == exp
assert obs.model_dump() == exp


@pytest.mark.parametrize(
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_region_processor_working(region_processor_path, simple_definition):
exp_dict = {value["model"][0]: value for value in exp_data}

assert exp_models == set(obs.mappings.keys())
assert all(exp_dict[m] == obs.mappings[m].dict() for m in exp_models)
assert all(exp_dict[m] == obs.mappings[m].model_dump() for m in exp_models)


def test_region_processor_not_defined(simple_definition):
Expand Down

0 comments on commit 8c62eec

Please sign in to comment.