Skip to content

fix: resolve visualization helper regressions#19

Merged
stefan-jansen merged 1 commit into
mainfrom
fix/viz-helper-regressions
May 15, 2026
Merged

fix: resolve visualization helper regressions#19
stefan-jansen merged 1 commit into
mainfrom
fix/viz-helper-regressions

Conversation

@stefan-jansen

Copy link
Copy Markdown
Contributor

Summary

  • fix plot_rolling_sharpe so externally supplied rolling results drive the rendered window set
  • keep rolling Sharpe reference labels readable on narrow layouts and fail loudly on unmatched windows
  • use adaptive cost-waterfall label formatting so small costs no longer round to hBc0 (0.0%)
  • add regression coverage for both visualization helpers
  • bump release to 0.1.0b21

Validation

  • uv run pytest tests/test_visualization/test_portfolio_plots.py -q
  • uv run pytest tests/test_visualization/test_backtest.py -q -k 'cost_waterfall'
  • uv run ruff check src tests
  • uv run ruff format --check src tests
  • uv run ty check
  • uv run --extra docs mkdocs build --strict
  • uv build
  • uv run pytest tests/ -q

Full suite result: 5226 passed, 21 skipped

Copilot AI review requested due to automatic review settings May 15, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes two visualization helper regressions: plot_rolling_sharpe now honors externally supplied rolling result windows and fails loudly when no series match, with reference labels repositioned to fit narrow layouts. plot_cost_waterfall uses adaptive currency/percent formatting so small costs render with appropriate precision. Adds regression tests and bumps version to 0.1.0b21.

Changes:

  • plot_rolling_sharpe: derive windows from rolling_result.sharpe.keys() when not specified; raise ValueError if no series match; move reference annotations to top right with right margin.
  • New _formatting.py helpers (format_currency_adaptive, format_percent_adaptive) used in plot_cost_waterfall.
  • Regression tests + CHANGELOG/version bump.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ml4t/diagnostic/visualization/portfolio/risk_plots.py Fix window selection and annotation positioning for plot_rolling_sharpe.
src/ml4t/diagnostic/visualization/backtest/cost_attribution.py Use adaptive formatters for waterfall labels.
src/ml4t/diagnostic/visualization/backtest/_formatting.py New shared adaptive currency/percent formatters.
tests/test_visualization/test_portfolio_plots.py New regression tests for rolling Sharpe behavior.
tests/test_visualization/test_backtest.py New regression test for small-cost waterfall labels.
src/ml4t/diagnostic/init.py Bump version to 0.1.0b21.
CHANGELOG.md Document fixes under 0.1.0b21.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stefan-jansen stefan-jansen merged commit ef4a9ed into main May 15, 2026
11 checks passed
@stefan-jansen stefan-jansen deleted the fix/viz-helper-regressions branch May 15, 2026 04:46
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