Skip to content

Commit

Permalink
combiners: Fix 99th percentile calculation when we don't have NumPy
Browse files Browse the repository at this point in the history
The 99th percentile calculation relied on the NumPy percentile() function,
which means the default output now breaks if there is no numpy available.
Fix this by adding an alternative implementation that doesn't rely on
NumPy (similar to other combiners).

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
  • Loading branch information
tohojo committed Nov 2, 2022
1 parent 4d97979 commit 689f837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Changes since v2.1.0 include:

- Fix crash on summary output when numpy is not installed.

# Flent v2.1.0 #
Released on 2022-11-02.

Expand Down
6 changes: 6 additions & 0 deletions flent/combiners.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ class Pct99Reducer(TryReducer):
raw_key = "pct99"

def _reduce(self, data):
if not HAS_NUMPY:
return sorted(data)[-(len(data) // 100 + 1)]

return np.percentile(data, 99)

class CumsumReducer(TryReducer):
Expand Down Expand Up @@ -740,6 +743,9 @@ def _reduce(self, data):
class RawPct99Reducer(RawReducer):

def _reduce(self, data):
if not HAS_NUMPY:
return sorted(data)[-(len(data) // 100 + 1)]

return np.percentile(data, 99)

class RawCumsumReducer(RawReducer):
Expand Down

0 comments on commit 689f837

Please sign in to comment.