go(plot): smarter string concat w/ fmt.Sprintf
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
surtur 2022-07-20 16:24:04 +02:00
parent 8efba25c19
commit 109ce82f3e
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -103,9 +103,11 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
p := plot.New()
pic := report.NewPic()
p.Title.Text = "D: " + fmt.Sprint(s.Dimens) +
", G: " + fmt.Sprint(s.Generations) +
", I: " + fmt.Sprint(s.Iterations)
p.Title.Text = fmt.Sprintf("D: %d, G: %d, I: %d",
s.Dimens,
s.Generations,
s.Iterations,
)
// this is latex-rendered.
pic.Caption = strings.ReplaceAll(p.Title.Text, " ", "~")
@ -165,19 +167,24 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
log.Panic(err)
}
filename := picsDir +
fPrefix + "-" +
util.SanitiseFName(s.Algo) + "-" +
util.SanitiseFName(dim.BenchName) + "-" +
fmt.Sprint(s.Dimens) + "D-" +
fmt.Sprint(s.Generations) + "G-" +
fmt.Sprint(len(dim.BenchResults)) + "I"
filename := fmt.Sprintf("%s%s-%s-%s-%dD-%dG-%dI",
picsDir,
fPrefix,
util.SanitiseFName(s.Algo),
util.SanitiseFName(dim.BenchName),
s.Dimens,
s.Generations,
len(dim.BenchResults),
)
filenameMean := filename + util.SanitiseFName(" Mean")
// NEVER EVER ATTEMPT TO INITIALISE THIS WITH `pic`!
picMean := report.NewPic()
meanTitle := "D: " + fmt.Sprint(s.Dimens) + ", G: " +
fmt.Sprint(s.Generations) + ", I: " + fmt.Sprint(s.Iterations)
meanTitle := fmt.Sprintf("D: %d, G: %d, I: %d",
s.Dimens,
s.Generations,
s.Iterations,
)
// this is latex-rendered.
picMean.Caption = "Mean - " + strings.ReplaceAll(meanTitle, " ", "~")
@ -190,8 +197,9 @@ func plotAllDims(algoStats []stats.Stats, fPrefix, fExt string, ch chan report.P
pMean := plotMeanVals(dim.MeanVals, meanTitle, s.Generations)
elapsed := time.Since(start)
info := "saving img to file: " + filename + "(-Mean)" + fExt +
" [generated in " + fmt.Sprint(elapsed) + "]"
info := fmt.Sprintf("saving img to file: %s(-Mean)%s [generated in %s]",
filename, fExt, elapsed,
)
if s.Algo == "Random Search" {
printRandomSearch(info)