Skip to content

Commit

Permalink
Updated percentile.py to allow user defined percentiles, and separati…
Browse files Browse the repository at this point in the history
…ng calculated values into separate columns (LLNL#103)

* Changed percentiles.py to take in custom values, and split calulated values into seperate columns

* Updated doc string for function

* Updated percentile.py to pass black and flake8

* Updating percentile unit testing

* Updated formatting for unit testing

* code cleanup

* percentiles: add test for percentiles=None

---------

Co-authored-by: Stephanie Brink <[email protected]>
  • Loading branch information
2 people authored and Yejashi committed Mar 6, 2024
1 parent 22df8ef commit a23f568
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
5 changes: 2 additions & 3 deletions thicket/stats/percentiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@


def percentiles(thicket, columns=None, percentiles=[0.25, 0.50, 0.75]):
"""
Calculate the q-th percentile for each node in the performance data table.
"""Calculate the q-th percentile for each node in the performance data table.
Designed to take in a thicket, and append one or more columns to the aggregated
statistics table for the q-th percentile calculation for each node. Each percentile
Expand Down Expand Up @@ -76,7 +75,7 @@ def percentiles(thicket, columns=None, percentiles=[0.25, 0.50, 0.75]):
and column_to_append not in thicket.statsframe.exc_metrics
):
thicket.statsframe.exc_metrics.append(column_to_append)
# check to see if inclusive metric
# check inclusive metrics
elif (
column in thicket.inc_metrics
and column_to_append not in thicket.statsframe.inc_metrics
Expand Down
40 changes: 40 additions & 0 deletions thicket/tests/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,46 @@ def test_percentiles_columnar_join(thicket_axis_columns):
combined_th, columns=[(idx, "Min time/rank")], percentiles=[0.4]
)

assert (
idx,
"Min time/rank_percentiles_25",
) in combined_th.statsframe.dataframe.columns
assert (
idx,
"Min time/rank_percentiles_50",
) in combined_th.statsframe.dataframe.columns
assert (
idx,
"Min time/rank_percentiles_75",
) in combined_th.statsframe.dataframe.columns
assert (
idx,
"Min time/rank_percentiles_25",
) in combined_th.statsframe.exc_metrics + combined_th.statsframe.inc_metrics
assert (
idx,
"Min time/rank_percentiles_50",
) in combined_th.statsframe.exc_metrics + combined_th.statsframe.inc_metrics
assert (
idx,
"Min time/rank_percentiles_75",
) in combined_th.statsframe.exc_metrics + combined_th.statsframe.inc_metrics

assert (
idx,
"Min time/rank_percentiles_25",
) in combined_th.statsframe.show_metric_columns()
assert (
idx,
"Min time/rank_percentiles_50",
) in combined_th.statsframe.show_metric_columns()
assert (
idx,
"Min time/rank_percentiles_75",
) in combined_th.statsframe.show_metric_columns()

th.percentiles(combined_th, columns=[(idx, "Min time/rank")], percentiles=[0.4])

assert (
idx,
"Min time/rank_percentiles_40",
Expand Down

0 comments on commit a23f568

Please sign in to comment.