intword: values between 10^36 and a googol format as huge decillion counts, and rounding to the next unit does not carry
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 52/100
Direção de pesquisa
Comece pelas alterações em number.py referenciadas no relatório e reproduza os exemplos de limite com Python 3.11. Confirme com os maintainers se a lacuna deve usar str(value) como fallback ou prosseguir no limite de googol e, em seguida, adicione testes de regressão para o comportamento selecionado. Considera-se concluído quando valores próximos de 10^100 não produzirem mais contagens enormes de decillion e o arredondamento seguir a regra acordada.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
What happened
intword handles values up to 1000 decillion (10^36) and exactly a googol
(10^100) well, but everything in between formats as an enormous decillion
count:
>>> import humanize
>>> humanize.intword(10**100)
'1.0 googol'
>>> humanize.intword(10**100 - 10**93)
'9999999000000000610151082626636586748864734715312950532670947852288.0 decillion'
>>> humanize.intword(10**50)
'100000000000000000.0 decillion'
A 67 digit unit count defeats the purpose of a human readable number, and
a value just below a googol that rounds up to it never carries to
"1.0 googol".
Verified on humanize 4.16.0 (published wheel) and on current main
(c3a124c), Python 3.11.
Why this looks like a bug rather than a choice
This is the same class of boundary behavior that #328 recently fixed for
metric() (carry to the next SI prefix when rounding reaches 1000). The
powers list jumps from decillion (10^33) to googol (10^100), and the
selection loop picks decillion for anything under a googol, no matter how
large the resulting count is. Values above the largest power already fall
back to str(value), which suggests the intended behavior for
"no reasonable unit" is the plain number, not a unit with a 67 digit
multiplier.
Expected
One of the following, whichever matches the project's intent:
- Values whose formatted count reaches 1000 of a unit with no adjacent
next power fall back tostr(value)(consistent with the existing
above-maximum behavior), and values that round up to exactly the next
power carry to it ("1.0 googol"), consistent with #328's carry rule. - Or simply fall back to
str(value)for the whole gap between 10^36
and 10^100.
I am happy to open a PR with regression tests for the boundary cases once
maintainers confirm which behavior is intended.
How this was found
An automated review gate proposed edge case tests for the recent number.py
changes (the #328 carry fix among them) and executed them against the
code; the "carry just below the next unit" test failed with the output
above. The failing test and its observed output are reproducible by hand
as shown.
- Linguagem predominante
- Python
- Estrelas
- 760
- Forks
- 166
- Merge médio
- 4d 19h
- PRs com merge (30d)
- 6
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-humanize/humanize
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
python-humanize/humanize#423 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
python-humanize/humanize#379 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
python-humanize/humanize#366 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
python-humanize/humanize#419 ·
Mantenedores costumam responder em até 2 dias
-
Percentages and ratiosAberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 48/100
python-humanize/humanize#277 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
Todas as issues de python-humanize/humanize
Issues semelhantes
-
tool-calling
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
vllm-project/vllm#59838 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
raullenchai/Rapid-MLX#4042 ·
Mantenedores costumam responder em até 1 dia
-
documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
transitmatters/mbta-slow-zone-bot#70 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
litestar-org/advanced-alchemy#811 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia