Skip to content

Commit

Permalink
Merge pull request #144 from psyinfra/fix-ram-histogram
Browse files Browse the repository at this point in the history
fixes #2 using mean of y_values in a certain range
  • Loading branch information
mathisloevenich authored Nov 25, 2021
2 parents 62d8b8a + 61a06d2 commit 95e15e4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions htcanalyze/log_analyzer/condor_log/ram_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ class RamHistory(ReprObject):
def __init__(self, image_size_events: List[ImageSizeEvent]):
self.image_size_events = image_size_events

@staticmethod
def mean_y_value(y_values, min_, max_):
"""Callback method for y-ticks."""
y_selected = [y for y in y_values if min_ <= y < max_]
if y_selected:
# if there are some Y values in that range
# show the average
return sum(y_selected) / len(y_selected)
# default is showing the lower end of the range
return min_

def plot_ram(self, show_legend=False) -> str:
"""
Creates a str with a histogram that can be printed to the command line.
Expand All @@ -52,6 +63,7 @@ def plot_ram(self, show_legend=False) -> str:

# else
fig = Figure()
fig.y_ticks_fkt = lambda x, y: self.mean_y_value(ram, x, y)
fig.width = 55
fig.height = 15
fig.set_x_limits(min_=min(dates))
Expand Down

0 comments on commit 95e15e4

Please sign in to comment.