Skip to content

Commit 432d4d5

Browse files
author
miranov25
committed
Phase 2: Complete output standardization
- Added suffix to diagnostic columns - Fixed 4 tests for new column names - 40 tests passing - Merge compatibility achieved
1 parent e104123 commit 432d4d5

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

UTILS/dfextensions/groupby_regression/groupby_regression_optimized.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def _make_nan_result_row(
8383

8484
# Add diagnostics (if dict provided)
8585
if diag_dict:
86-
row[f"{diag_prefix}n_total"] = diag_dict.get('n_total', 0)
87-
row[f"{diag_prefix}n_valid"] = diag_dict.get('n_valid', 0)
88-
row[f"{diag_prefix}n_filtered"] = diag_dict.get('n_filtered', 0)
89-
row[f"{diag_prefix}cond_xtx"] = diag_dict.get('cond_xtx', np.inf)
90-
row[f"{diag_prefix}status"] = diag_dict.get('status', 'UNKNOWN')
86+
row[f"{diag_prefix}n_total{suffix}"] = diag_dict.get('n_total', 0)
87+
row[f"{diag_prefix}n_valid{suffix}"] = diag_dict.get('n_valid', 0)
88+
row[f"{diag_prefix}n_filtered{suffix}"] = diag_dict.get('n_filtered', 0)
89+
row[f"{diag_prefix}cond_xtx{suffix}"] = diag_dict.get('cond_xtx', np.inf)
90+
row[f"{diag_prefix}status{suffix}"] = diag_dict.get('status', 'UNKNOWN')
9191

9292
return row
9393

@@ -975,12 +975,12 @@ def make_parallel_fit_v3(
975975

976976
# Add diagnostics (if enabled)
977977
if diag:
978-
row[f"{diag_prefix}n_total"] = n_total
979-
row[f"{diag_prefix}n_valid"] = n_valid
980-
row[f"{diag_prefix}n_filtered"] = n_filtered
981-
row[f"{diag_prefix}cond_xtx"] = cond
982-
row[f"{diag_prefix}status"] = status
983-
row[f"{diag_prefix}time_ms"] = (t1 - t0) * 1000
978+
row[f"{diag_prefix}n_total{suffix}"] = n_total
979+
row[f"{diag_prefix}n_valid{suffix}"] = n_valid
980+
row[f"{diag_prefix}n_filtered{suffix}"] = n_filtered
981+
row[f"{diag_prefix}cond_xtx{suffix}"] = cond
982+
row[f"{diag_prefix}status{suffix}"] = status
983+
row[f"{diag_prefix}time_ms{suffix}"] = (t1 - t0) * 1000
984984

985985
res_rows.append(row)
986986

@@ -993,7 +993,7 @@ def make_parallel_fit_v3(
993993
# Add wall time diagnostic
994994
if diag:
995995
t_end = time.perf_counter()
996-
dfGB[f"{diag_prefix}wall_ms"] = (t_end - t_start) * 1000
996+
dfGB[f"{diag_prefix}wall_ms{suffix}"] = (t_end - t_start) * 1000
997997

998998
# ========================================================================
999999
# 5. HANDLE PREDICTIONS (IF REQUESTED)
@@ -1357,11 +1357,11 @@ def make_parallel_fit_v4(
13571357
out_dict[f"{tname}_mad{suffix}"] = mad_arr[:, t_idx]
13581358
# Diagnostics (if enabled)
13591359
if diag:
1360-
out_dict[f"{diag_prefix}n_total"] = n_total_arr
1361-
out_dict[f"{diag_prefix}n_valid"] = n_valid_arr
1362-
out_dict[f"{diag_prefix}n_filtered"] = n_filtered_arr
1363-
out_dict[f"{diag_prefix}cond_xtx"] = cond_arr
1364-
out_dict[f"{diag_prefix}status"] = status_arr
1360+
out_dict[f"{diag_prefix}n_total{suffix}"] = n_total_arr
1361+
out_dict[f"{diag_prefix}n_valid{suffix}"] = n_valid_arr
1362+
out_dict[f"{diag_prefix}n_filtered{suffix}"] = n_filtered_arr
1363+
out_dict[f"{diag_prefix}cond_xtx{suffix}"] = cond_arr
1364+
out_dict[f"{diag_prefix}status{suffix}"] = status_arr
13651365

13661366

13671367

UTILS/dfextensions/groupby_regression/tests/test_groupby_regression_optimized.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,14 +1597,14 @@ def test_v3_inf_nan_filtering():
15971597
)
15981598

15991599
# Check diagnostics
1600-
assert 'diag_n_total' in dfGB.columns
1601-
assert 'diag_n_filtered' in dfGB.columns
1600+
assert 'diag_n_total_test' in dfGB.columns
1601+
assert 'diag_n_filtered_test' in dfGB.columns
16021602

16031603
# Each group should have filtered 1 row
1604-
assert all(dfGB['diag_n_filtered'] == 1)
1604+
assert all(dfGB['diag_n_filtered_test'] == 1)
16051605

16061606
# All should have status OK (enough data remains)
1607-
assert all(dfGB['diag_status'] == 'OK')
1607+
assert all(dfGB['diag_status_test'] == 'OK')
16081608

16091609
print("✅ test_v3_inf_nan_filtering passed")
16101610

@@ -1820,12 +1820,12 @@ def test_v3_singular_matrix_handling():
18201820
)
18211821

18221822
# Check status indicates problem
1823-
status = dfGB['diag_status'].values[0]
1823+
status = dfGB['diag_status_test'].values[0]
18241824
assert status in ['ILL_CONDITIONED_RIDGED', 'SINGULAR_MATRIX'], \
18251825
f"Expected ill-conditioned status, got {status}"
18261826

18271827
# Check condition number is very high
1828-
cond = dfGB['diag_cond_xtx'].values[0]
1828+
cond = dfGB['diag_cond_xtx_test'].values[0]
18291829
assert cond > 1e10, f"Expected high condition number, got {cond}"
18301830

18311831
# Check function didn't crash (values are finite or NaN)
@@ -2008,14 +2008,14 @@ def test_v4_inf_nan_filtering():
20082008
)
20092009

20102010
# Check diagnostics exist
2011-
assert 'diag_n_total' in dfGB.columns
2012-
assert 'diag_n_filtered' in dfGB.columns
2011+
assert 'diag_n_total_test' in dfGB.columns
2012+
assert 'diag_n_filtered_test' in dfGB.columns
20132013

20142014
# Each group should have filtered 1 row
2015-
assert all(dfGB['diag_n_filtered'] == 1)
2015+
assert all(dfGB['diag_n_filtered_test'] == 1)
20162016

20172017
# All should have status OK (enough data remains)
2018-
assert all(dfGB['diag_status'] == 'OK')
2018+
assert all(dfGB['diag_status_test'] == 'OK')
20192019

20202020
print("✅ test_v4_inf_nan_filtering passed")
20212021

@@ -2232,12 +2232,12 @@ def test_v4_singular_matrix_handling():
22322232
)
22332233

22342234
# Check status indicates problem
2235-
status = dfGB['diag_status'].values[0]
2235+
status = dfGB['diag_status_test'].values[0]
22362236
assert status in ['ILL_CONDITIONED_RIDGED', 'SINGULAR_MATRIX'], \
22372237
f"V4: Expected ill-conditioned status, got {status}"
22382238

22392239
# Check condition number is very high
2240-
cond = dfGB['diag_cond_xtx'].values[0]
2240+
cond = dfGB['diag_cond_xtx_test'].values[0]
22412241
assert cond > 1e10, f"V4: Expected high condition number, got {cond}"
22422242

22432243
# Check function didn't crash (values are finite or NaN)

0 commit comments

Comments
 (0)