.mean() on ArrayView1<u64>: panicked at 'attempt to add with overflow'
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Start by running the provided Rust example and inspect the ndarray implementations of mean() and sum(), since the report identifies their likely interaction. Determine how mean should behave when summing u64 values beyond that type's range, then verify that the reproduction no longer panics and still returns the expected mean.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I wanted to calculate a mean over an ArrayView1<u64> with 1000 values and encounter a panic:
thread 'main' panicked at 'attempt to add with overflow', /rustc/e1884a8e3c3e813aada8254edfa120e85bf5ffca/library/core/src/ops/arith.rs:107:1
Is this intended? Or should the u64 values internally be casted to u128 when calculating the mean?
The following code reproduces the error:
use ndarray::*;
fn main() {
let mut data_vec: Vec<u64> = Vec::new();
for _ in 1..1000 {
data_vec.push(132542363533234561)
}
let data = data_vec.as_slice();
let view: ArrayView1<u64> = ArrayView1::from_shape(data.len(), data).unwrap();
println!("{:?}", view.mean());
}
I think the reason for this error is that mean() uses the public sum() function, which panics if the result does not fit into the element type. However, the mean result should always fit into the element type, so mean() maybe shouldn't use the public sum() function.
- Ngôn ngữ chính
- Rust
- Star
- 4.3k
- Fork
- 391
- 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 rust-ndarray/ndarray
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1612 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1617 · 1 bình luận ·
-
Stack overflow in `triu` Đang mởbug good first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
rust-ndarray/ndarray#1615 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1610 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1609 ·
Tất cả issue của rust-ndarray/ndarray
Issue tương tự
-
risk:low runtime status:in-progress type:test
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
zeroclaw-labs/zeroclaw#11023 ·
-
good first issue refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
EricSpencer00/Resilient#4835 · 1 bình luận ·
-
agent:ready documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
cesarferreira/stax#890 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100