Skip to content

Commit

Permalink
Pass name as string instead of method to aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhuppmann committed Sep 1, 2023
1 parent 652ee27 commit c1a1e6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pyam/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
logger = logging.getLogger(__name__)


def _aggregate(df, variable, components=None, method=np.sum):
def _aggregate(df, variable, components=None, method="sum"):
"""Internal implementation of the `aggregate` function"""

if components is not None:
Expand Down Expand Up @@ -168,7 +168,7 @@ def _aggregate_region(
return _data


def _aggregate_time(df, variable, column, value, components, method=np.sum):
def _aggregate_time(df, variable, column, value, components, method="sum"):
"""Internal implementation for aggregating data over subannual time"""
# default `components` to all entries in `column` other than `value`
if components is None:
Expand Down Expand Up @@ -196,7 +196,7 @@ def _aggregate_time(df, variable, column, value, components, method=np.sum):
return _data


def _group_and_agg(df, by, method=np.sum):
def _group_and_agg(df, by, method="sum"):
"""Group-by & aggregate `pd.Series` by index names on `by`"""
cols = df.index.names.difference(to_list(by))
# pick aggregator func (default: sum)
Expand Down
4 changes: 2 additions & 2 deletions pyam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"max": np.max,
"avg": np.mean,
"mean": np.mean,
"sum": np.sum,
"sum": "sum",
}


Expand Down Expand Up @@ -546,7 +546,7 @@ def pattern_match(
if is_str(s):
pattern = re.compile(escape_regexp(s) + "$" if not regexp else s)
depth = True if level is None else find_depth(_data, s, level)
matches |= data.str.match(pattern) & depth
matches |= data.str.match(pattern) & np.array(depth)
else:
matches = np.logical_or(matches, data == s)

Expand Down

0 comments on commit c1a1e6d

Please sign in to comment.