diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 15:52:02 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-21 15:52:02 +0200 |
| commit | d25c2cba801cbaa9f9c0d5a92b90f153630ffe24 (patch) | |
| tree | 8fc2672984dde4a621944839b951a478bb87460a /cli | |
| parent | 5b1962f13809f4306b50536a2105252a71b5d74f (diff) | |
Upgrade to Go 1.27 and apply go fix modernization
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/cli.go | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -106,10 +106,7 @@ func runBacktest(db *sql.DB) error { }) w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) fmt.Fprintln(w, "computed\treference\terr %\tride") - limit := 10 - if len(samples) < limit { - limit = len(samples) - } + limit := min(len(samples), 10) for _, s := range samples[:limit] { fmt.Fprintf(w, "%s\t%s\t%+.1f\t%s (%s)\n", s.computed.Round(time.Second), s.reference.Round(time.Second), s.relErrorPct, s.name, s.externalID) } @@ -162,10 +159,7 @@ func errorDistribution(absErrors []float64, percentiles []float64) map[float64]f sort.Float64s(sorted) distribution := map[float64]float64{} for _, p := range percentiles { - index := int(math.Ceil(p/100*float64(len(sorted))) - 1) - if index < 0 { - index = 0 - } + index := max(int(math.Ceil(p/100*float64(len(sorted)))-1), 0) if index >= len(sorted) { index = len(sorted) - 1 } |
