`sympify_petab` returns `Integer` for Python/numpy integers, but `Float` for numeric strings
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 50/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 18
- Fork
- 9
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PEtab-dev/libpetab-python
-
`petab_files_1to2` keeps a stale model file when converting into a non-empty output directoryĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
PEtab-dev/libpetab-python#566 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PEtab-dev/libpetab-python#549 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
PEtab-dev/libpetab-python#525 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
PEtab-dev/libpetab-python#565 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
PEtab-dev/libpetab-python#555 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PEtab-dev/libpetab-python
Issue tương tự
-
bug P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Toloka/tolokaforge#1947 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SageMaker provider: streaming fails with NoStreamDataError on DJL Serving (LMI) endpointsCó thể đã có người làm @balajiaru đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
UKGovernmentBEIS/inspect_ai#6127 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
pydot/pydot#601 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
letsencrypt/cp-cps#361 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100