Skip to content

Commit

Permalink
Use math.Ln2 where possible (#3383)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored Sep 11, 2024
1 parent 6cf2941 commit a172154
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions utils/math/continuous_averager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"time"
)

var convertEToBase2 = math.Log(2)

type continuousAverager struct {
halflife float64
weightedSum float64
Expand All @@ -34,7 +32,7 @@ func NewAverager(
currentTime time.Time,
) Averager {
return &continuousAverager{
halflife: float64(halflife) / convertEToBase2,
halflife: float64(halflife) / math.Ln2,
weightedSum: initialPrediction,
normalizer: 1,
lastUpdated: currentTime,
Expand Down
4 changes: 1 addition & 3 deletions utils/math/meter/continuous_meter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
)

var (
convertEToBase2 = math.Log(2)

_ Factory = (*ContinuousFactory)(nil)
_ Meter = (*continuousMeter)(nil)
)
Expand All @@ -34,7 +32,7 @@ type continuousMeter struct {
// NewMeter returns a new Meter with the provided halflife
func NewMeter(halflife time.Duration) Meter {
return &continuousMeter{
halflife: float64(halflife) / convertEToBase2,
halflife: float64(halflife) / math.Ln2,
}
}

Expand Down

0 comments on commit a172154

Please sign in to comment.