`pretty-format-json` modifies floating point numbers that have too many digits of precision
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reproducing the issue with the pretty-format-json hook and inspect the high-precision-numbers branch and linked diff for its existing test case. Done means the hook preserves the input value 4.4257052820783003 in formatted output without losing decimal digits, with the regression test passing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
pretty-format-json modifies floating point numbers that have too many digits of precision.
Background
I have to work with JSON files that may be generated by non-python programs. These files, for whatever reason, have numbers that have up to 16 digits after the decimal place.
(It's absurd, really. The people taking these measurements are somehow able to measure 0.1μHz on a 10GHz scale?? Yeah, they're saving values like 5.9257052820783001 GHz. Someone needs to teach them about significant figures... but that's beside the point. The point is I have to deal with this data 😒)
Steps to Reproduce
- Create the following json file:
{"foo": 4.4257052820783003} - Run pretty-format-json on it.
Expected Output:
{
"foo": 4.4257052820783003
}
Actual Output:
{
"foo": 4.4257052820783
}
The diff from expected is:
{
- "foo": 4.4257052820783003
+ "foo": 4.4257052820783
}
Version Info
- pre-commit: 2.19.0
- pre-commit-hooks: v4.2.0
- Python: 3.8.8
- OS: Debian 11
Discussion
This might be something that has to be fixed within the python builtin json package. A custom JSON encoder/decoder that wraps things using decimal.Decimal might work too.
I've created a test case for this. See my high-precision-numbers branch or the diff.
I'll see if I have time to actually fix this, but I don't expect to ☹️.
- Ngôn ngữ chính
- Python
- Star
- 6.7k
- Fork
- 800
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
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 pre-commit/pre-commit-hooks
-
Immutable Releases Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
pre-commit/pre-commit-hooks#1218 · 4 bình luận · 2 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
pre-commit/pre-commit-hooks#1020 · 8 bình luận · 1 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
pre-commit/pre-commit-hooks#749 · 1 reaction ·
-
enhancement good-first-issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
pre-commit/pre-commit-hooks#612 · 13 bình luận ·
-
Ban unarmored GPG keys Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
pre-commit/pre-commit-hooks#339 · 18 bình luận · 2 reaction ·
Tất cả issue của pre-commit/pre-commit-hooks
Issue tương tự
-
sponsored
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
opensubtitlescom: moviehash never sent when opensubtitles (.org) is not in the provider list Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Diaoul/subliminal#1382 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
triage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
agentscope-ai/agentscope#2775 ·
-
worker.gpuVendors silently accepts unsupported/misspelled vendor names — no validation guard Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100