Skip to content

Commit 8ba8db0

Browse files
committed
MAINT: move DarshanReportTable
* Fixes #892 * move `DarshanReportTable` to a more general location for reuse in the CLI/summary report machinery * I'm not sure it really makes sense to generate potential merge conflicts for such a small adjustment at this stage relative to other priorities, but here it is if you want the cleanup
1 parent a60594d commit 8ba8db0

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

darshan-util/pydarshan/darshan/cli/summary.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626
darshan.enable_experimental()
2727

2828

29+
class DarshanReportTable:
30+
"""
31+
Stores table figures in dataframe and html formats.
32+
33+
Parameters
34+
----------
35+
df: a ``pd.DataFrame``.
36+
37+
kwargs: keyword arguments passed to ``pd.DataFrame.to_html()``.
38+
39+
"""
40+
def __init__(self, df: Any, **kwargs):
41+
self.df = df
42+
self.html = self.df.to_html(**kwargs)
43+
44+
2945
class ReportFigure:
3046
"""
3147
Stores info for each figure in `ReportData.register_figures`.
@@ -100,7 +116,7 @@ def generate_fig(self):
100116
encoded = self.get_encoded_fig(mpl_fig=fig)
101117
# create the img string
102118
self.fig_html = f"<img src=data:image/png;base64,{encoded} alt={self.fig_title} width={self.fig_width}>"
103-
elif isinstance(fig, plot_common_access_table.DarshanReportTable):
119+
elif isinstance(fig, DarshanReportTable):
104120
# retrieve html table from `DarshanReportTable`
105121
self.fig_html = fig.html
106122
else:

darshan-util/pydarshan/darshan/experimental/plots/plot_common_access_table.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pandas as pd
44

55
import darshan
6+
from darshan.cli.summary import DarshanReportTable
67

78

89
def remove_nonzero_rows(df: Any) -> Any:
@@ -106,22 +107,6 @@ def get_access_count_df(mod_df: Any, mod: str) -> Any:
106107
return pd.concat(df_list, axis=1)
107108

108109

109-
class DarshanReportTable:
110-
"""
111-
Stores table figures in dataframe and html formats.
112-
113-
Parameters
114-
----------
115-
df: a ``pd.DataFrame``.
116-
117-
kwargs: keyword arguments passed to ``pd.DataFrame.to_html()``.
118-
119-
"""
120-
def __init__(self, df: Any, **kwargs):
121-
self.df = df
122-
self.html = self.df.to_html(**kwargs)
123-
124-
125110
def plot_common_access_table(report: darshan.DarshanReport, mod: str, n_rows: int = 4) -> DarshanReportTable:
126111
"""
127112
Creates a table containing the most

0 commit comments

Comments
 (0)