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() p := plot.New()
pic := report.NewPic() pic := report.NewPic()
p.Title.Text = "D: " + fmt.Sprint(s.Dimens) + p.Title.Text = fmt.Sprintf("D: %d, G: %d, I: %d",
", G: " + fmt.Sprint(s.Generations) + s.Dimens,
", I: " + fmt.Sprint(s.Iterations) s.Generations,
s.Iterations,
)
// this is latex-rendered. // this is latex-rendered.
pic.Caption = strings.ReplaceAll(p.Title.Text, " ", "~") 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) log.Panic(err)
} }
filename := picsDir + filename := fmt.Sprintf("%s%s-%s-%s-%dD-%dG-%dI",
fPrefix + "-" + picsDir,
util.SanitiseFName(s.Algo) + "-" + fPrefix,
util.SanitiseFName(dim.BenchName) + "-" + util.SanitiseFName(s.Algo),
fmt.Sprint(s.Dimens) + "D-" + util.SanitiseFName(dim.BenchName),
fmt.Sprint(s.Generations) + "G-" + s.Dimens,
fmt.Sprint(len(dim.BenchResults)) + "I" s.Generations,
len(dim.BenchResults),
)
filenameMean := filename + util.SanitiseFName(" Mean") filenameMean := filename + util.SanitiseFName(" Mean")
// NEVER EVER ATTEMPT TO INITIALISE THIS WITH `pic`! // NEVER EVER ATTEMPT TO INITIALISE THIS WITH `pic`!
picMean := report.NewPic() picMean := report.NewPic()
meanTitle := "D: " + fmt.Sprint(s.Dimens) + ", G: " + meanTitle := fmt.Sprintf("D: %d, G: %d, I: %d",
fmt.Sprint(s.Generations) + ", I: " + fmt.Sprint(s.Iterations) s.Dimens,
s.Generations,
s.Iterations,
)
// this is latex-rendered. // this is latex-rendered.
picMean.Caption = "Mean - " + strings.ReplaceAll(meanTitle, " ", "~") 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) pMean := plotMeanVals(dim.MeanVals, meanTitle, s.Generations)
elapsed := time.Since(start) elapsed := time.Since(start)
info := "saving img to file: " + filename + "(-Mean)" + fExt + info := fmt.Sprintf("saving img to file: %s(-Mean)%s [generated in %s]",
" [generated in " + fmt.Sprint(elapsed) + "]" filename, fExt, elapsed,
)
if s.Algo == "Random Search" { if s.Algo == "Random Search" {
printRandomSearch(info) printRandomSearch(info)