`logy=True` raises for a constant curve with `unit=None`

未关闭 适合新手
#627 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从 core/limits.py 中的 fix_empty_range 开始,将对数分支与已经处理 unit=None 的线性分支进行比较。使用提供的常数曲线示例复现问题,并检查单点情况下的 logx=True。当这两种情况都能在不出现 UnitError 的情况下绘图,且现有的无量纲单位行为仍然正常时,任务即完成。

由索引模型根据 Issue 内容生成。

描述

import plopp as pp, scipp as sc

da = sc.DataArray(sc.array(dims=['x'], values=[2.0, 2.0, 2.0], unit=None),
                  coords={'x': sc.arange('x', 3.0, unit=None)})
pp.plot(da, logy=True)
# UnitError: Cannot divide with operand of unit 'None'.

In core/limits.py, fix_empty_range, the log branch divides by
sc.scalar(10.0, unit=""). The linear branch handles unit=None already.
The same happens with logx=True for a single point. It works with
unit='dimensionless'.

Suggestion: sc.scalar(lower.value / 10.0, unit=unit) (and the same for
the upper limit), as the linear branch does.

Reproduced on plopp 26.11.0, scipp 26.9.0, matplotlib 3.11.2.

主要语言
Python
星标
12
派生
7
平均合并
16 小时 5 分钟
30 天内合并 PR
6

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

scipp/plopp 的其他 Issue

查看 scipp/plopp 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。