Retire unused module and forecast compatibility exports
This commit is contained in:
@@ -47,7 +47,7 @@ type TimedValue struct {
|
||||
Time time.Time `json:"time"`
|
||||
}
|
||||
|
||||
const DefaultPrecipWindowProbabilityThreshold = 40
|
||||
const precipWindowProbabilityThreshold = 40
|
||||
|
||||
type Indicators struct {
|
||||
Snow bool `json:"snow,omitempty"`
|
||||
@@ -86,7 +86,7 @@ type PrecipitationWindow struct {
|
||||
}
|
||||
|
||||
func BuildPrecipTiming(periods []weatherdata.ForecastPeriod) PrecipTiming {
|
||||
return buildPrecipTimingWithThreshold(periods, DefaultPrecipWindowProbabilityThreshold)
|
||||
return buildPrecipTimingWithThreshold(periods, precipWindowProbabilityThreshold)
|
||||
}
|
||||
|
||||
func buildPrecipTimingWithThreshold(periods []weatherdata.ForecastPeriod, threshold float64) PrecipTiming {
|
||||
|
||||
@@ -484,8 +484,8 @@ func TestBuildPrecipTimingBuildsThresholdWindows(t *testing.T) {
|
||||
if timing.MaxPrecipitationProbability == nil || timing.MaxPrecipitationProbability.Value != 80 {
|
||||
t.Fatalf("MaxPrecipitationProbability = %#v, want 80", timing.MaxPrecipitationProbability)
|
||||
}
|
||||
if timing.ProbabilityThreshold != DefaultPrecipWindowProbabilityThreshold {
|
||||
t.Fatalf("ProbabilityThreshold = %v, want default threshold", timing.ProbabilityThreshold)
|
||||
if timing.ProbabilityThreshold != 40 {
|
||||
t.Fatalf("ProbabilityThreshold = %v, want 40", timing.ProbabilityThreshold)
|
||||
}
|
||||
if len(timing.PrecipitationWindows) != 2 {
|
||||
t.Fatalf("PrecipitationWindows length = %d, want 2: %#v", len(timing.PrecipitationWindows), timing.PrecipitationWindows)
|
||||
@@ -567,26 +567,14 @@ func TestBuildPrecipTimingHandlesDryForecast(t *testing.T) {
|
||||
if timing.FirstPrecipitation != nil || timing.LastPrecipitation != nil || len(timing.PrecipitationWindows) != 0 || timing.ThunderMentioned {
|
||||
t.Fatalf("dry timing = %#v, want no precip timing and no thunder", timing)
|
||||
}
|
||||
if timing.ProbabilityThreshold != DefaultPrecipWindowProbabilityThreshold {
|
||||
t.Fatalf("ProbabilityThreshold = %v, want default threshold", timing.ProbabilityThreshold)
|
||||
if timing.ProbabilityThreshold != 40 {
|
||||
t.Fatalf("ProbabilityThreshold = %v, want 40", timing.ProbabilityThreshold)
|
||||
}
|
||||
if timing.MaxPrecipitationProbability == nil || timing.MaxPrecipitationProbability.Value != 0 {
|
||||
t.Fatalf("dry max precip = %#v, want checked zero chance", timing.MaxPrecipitationProbability)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThresholdHelpers(t *testing.T) {
|
||||
if !DifferenceAtLeast(50, 56, 5) {
|
||||
t.Fatal("DifferenceAtLeast = false, want true")
|
||||
}
|
||||
if !CrossesAtOrAbove(29, 32, 32) {
|
||||
t.Fatal("CrossesAtOrAbove = false, want true")
|
||||
}
|
||||
if !CrossesBelow(35, 31, 32) {
|
||||
t.Fatal("CrossesBelow = false, want true")
|
||||
}
|
||||
}
|
||||
|
||||
func testBundle(location *time.Location) *weatherdata.Bundle {
|
||||
return &weatherdata.Bundle{
|
||||
Hourly: &weatherdata.ForecastRun{Periods: []weatherdata.ForecastPeriod{
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package forecast
|
||||
|
||||
func DifferenceAtLeast(previous float64, current float64, threshold float64) bool {
|
||||
return abs(current-previous) >= threshold
|
||||
}
|
||||
|
||||
func CrossesAtOrAbove(previous float64, current float64, threshold float64) bool {
|
||||
return previous < threshold && current >= threshold
|
||||
}
|
||||
|
||||
func CrossesBelow(previous float64, current float64, threshold float64) bool {
|
||||
return previous >= threshold && current < threshold
|
||||
}
|
||||
|
||||
func abs(value float64) float64 {
|
||||
if value < 0 {
|
||||
return -value
|
||||
}
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user