Skip to content

Commit a71c8d3

Browse files
committed
improves side by side
1 parent c1cf73c commit a71c8d3

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

_unittests/ut_helpers/test_log_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def test_cube_sbs_no_time(self):
514514
cube = CubeLogs(
515515
df, keys=["^m_*", "exporter", "opt"], values=["time_p", "perf"], time="date"
516516
).load()
517-
sbs, sbs_agg = cube.sbs(
517+
sbs, sbs_agg, _ = cube.sbs(
518518
dict(CFA=dict(exporter="E1", opt="O"), CFB=dict(exporter="E2", opt="O"))
519519
)
520520
self.assertEqual(sbs.shape, (4, 9))
@@ -604,7 +604,7 @@ def test_cube_sbs_with_time(self):
604604
cube = CubeLogs(
605605
df, keys=["^m_*", "exporter", "opt"], values=["time_p", "perf"], time="date"
606606
).load()
607-
sbs, sbs_agg = cube.sbs(
607+
sbs, sbs_agg, _ = cube.sbs(
608608
dict(CFA=dict(exporter="E1", opt="O"), CFB=dict(exporter="E2", opt="O"))
609609
)
610610
self.assertEqual(sbs.shape, (8, 9))

onnx_diagnostic/helpers/log_helper.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def to_excel(
12101210
for k, v in sbs.items():
12111211
print(f"[CubeLogs.to_excel] sbs {k}: {v}")
12121212
name = "∧".join(sbs)
1213-
sbs_raw, sbs_agg = self.sbs(sbs)
1213+
sbs_raw, sbs_agg, sbs_col = self.sbs(sbs)
12141214
if verbose:
12151215
print(f"[CubeLogs.to_excel] add sheet {name!r} with shape {sbs_raw.shape}")
12161216
print(
@@ -1234,6 +1234,14 @@ def to_excel(
12341234
sbs_agg.index.nlevels,
12351235
),
12361236
)
1237+
sbs_col.to_excel(
1238+
writer,
1239+
sheet_name=f"{name}-COL",
1240+
freeze_panes=(
1241+
sbs_col.columns.nlevels + 1,
1242+
sbs_col.index.nlevels,
1243+
),
1244+
)
12371245

12381246
if plots:
12391247
from openpyxl.drawing.image import Image
@@ -1314,7 +1322,7 @@ def cube_time(self, fill_other_dates: bool = False, threshold: float = 1.2) -> "
13141322

13151323
def sbs(
13161324
self, configs: Dict[str, Dict[str, Any]], column_name: str = "CONF"
1317-
) -> Tuple[pandas.DataFrame, pandas.DataFrame]:
1325+
) -> Tuple[pandas.DataFrame, pandas.DataFrame, pandas.DataFrame]:
13181326
"""
13191327
Creates a side-by-side for two configurations.
13201328
Every configuration a dictionary column:value which filters in
@@ -1325,7 +1333,7 @@ def sbs(
13251333
:param configs: example
13261334
``dict(CFA=dict(exporter="E1", opt="O"), CFB=dict(exporter="E2", opt="O"))``
13271335
:param column_name: column to add with the name of the configuration
1328-
:return: data and aggregated date
1336+
:return: data, aggregated date, data with a row per model
13291337
"""
13301338
assert (
13311339
len(configs) >= 2
@@ -1433,6 +1441,8 @@ def _mkc(m, s):
14331441
_mkc(m, f"{n1}<{n2}"): (si < sj).astype(int),
14341442
_mkc(m, f"{n1}=={n2}"): (si == sj).astype(int),
14351443
_mkc(m, f"{n1}>{n2}"): (si > sj).astype(int),
1444+
_mkc(m, f"{n1}*({n1}{n2})"): si * (~sinan & ~sjnan).astype(float),
1445+
_mkc(m, f"{n2}*({n1}{n2})"): sj * (~sinan & ~sjnan).astype(float),
14361446
}
14371447
)
14381448
nas.columns.names = view_res.columns.names
@@ -1452,7 +1462,7 @@ def _mkc(m, s):
14521462
}
14531463
flat = view_res.groupby(self.time).agg(aggs)
14541464
flat = flat.stack("METRICS", future_stack=True)
1455-
return res, flat
1465+
return res, flat, view_res.T.sort_index().T
14561466

14571467

14581468
class CubeLogsPerformance(CubeLogs):

0 commit comments

Comments
 (0)