Repository navigation
[Python] Add missing Histogram.p95 used by HistogramResult.p95 - #41710
leninworld wants to merge 1 commit into
Conversation
HistogramResult.p95 called Histogram.p95(), which did not exist, so reading .p95 on a histogram metric result raised AttributeError. Fixes apache#41709
There was a problem hiding this comment.
📋 Review Summary
This PR adds the missing Histogram.p95() method in apache_beam/utils/histogram.py, fixing an AttributeError when accessing HistogramResult.p95. The implementation is clean, consistent with the existing percentile methods (p99, p90, p50), and includes appropriate unit tests for both Histogram and HistogramResult.
🔍 General Feedback
- The fix directly resolves the broken
HistogramResult.p95property by delegating toself.get_linear_interpolation(0.95). - Unit test coverage in
histogram_test.pyandcells_test.pymatches existing test conventions and verifies the end-to-end property access.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
|
Assigning reviewers: R: @claudevdm for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Fixes #41709
HistogramResult.p95callsself.data.histogram.p95(), butHistogramhad nop95()method, so reading.p95on a histogram metric result raisedAttributeError. This addsHistogram.p95()next top50()/p90()/p99(), using the sameget_linear_interpolationcall.Testing
HistogramTest.test_p95(apache_beam/utils/histogram_test.py) andTestHistogramCell.test_result_p95(apache_beam/metrics/cells_test.py, theHistogramResult.p95path). Both fail onmasterwithAttributeError: 'Histogram' object has no attribute 'p95'and pass with the fix.pytest apache_beam/metrics apache_beam/utils/histogram_test.py: 91 passed.yapf --diff(0.43.0),ruff check(0.17.6) andwhitespacelintare clean on the changed files.