plot/plotter: NewHist(binPoints) panic when a small negative number is used
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- go
研究方向
從 plotter.NewHist 和 binPoints 函式開始,著重檢查第 213 行附近的條件,以及報告中包含一個小負值的最小範例。在報告所使用的 Go 和 Gonum/plot 版本下執行該範例,接著確認相同的輸入會回傳 bins 而不會引發 panic,且此行為已由回歸測試涵蓋。
由索引模型根據 Issue 內容生成。
描述
What are you trying to do?
I am trying to analyze the distribution of a series of numbers by plotter.NewHist
What did you do?
Here is a minimal example of the code I used:
func TestA(t *testing.T) {
data := []float64{203.4, -9.223372036854776e+17, 220.4}
_, err := plotter.NewHist(plotter.Values(data), 10)
if err != nil {
fmt.Println(err)
}
}
What did you expect to happen?
some bin are returned and there is no error or panic
What actually happened?
funcion binPoints panics with following message
panic: 203.4, xmin=-9.223372036854776e+17, xmax=220.4, w=9.223372036854779e+16, bin=10, n=10
What version of Go and Gonum/plot are you using?
Go 1.23
gonum.org/v1/plot v0.15.0
Also reproduced in
Go 1.20
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b
Annotation
When debugging, I find the bin is set to 10 wrongly. I doubt it is the computing accuracy problem for float64. Maybe if x == xmax (line 213) should be changed to if bin >=n?
- 主要語言
- Go
- 星號
- 3k
- 分支
- 202
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
gonum/plot 的其他 Issue
-
難度 3/5 1-2 天 新手友好度 35/100
-
難度 2/5 1-3 小時 新手友好度 52/100
-
難度 5/5 一週以上 新手友好度 32/100
-
難度 3/5 1-2 天 新手友好度 35/100
-
難度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
Gaurav-Gosain/tuios#1316 ·
維護者通常 1 天內回覆
-
area:auth documentation priority:low
難度 1/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
Mend: dependency security vulnerability
難度 2/5 1-3 小時 新手友好度 65/100
kube-tarian/sigrun#203 ·
-
難度 2/5 1-3 小時 新手友好度 72/100
kubernetes-csi/csi-driver-iscsi#485 ·
維護者通常 1 天內回覆
-
good first issue
難度 2/5 1-3 小時 新手友好度 72/100
eugenioenko/ttt#1276 ·
維護者通常 1 天內回覆