fix(aggregations): guard mean_of_measurement against empty measurements - #1608
Open
WatchTree-19 wants to merge 1 commit into
Open
fix(aggregations): guard mean_of_measurement against empty measurements#1608WatchTree-19 wants to merge 1 commit into
WatchTree-19 wants to merge 1 commit into
Conversation
mean_of_measurement divided by len(measurements) with no empty guard, so a test whose aggregate_measurements() receives no measured items (e.g. every item errored or was filtered) raised ZeroDivisionError instead of producing a score. Its sibling MeasurementStats.calculate already returns mean 0 for an empty input; mean_of_measurement now does the same. Adds regression tests. Signed-off-by: WatchTree-19 <119982314+WatchTree-19@users.noreply.github.com>
|
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
This was referenced Aug 29, 2026
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Could an empty set remain distinguishable from a measured zero? Returning 0.0 means an all-error or all-filtered run becomes a valid zero measurement. For safety benchmarks that can make missing coverage look benign and bias aggregates. I would prefer NaN / None, or an explicit no-data result, rather than converting absence of evidence into a score.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
what
mean_of_measurementdivides bylen(measurements)with no empty guard:so a test whose
aggregate_measurements()receives no measured items - e.g. every item errored or was filtered out - raisesZeroDivisionErrorinstead of producing a score, crashing aggregation/reporting.its sibling in the same module,
MeasurementStats.calculate, already guards this and returns mean0for an empty input.mean_of_measurementnow does the same, keeping the two consistent.fix
return
0.0when there are no measurements. adds regression tests (test_mean_of_measurementandtest_mean_of_measurement_no_measurements) - the empty case raisesZeroDivisionErroronmainand passes with the change. black clean, DCO signed.