Skip to content

Commit

Permalink
datalist mean 自動跳過非數字元素
Browse files Browse the repository at this point in the history
  • Loading branch information
TimLai666 committed Sep 14, 2024
1 parent a9be767 commit f992dab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion datalist.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ func (dl *DataList) Mean() float64 {
sum += val
count++
} else {
LogWarning("DataList.Mean(): Element %v cannot be converted to float64, skipping.", val)
LogWarning("DataList.Mean(): Element %v is not a numeric type, skipping.", v)
// 跳过无法转换的元素
continue
}
Expand Down
2 changes: 1 addition & 1 deletion insyra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestMin(t *testing.T) {

// 測試 Mean 函數
func TestMean(t *testing.T) {
dl := NewDataList(1, 2, 3, 4)
dl := NewDataList(1, 2, 3, int(4), "5")
mean := dl.Mean()

if !float64Equal(mean, 2.5) {
Expand Down

0 comments on commit f992dab

Please sign in to comment.