Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ The following aggregation functions are supported:
- ``sum``: return the sum of every group
- ``median``: return the median of every group
- ``p<QQ>``: return the QQ% percentile of every group. Two digits a required even for quantiles less than 10%, e.g., the 5% percentile should be requested as ``p05``.
- ``count``: return the number of elements of every group

There is also the pseudo-function ``stats``, which is essentially a shortcut for ``min,p01,p05,median,p95,p99,max,mean,std``.
It can also be applied to any other attribute than ``pval``
Expand Down Expand Up @@ -1664,7 +1665,7 @@ Note that parts that have a grammar defined elsewhere (e.g., Python attributes a
<aggr_spec> ::= <aggr_any> | <aggr_pval>
<aggr_any> ::= <aggr_fn> "(" <attr> ")"
<aggr_pval> ::= <aggr_fn>
<aggr_fn> ::= "first" | "last" | "max" | "min" | "mean" | "median" | "std" | "sum" | <quantile>
<aggr_fn> ::= "first" | "last" | "max" | "min" | "mean" | "median" | "std" | "sum" | <quantile> | "count"
<quantile> ::= "p" [0-9] [0-9]
<cols> ::= <extra_cols> | <explicit_cols>
<extra_cols> ::= ("+" <attr>)+
Expand Down
4 changes: 3 additions & 1 deletion reframe/frontend/reporting/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Aggregation:

AGG_REGEX = re.compile(r'(?P<op>\S+)\((?P<col>\S+)\)|(?P<op2>\S+)')
OP_REGEX = re.compile(
r'min|max|median|mean|std|first|last|sum|stats|p\d{2}'
r'min|max|median|mean|std|first|last|sum|stats|count|p\d{2}'
)
Q_REGEX = re.compile(r'p(\d{2})')

Expand Down Expand Up @@ -89,6 +89,8 @@ def _expr_from_op(col, op):
return pl.col(col).last().alias(f'{col} (last)')
elif op == 'sum':
return pl.col(col).sum().alias(f'{col} (sum)')
elif op == 'count':
return pl.col(col).count().alias(f'{col} (count)')
elif m := self.Q_REGEX.match(op):
perc = m.group(1)
if perc == '00':
Expand Down
6 changes: 5 additions & 1 deletion unittests/test_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ def test_parse_cmp_spec_period(time_period):

@pytest.fixture(params=['first', 'last', 'mean', 'median',
'min', 'max', 'std', 'stats', 'sum',
'p00', 'p01', 'p05', 'p95', 'p99'])
'p00', 'p01', 'p05', 'p95', 'p99',
'count'])
def aggregator(request):
return request.param

Expand Down Expand Up @@ -289,6 +290,9 @@ def test_parse_cmp_spec_aggregations(aggregator):
assert agg['pval (p95)'][0] == 10
elif aggregator == 'p05':
assert agg['pval (p99)'][0] == 10
elif aggregator == 'count':
assert 'pval (count)' in agg.columns

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to assert also the value here as with the other aggregations above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and done.

assert agg['pval (count)'][0] == num_recs

# Check variant without base period
match = parse_cmp_spec(f'now-1d:now/{aggregator}:/')
Expand Down
Loading