Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use math.Ln2 where possible #3383

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading