Skip to content

Commit 61b02d4

Browse files
author
miranov25
committed
Phase 13.25.DF FIX1: P2-1 capsize introspection + P2-2 yerr assertion
Tests only — no production code change. P2-1 (Claude49+Claude48 convergent): AD-53 capsize independence test now introspects actual rendered capsize values via ec[0][1][0].get_markersize()/2.0 and asserts 5.0 for SEM mode, 7.0 for quantile mode. Previously only checked container presence. P2-2 (Claude48): test_error_bars_yerr_is_asymmetric now verifies cap lines present + quantile stats in dict. Test results: 577 passed, 0 failed (unchanged)
1 parent 06f84ff commit 61b02d4

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

UTILS/dfextensions/dfdraw/tests/test_quantiles_profile.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,14 @@ class TestQuantileErrorBarsRendering:
196196
"""T-1: Real assertions on ErrorbarContainer, yerr, capsize."""
197197

198198
def test_error_bars_yerr_is_asymmetric(self,df_gaussian):
199-
_,ax,_=DFDraw(df_gaussian).profile("y:x",bins=20,quantiles=[.16,.84])
199+
"""R3: ErrorbarContainer with asymmetric quantile error bars."""
200+
_,ax,s=DFDraw(df_gaussian).profile("y:x",bins=20,quantiles=[.16,.84])
200201
ec=[c for c in ax.containers if isinstance(c,ErrorbarContainer)]
201-
assert len(ec)>=1,f"Expected ErrorbarContainer, got {ax.containers}"; plt.close('all')
202+
assert len(ec)>=1,f"Expected ErrorbarContainer, got {ax.containers}"
203+
# Verify error bars rendered (cap lines present) and quantile stats in dict
204+
assert len(ec[0][1])>0,"Cap lines must be present"
205+
assert 'q_lower_per_bin' in s and 'q_upper_per_bin' in s
206+
plt.close('all')
202207

203208
def test_error_bars_q_lower_below_mean(self,df_gaussian):
204209
_,_,s=DFDraw(df_gaussian).profile("y:x",bins=20,quantiles=[.16,.84])
@@ -233,16 +238,27 @@ def test_error_bars_capsize_from_style(self,df_gaussian):
233238
set_style(None)
234239

235240
def test_quantile_capsize_independent_of_profile_capsize(self,df_gaussian):
236-
"""AD-53 lock: independence verified by rendering with DIFFERENT capsize values."""
241+
"""AD-53 lock: rendered cap sizes must match each key independently.
242+
P2-1 from Claude49+Claude48 convergent: introspect actual capsize values."""
237243
set_style(None); set_style({"profile.capsize":5,"quantile.error_bars.capsize":7.0})
238244
d=DFDraw(df_gaussian)
239245
_,ax1,_=d.profile("y:x",bins=20) # uses profile.capsize=5
240246
ec1=[c for c in ax1.containers if isinstance(c,ErrorbarContainer)]
241247
assert len(ec1)>=1,"Non-quantile ErrorbarContainer missing"
248+
# matplotlib stores capsize as markersize/2 on cap lines
249+
caps1=ec1[0][1] # cap lines tuple
250+
if caps1:
251+
sem_capsize=caps1[0].get_markersize()/2.0
252+
assert sem_capsize==pytest.approx(5.0,abs=0.5), \
253+
f"profile.capsize=5 should propagate to SEM mode, got {sem_capsize}"
242254
_,ax2,_=d.profile("y:x",bins=20,quantiles=[.16,.84]) # uses quantile.error_bars.capsize=7
243255
ec2=[c for c in ax2.containers if isinstance(c,ErrorbarContainer)]
244256
assert len(ec2)>=1,"Quantile ErrorbarContainer missing"
245-
# Both render with their respective style keys — independence proven
257+
caps2=ec2[0][1]
258+
if caps2:
259+
q_capsize=caps2[0].get_markersize()/2.0
260+
assert q_capsize==pytest.approx(7.0,abs=0.5), \
261+
f"quantile.error_bars.capsize=7 should propagate to quantile mode, got {q_capsize}"
246262
plt.close('all'); set_style(None)
247263

248264
# ── Class 5: Band rendering (8 invariance) — T-2 FIXED: unconditional ──

0 commit comments

Comments
 (0)