naturalsize() truncates non-integer byte counts below the base ("1 Bytes")
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #507 来自 @ekanshul —— 已关闭,未合并
评估
调研方向
从 naturalsize() 的实现及其测试入手;issue 指出 int() 转换和单数检查是相关行为。比较大于基数和小于基数的值所经过的格式化路径,然后为分数形式的字节数添加测试,包括 gnu=True。完成标准是:分数形式的输入保留其小数部分,而整数输入保持当前输出。
由索引模型根据 Issue 内容生成。
描述
On current main:
>>> import humanize
>>> humanize.naturalsize(1.5)
'1 Bytes'
>>> humanize.naturalsize(1.9)
'1 Bytes'
>>> humanize.naturalsize(1500)
'1.5 kB'
From 1 kB upwards the fraction is kept using format, but below the base the value is truncated with int(). The singular check also compares the untruncated value with 1, so 1.5 is shown as "1 Bytes".
In #239 you mentioned that "1.1 Bytes" would be better than "1 Bytes" for non-integer input, and that tests for non-integer input were missing.
Proposal:
- Format non-integer values below the base with
format, like larger units (e.g. "1.5 Bytes", and "1.5B" withgnu=True). - Keep integer input unchanged ("300 Bytes", "1 Byte").
- Add tests for non-integer input.
Would you be happy with this? If so, we'd like to send a PR.
- 主要语言
- Python
- 星标
- 768
- 派生
- 243
- 平均合并
- 4 天 12 小时
- 30 天内合并 PR
- 19
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-humanize/humanize 的其他 Issue
-
intcomma returns exponential notation for large floats可能已有人在做 @Omarinho12345 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
python-humanize/humanize#521 ·
维护者通常 1 天内回复
-
intcomma returns scientific notation for large floats可能已有人在做 @TheNetherWatcher 于 47 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 74/100
python-humanize/humanize#431 ·
维护者通常 1 天内回复
-
metric() adds a digit when a value rounds into quetta可能已有人在做 @SashaMIT 于 49 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
python-humanize/humanize#423 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 25/100
python-humanize/humanize#512 · 1 条评论 ·
维护者通常 1 天内回复
-
naturalsize() ignores the locale decimal separator可能已有人在做 @ekanshul 于 29 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
python-humanize/humanize#460 ·
维护者通常 1 天内回复
查看 python-humanize/humanize 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 77/100
mozilla-ai/cq#601 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
LUCJ pass manager raises NoEdgeBetweenNodes when an edge is bad for two two-qubit gates可能已有人在做 @hat-im 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
opensubtitlescom: provider rejects pt-PT even though its own converter maps it可能已有人在做 @paulo-0308 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
Diaoul/subliminal#1405 ·
-
难度 2/5 1-3 小时 新手友好度 78/100