Skip to content

Add plot transform and deprecated wrappers#1589

Merged
SAKURA-CAT merged 2 commits intomainfrom
chore/some-misc
Apr 30, 2026
Merged

Add plot transform and deprecated wrappers#1589
SAKURA-CAT merged 2 commits intomainfrom
chore/some-misc

Conversation

@SAKURA-CAT
Copy link
Copy Markdown
Member

变更内容

  • 新增 swanlab.plot 模块,作为自定义图表的占位入口,目前从 echarts 组件中导出 confusion_matrixroc_curvepr_curve
  • swanlab.roc_curve()swanlab.pr_curve()swanlab.confusion_matrix() 添加 @deprecated 装饰器和弃用警告,引导用户使用 swanlab.echarts.* 替代
  • 更新 __init__.pyi 类型存根,添加 plot 导出
  • 调整 __all__ 导出顺序,将 echartsplot 归类到数据模块组

变更文件

  • swanlab/__init__.py — 添加 plot 导入、deprecated 包装函数
  • swanlab/__init__.pyi — 添加 plot 类型导出
  • swanlab/sdk/__init__.py — 添加 plot 导入,调整导出顺序
  • swanlab/sdk/internal/run/transforms/plot/__init__.py — 新增 plot 模块

Introduce a new swanlab.sdk.internal.run.transforms.plot module that re-exports echarts.metrics (confusion_matrix, roc_curve, pr_curve) as a placeholder plotting API. Expose the new plot symbol in swanlab.sdk and the top-level package (including typing stubs). Add top-level deprecated helper functions (roc_curve, pr_curve, confusion_matrix) that warn and forward calls to swanlab.echarts.* to preserve backwards compatibility. Also import typing_extensions.deprecated and warnings to support the deprecation wrappers.
@SAKURA-CAT SAKURA-CAT self-assigned this Apr 30, 2026
@SAKURA-CAT SAKURA-CAT added 📈 chart SwanLab chart 💪 enhancement New feature or request labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new plot module and deprecates the top-level roc_curve, pr_curve, and confusion_matrix functions, redirecting them to the echarts module with appropriate deprecation warnings. The feedback suggests adding stacklevel=2 to the warnings.warn calls to ensure the warning points to the user's code rather than the internal wrapper. Additionally, it is recommended to update the type stub file (__init__.pyi) to include these deprecated functions to maintain consistency and provide better IDE support.

Comment thread swanlab/__init__.py
Comment thread swanlab/__init__.pyi
@SAKURA-CAT SAKURA-CAT merged commit de94825 into main Apr 30, 2026
18 checks passed
@SAKURA-CAT SAKURA-CAT deleted the chore/some-misc branch April 30, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📈 chart SwanLab chart 💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant