Commit 11e71620 authored by Sebastien Binet's avatar Sebastien Binet Committed by GitHub

plot: remove log func from package scope

Having a function named `log` is relatively annoying when one is
debugging, especially in conjunction with `goimports`:
adding `log.Fatalf("foo")` statements is confusing `goimports` as a
function with the name `log` is already defined.

Remove `func log` and directly move its checks inside `LogScaler.Normalize`.
parent 9f5dec10
......@@ -167,8 +167,11 @@ var _ Normalizer = LogScale{}
// Normalize returns the fractional logarithmic distance of
// x between min and max.
func (LogScale) Normalize(min, max, x float64) float64 {
logMin := log(min)
return (log(x) - logMin) / (log(max) - logMin)
if min <= 0 || max <= 0 || x <= 0 {
panic("Values must be greater than 0 for a log scale.")
}
logMin := math.Log(min)
return (math.Log(x) - logMin) / (math.Log(max) - logMin)
}
// InvertedScale can be used as the value of an Axis.Scale function to
......@@ -610,13 +613,6 @@ func tickLabelWidth(sty draw.TextStyle, ticks []Tick) vg.Length {
return maxWidth
}
func log(x float64) float64 {
if x <= 0 {
panic("Values must be greater than 0 for a log scale.")
}
return math.Log(x)
}
// formatFloatTick returns a g-formated string representation of v
// to the specified precision.
func formatFloatTick(v float64, prec int) string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment