Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

_map_title crashes for orthographic maps with UnboundLocalError: xpt

未关闭
#122 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python

调研方向

首先定位 _map_title,并使用所述的默认设置重现带有非空标题的最小 ortho 等值线图。跟踪 xpt 和 ypt 在每个投影中的赋值方式,然后验证正交投影图能够带标题进行渲染,且不会产生 UnboundLocalError。

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

描述

bug

This actually occurs for other plot types as well.

Version: cfplot 3.4.0; python 3.12

Observed behavior:

  • Orthographic contour plot crashes when cf-plot tries to render the map title
  • If the title is removed, the plot renders successfully

Expected behavior:

  • Orthographic contour plots should render with a title
  • At minimum, _map_title should not crash if a projection-specific title anchor has not been computed

Minimal failing scenario:

  • Projection: ortho
  • Default GUI-style settings:
    • [lat_0 = 0.0]
    • [lon_0 = 0.0
    • Render a contour plot with a non-empty title

Probable root cause:
_map_title() appears to compute xpt, ypt only for some projections, then unconditionally uses them in the non-dims branch.

From the installed 3.4.0 source, the title-anchor coordinates are assigned for cases such as:

  • npstere
  • spstere
  • lcc

but later the code does:

else:
    halign = "center"
    plotvars.mymap.text(
        xpt,
        ypt,
        title,
        ...
    )

For ortho, xpt/ypt do not appear to be initialized before this branch is reached.

主要语言
Python
星标
21
派生
11
平均合并
7 小时 11 分钟
30 天内合并 PR
1

环境准备

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

从这里开始

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

NCAS-CMS/cf-plot 的其他 Issue

查看 NCAS-CMS/cf-plot 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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