Skip to content

Commit

Permalink
Update pyam-imports prior to pyam v2.0 (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann authored Aug 21, 2023
1 parent 226b13e commit 14f1261
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions nomenclature/code.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json
import re
import pyam
import pycountry
from keyword import iskeyword
from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Union

from pydantic import BaseModel, Field, validator

from pyam.utils import to_list


class Code(BaseModel):
"""A simple class for a mapping of a "code" to its attributes"""
Expand Down Expand Up @@ -230,7 +230,7 @@ def check_iso3_codes(cls, v, values) -> List[str]:
"""Verifies that each ISO3 code is valid according to pycountry library."""
if invalid_iso3_codes := [
iso3_code
for iso3_code in pyam.to_list(v)
for iso3_code in to_list(v)
if pycountry.countries.get(alpha_3=iso3_code) is None
]:
raise ValueError(
Expand Down
3 changes: 2 additions & 1 deletion nomenclature/validation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from pyam import IamDataFrame, to_list
from pyam import IamDataFrame
from pyam.utils import to_list

# define logger for this script at logging level INFO
logger = logging.getLogger(__name__)
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import pytest
import shutil
import pandas as pd
from pyam import IamDataFrame, IAMC_IDX
from pyam import IamDataFrame
from pyam.utils import IAMC_IDX
from nomenclature import DataStructureDefinition


Expand Down
3 changes: 2 additions & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from nomenclature.core import process
from nomenclature.definition import DataStructureDefinition
from nomenclature.processor.region import RegionProcessor
from pyam import IAMC_IDX, IamDataFrame, assert_iamframe_equal
from pyam import IamDataFrame, assert_iamframe_equal
from pyam.utils import IAMC_IDX

from conftest import TEST_DATA_DIR, add_meta

Expand Down
3 changes: 2 additions & 1 deletion tests/test_region_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
process,
)
from nomenclature.error.region import RegionAggregationMappingParsingError
from pyam import IAMC_IDX, IamDataFrame
from pyam import IamDataFrame
from pyam.utils import IAMC_IDX

from conftest import TEST_DATA_DIR, clean_up_external_repos

Expand Down

0 comments on commit 14f1261

Please sign in to comment.