Skip to content

Commit

Permalink
Merge branch 'main' into feature/require
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Dec 12, 2022
2 parents d5465dd + df1df1c commit ff97338
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Expand Up @@ -7,7 +7,8 @@ Bump minimum version of **pandas** to v1.2.0 to support automatic engine selecti

## Individual updates

- [#715](https://github.com/IAMconsortium/pyam/pull/715) Add a `require_data()` method
- [#715](https://github.com/IAMconsortium/pyam/pull/715) Add a `require_data()` method
- [#713](https://github.com/IAMconsortium/pyam/pull/713) Informative error when using lists for filter by level, `level` now a forbidden column.
- [#709](https://github.com/IAMconsortium/pyam/pull/709) Hotfix ops to support `fillna=0`
- [#708](https://github.com/IAMconsortium/pyam/pull/708) Remove 'xls' as by-default-supported file format

Expand Down
2 changes: 1 addition & 1 deletion pyam/_style.py
Expand Up @@ -50,7 +50,7 @@ def _get_standard_colors(
elif color_type == "random":

def random_color(column):
""" Returns a random color represented as a list of length 3"""
"""Returns a random color represented as a list of length 3"""
# GH17525 use common._random_state to avoid resetting the seed
rs = com.random_state(column)
return rs.rand(3).tolist()
Expand Down
7 changes: 6 additions & 1 deletion pyam/utils.py
Expand Up @@ -31,7 +31,7 @@
REQUIRED_COLS = ["region", "variable", "unit"]

# illegal terms for data/meta column names to prevent attribute conflicts
ILLEGAL_COLS = ["data", "meta"]
ILLEGAL_COLS = ["data", "meta", "level"]

# dictionary to translate column count to Excel column names
NUMERIC_TO_STR = dict(
Expand Down Expand Up @@ -428,6 +428,11 @@ def find_depth(data, s="", level=None):
whether depth satisfies the condition (equality if level is int,
>= if ``.+``, <= if ``.-``)
"""
if islistable(level):
raise ValueError(
"Level is only run with ints or strings, not lists. Use strings with "
"integers and + or - to filter by ranges."
)
if isstr(data):
return _find_depth([data], s, level)[0]

Expand Down
5 changes: 5 additions & 0 deletions tests/test_core.py
Expand Up @@ -383,6 +383,11 @@ def test_variable_depth_raises(test_df):
pytest.raises(ValueError, test_df.filter, level="1/")


def test_variable_depth_with_list_raises(test_df):
pytest.raises(ValueError, test_df.filter, level=["1", "2"])
pytest.raises(ValueError, test_df.filter, level=[1, 2])


def test_timeseries(test_df):
dct = {
"model": ["model_a"] * 2,
Expand Down

0 comments on commit ff97338

Please sign in to comment.