Skip to content

Commit 0efdbc8

Browse files
committed
change dispatch method
1 parent ed15fd6 commit 0efdbc8

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/OutputWriters/windowed_time_average.jl

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,16 @@ mutable struct AveragedSpecifiedTimes{S<:SpecifiedTimes, W} <: AbstractSchedule
110110
collecting :: Bool
111111
end
112112

113-
const VaryingWindowAveragedSpecifiedTimes = AveragedSpecifiedTimes{<:Vector}
113+
const VaryingWindowAveragedSpecifiedTimes = AveragedSpecifiedTimes{<:Any, <:Vector}
114114

115115
AveragedSpecifiedTimes(specified_times::SpecifiedTimes; window, stride=1) =
116116
AveragedSpecifiedTimes(specified_times, window, stride, false)
117117

118118
AveragedSpecifiedTimes(times; window, kw...) = AveragedSpecifiedTimes(times, window; kw...)
119119

120-
function determine_epsilon(eltype)
121-
if eltype <: AbstractFloat
122-
return eps(eltype)
123-
elseif eltype <: Period
124-
return Second(0)
125-
else
126-
return 0
127-
end
128-
end
120+
determine_epsilon(eltype) = 0
121+
determine_epsilon(::Type{T}) where T <: AbstractFloat = eps(T)
122+
determine_epsilon(::Period) = Second(0)
129123

130124
function AveragedSpecifiedTimes(times, window::Vector; kw...)
131125
length(window) == length(times) || throw(ArgumentError("When providing a vector of windows, its length $(length(window)) must match the number of specified times $(length(times))."))
@@ -152,7 +146,7 @@ function AveragedSpecifiedTimes(times, window::Union{<:Number, <:Period}; kw...)
152146
end
153147

154148
get_next_window(schedule::VaryingWindowAveragedSpecifiedTimes) = schedule.window[schedule.specified_times.previous_actuation + 1]
155-
get_next_window(schedule::AveragedSpecifiedTimes) = schedule.window
149+
get_next_window(schedule) = schedule.window
156150

157151
function (schedule::AveragedSpecifiedTimes)(model)
158152
time = model.clock.time

0 commit comments

Comments
 (0)