Configurably truncated representation when FieldList is very long
还没有人认领这个 Issue。
评估
调研方向
首先定位 issue 中提到的 FieldList 的 str 和 repr 实现,以及 cf.configuration() 入口点。查看现有的表示测试,然后定义截断阈值和配置行为;完成标准是:较长的 FieldList 表示会被缩略,较短的表示保持不变,并且阈值可以配置。
由索引模型根据 Issue 内容生成。
描述
In str and repr calls on a FieldList, we print a one-line view of all fields present in the list, which is generally useful and sensible, however when the FieldList is suitably long this can seem like far too much information that it becomes spammy and it becomes hard to access previous terminal or interactive Python calls and output. For example, working with WRF data I get >10,000 field representations spat out as a listing.
A nice feature would be to truncate this listing with an ellipsis (or otherwise, but that seems standard and sensible e.g. as used to truncate numpy arrays), when the list is over N items long for some sensible N:
[<CF Field: ncvar%ACGRDFLX(ncdim%Time(1), ncdim%south_north(179), ncdim%west_east(139)) J m-2>,
<CF Field: ncvar%ACGRDFLX(ncdim%Time(1), ncdim%south_north(179), ncdim%west_east(139)) J m-2>,
<CF Field: ncvar%ACGRDFLX(ncdim%Time(1), ncdim%south_north(179), ncdim%west_east(139)) J m-2>,
...
<CF Field: ncvar%ZS(ncdim%Time(1), ncdim%soil_layers_stag(4)) m>,
<CF Field: ncvar%ZS(ncdim%Time(1), ncdim%soil_layers_stag(4)) m>,
<CF Field: ncvar%ZS(ncdim%Time(1), ncdim%soil_layers_stag(4)) m>]
and perhaps to and also add a note of the full length to the start of the reporesentation to indicate how many fields have been subsumed into the ellipsis, e.g. to include a first line to the above such as this, or similar, where N is the length:
CF FieldList (N):
[ ... ]
Configurability
NumPy and others support configurability on the truncation threshold (point at which the representation gets summarised and not shown fully) via methods such as numpy.set_printoptions with a threshold argument, so ideally we can also allow the user to configure this for our FieldList (and maybe otherwise, with other truncation on aspects such as data array views?). I suggest adding another setting under cf.configuration() called print_threshold or similar, taking an integer as per the numpy threshold parameter.
- 主要语言
- Python
- 星标
- 151
- 派生
- 23
- 平均合并
- 3 天 9 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NCAS-CMS/cf-python 的其他 Issue
-
documentation
难度 1/5 1 小时以内 新手友好度 72/100
-
Convert to/from iris cubes可能已有人在做 @davidhassell 于 3 天前认领。 未关闭enhancement
难度 5/5 一周以上 新手友好度 25/100
-
Convert from/to `xarray`可能已有人在做 @davidhassell 于 3 天前认领。 未关闭enhancement xarray
难度 5/5 一周以上 新手友好度 25/100
-
installation
难度 4/5 3-5 天 新手友好度 45/100
-
Attempt at unsupported conservative 3D mesh regridding可能重新可做 @sadielbartholomew 于 74 天前认领,目前没有进行中的 PR。 未关闭bug?
查看 NCAS-CMS/cf-python 的全部 Issue
相似的 Issue
-
eegprep-lean: set channel types from the Zarr group's channel_type可能已有人在做 @claude 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
blacklanternsecurity/bbot#3679 ·
维护者通常 2 天内回复
-
Bot Type: Bug Type: Documentation
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 80/100
speakeasy-api/speakeasy#2159 ·
维护者通常 1 天内回复