From fd261c94cbf16d5a6b98465b84830e6c429a5cfc Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Tue, 18 Jun 2024 10:23:40 +0200 Subject: [PATCH 1/5] who needs pandas anyway? --- src/radical/analytics/utils/plot.py | 38 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/radical/analytics/utils/plot.py b/src/radical/analytics/utils/plot.py index c776219..3123c86 100644 --- a/src/radical/analytics/utils/plot.py +++ b/src/radical/analytics/utils/plot.py @@ -1,9 +1,12 @@ + import os import sys import glob import functools -import pandas as pd -import matplotlib as mpl + +import pandas as pd +import numpy as np +import matplotlib as mpl import radical.utils as ru @@ -74,7 +77,7 @@ def get_mplstyle(name): # ------------------------------------------------------------------------------ # def stack_transitions(series, tresource, to_stack): - '''Creates data frames for each metric and combines them into one data frame + '''Creates time series for each metric and combines them into one data frame for alignment. Since transitions obviously happen at arbitrary times, the timestamps for metric A may see no transitions for metric B. When using a combined timeline, we end up with NaN entries for some metrics on most @@ -103,19 +106,26 @@ def stack_transitions(series, tresource, to_stack): that point in time. ''' - dfs = [pd.DataFrame(series[tresource][m], columns=['time', m]) - for m in series[tresource]] + # find the global time line + glob_times = set() + for m,df in series[tresource].items(): + for t,_ in df: + glob_times.add(t) + + glob_times = sorted(glob_times) + + # create a timeline for each metric, set missing values as NaN + tlines = dict() + tlines['time'] = glob_times + for m in series[tresource]: + tlines[m] = [np.nan] * len(glob_times) - # merge them into one data frame, creating a common time-line - merged = functools.reduce(lambda left, right: - pd.merge(left, right, - left_on='time', - right_on='time', - how='outer'), dfs) - # sort the global time line - merged.sort_values(by='time', inplace=True) + for t,v in series[tresource][m]: + t_idx = glob_times.index(t) + tlines[m][t_idx] = v - # fill in missing values (carry over previous ones) + # create dataframe and fill all NaN values with the previous valid value + merged = pd.DataFrame(tlines) merged.fillna(method='ffill', inplace=True) # stacked plotting and area filling don't play well together in matplotlib. From c21db693a00aad78d2c202993ae2ee9d8a1abf6a Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Tue, 18 Jun 2024 10:41:36 +0200 Subject: [PATCH 2/5] avoid deprecation warning --- src/radical/analytics/utils/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/radical/analytics/utils/plot.py b/src/radical/analytics/utils/plot.py index 3123c86..50d126a 100644 --- a/src/radical/analytics/utils/plot.py +++ b/src/radical/analytics/utils/plot.py @@ -126,7 +126,7 @@ def stack_transitions(series, tresource, to_stack): # create dataframe and fill all NaN values with the previous valid value merged = pd.DataFrame(tlines) - merged.fillna(method='ffill', inplace=True) + merged.ffill(inplace=True) # stacked plotting and area filling don't play well together in matplotlib. # Instead we use normal (unstacked) plot routines and fill in between, we From 56611bec096beb85e26b3ef5723d61dab15ce8bc Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Wed, 19 Jun 2024 11:10:11 +0200 Subject: [PATCH 3/5] fix xticks --- bin/rp_inspect/plot_util_2.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/rp_inspect/plot_util_2.py b/bin/rp_inspect/plot_util_2.py index 693f073..e36c7c2 100755 --- a/bin/rp_inspect/plot_util_2.py +++ b/bin/rp_inspect/plot_util_2.py @@ -265,6 +265,7 @@ def main(): for ax in fig.get_axes(): ax.label_outer() + plt.setp(ax.get_xticklabels(), visible=True) # Title of the plot fig.suptitle(to_latex('%s Tasks - %s Nodes' % (n_tasks, n_nodes))) From b13fa18c2388b87b7816d9013bd24b71a22722d9 Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Wed, 19 Jun 2024 12:09:55 +0200 Subject: [PATCH 4/5] hmpf --- bin/rp_inspect/plot_util_2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/rp_inspect/plot_util_2.py b/bin/rp_inspect/plot_util_2.py index e36c7c2..693f073 100755 --- a/bin/rp_inspect/plot_util_2.py +++ b/bin/rp_inspect/plot_util_2.py @@ -265,7 +265,6 @@ def main(): for ax in fig.get_axes(): ax.label_outer() - plt.setp(ax.get_xticklabels(), visible=True) # Title of the plot fig.suptitle(to_latex('%s Tasks - %s Nodes' % (n_tasks, n_nodes))) From b3f9cca04e213cd2196f545d8d1fa7cdecd4c02a Mon Sep 17 00:00:00 2001 From: Andre Merzky Date: Wed, 26 Jun 2024 00:48:29 +0200 Subject: [PATCH 5/5] linting --- src/radical/analytics/utils/plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/radical/analytics/utils/plot.py b/src/radical/analytics/utils/plot.py index 50d126a..f96e505 100644 --- a/src/radical/analytics/utils/plot.py +++ b/src/radical/analytics/utils/plot.py @@ -2,7 +2,6 @@ import os import sys import glob -import functools import pandas as pd import numpy as np