`sympify_petab` returns `Integer` for Python/numpy integers, but `Float` for numeric strings
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 50/100
Direção de pesquisa
Start with sympify_petab in the petab.v1.math module and its docstring, which already says integers become floats. Reproduce the four calls in the issue to see the current Integer/Float split. Deciding whether to convert Python and numpy integers to sp.Float is a maintainer call, since existing callers would see a different return type. Done means the agreed behaviour is implemented and the v2 round-trip comparison holds.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
sympify_petab converts numeric strings to sp.Float, but Python and numpy integers to sp.Integer:
import numpy as np
from petab.v1.math import sympify_petab
sympify_petab("2") # Float: 2.00000000000000
sympify_petab(2.0) # Float: 2.00000000000000
sympify_petab(2) # Integer: 2
sympify_petab(np.int64(2)) # Integer: 2
Since sympy 1.13, sp.Integer(2) != sp.Float(2), so the type matters for comparisons. And integer arithmetic stays exact: sympify_petab(1) / sympify_petab(3) gives 1/3, while sympify_petab("1") / sympify_petab("3") gives 0.333333333333333.
In petab.v2, which parses all math fields with sympify_petab, this has the following effects:
- For the same file content, the type depends on pandas' dtype inference for the whole column. A
targetValueof2is parsed asIntegerif all target values in the condition table are integers, and asFloatif any other row contains a non-integer or an expression. - Objects created from Python integers, e.g.
Change(target_id="k1", target_value=2), do not compare equal to the same objects after writing and reading them back, because the value is written as2.0and read back asFloat.
PEtab numbers are floating point (the sympify_petab docstring also says "integer values are converted to floats", which currently only holds for strings). Converting integers to sp.Float in sympify_petab would make this consistent. However, this would change the return value for existing callers that pass Python integers.
🤖 Drafted with AI assistance.
- Linguagem predominante
- Python
- Estrelas
- 18
- Forks
- 9
- Merge médio
- 1d 21h
- PRs com merge (30d)
- 25
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem 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 PEtab-dev/libpetab-python
-
`petab1to2`: random column name for pre-existing `experimentId` columnTalvez já em andamento @dweindl assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
PEtab-dev/libpetab-python#568 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
`petab_files_1to2` keeps a stale model file when converting into a non-empty output directoryAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
PEtab-dev/libpetab-python#566 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
PEtab-dev/libpetab-python#549 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
PEtab-dev/libpetab-python#525 ·
Mantenedores costumam responder em até 1 dia
-
`petablint` fails for PEtab v2 problems with only warningsTalvez já em andamento @dweindl assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
PEtab-dev/libpetab-python#567 · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de PEtab-dev/libpetab-python
Issues semelhantes
-
link-rot
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 67/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
developmentseed/titiler-cmr#265 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Insecure Brotli version <1.2.1Talvez já em andamento @jamescw19 assumiu hoje. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
stac-utils/stac-fastapi-pgstac#438 · 1 reação ·
-
bug triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia