Skip to content

fix: smooth contour spacing reported success when aborted mid-iteration - #419

Merged
paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:fix/smooth-contour-quantiles
Nov 19, 2026
Merged

paulmueller merged 1 commit into
DC-analysis:mainfrom
paulmueller-agent:fix/smooth-contour-quantiles

Conversation

@paulmueller-agent

Copy link
Copy Markdown
Contributor

Two issues in dclab.kde.smooth_contour.find_smooth_contour_spacing:

  1. Nested quantiles: get_contour_lines was called with quantiles=[[np.max(quantiles)]]. This worked by chance: np.nanpercentile returned a (1, 1) array, iterating over the normalized levels yielded a 1-element array per quantile, and find_contours_level accepted that. The contours were identical to the flat version, but the levels were nested ([[1.42]] instead of [1.42]). Now a flat list is passed. The results are unchanged (all pinned values in test_kde_smooth_contour.py still pass).

  2. Abort during iteration: when abort_event was set while iterating over the datasets, the inner loop was left with break, which skipped the for ... else block. With no (or only some) contours checked, max_dphi stayed small, so the function returned success=True with reason "target opening angle reached". The abort event is now checked after the loop over the datasets (reason "abort event", success=False). I replaced the for ... else construct with explicit checks.

New test test_find_smooth_contour_abort_during_iteration (fails without the fix).

🤖 Generated with Claude Code

- pass a flat list of quantiles to `get_contour_lines` (the nested
  list only worked by chance, the contour levels were nested as well)
- check the abort event after iterating over the datasets

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulmueller-agent
paulmueller-agent force-pushed the fix/smooth-contour-quantiles branch from a3f39c2 to 9d17956 Compare November 19, 2026 09:12
@paulmueller
paulmueller merged commit a427522 into DC-analysis:main Nov 19, 2026
4 checks passed
@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.00%. Comparing base (575cdc6) to head (9d17956).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #419   +/-   ##
=======================================
  Coverage   93.00%   93.00%           
=======================================
  Files         124      124           
  Lines        9725     9727    +2     
=======================================
+ Hits         9045     9047    +2     
  Misses        680      680           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants