Skip to content
Open
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
8 changes: 4 additions & 4 deletions ext/TimeVaryingInputs0DExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ function TimeVaryingInputs.TimeVaryingInput(
"LinearPeriodFillingInterpolation is not supported when the input data is 1D",
)
end

if eltype(times) <: ITime && eltype(times) isa UnionAll
times = [promote(times...)...]
end
if extrapolation_bc(method) isa PeriodicCalendar
if extrapolation_bc(method) isa PeriodicCalendar{Nothing}
if !isequispaced(
eltype(times) <: ITime ? [float.(promote(times...))...] : times,
)
if !isequispaced(eltype(times) <: ITime ? float.(times) : times)
error(
"PeriodicCalendar() boundary condition cannot be used because data is defined at non uniform intervals of time",
)
Expand Down
7 changes: 7 additions & 0 deletions test/time_varying_inputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ end
method = TimeVaryingInputs.LinearPeriodFillingInterpolation(),
)

# test promote when some input times do not contain an epoch
promotion_tvi = TimeVaryingInputs.TimeVaryingInput(
[ITime(0; epoch = DateTime(2010)), ITime(1)],
ys,
)
@test all(t -> t.epoch == DateTime(2010), promotion_tvi.times)

# Test PeriodicCalendar with non simple duration
@test_throws ErrorException TimeVaryingInputs.PeriodicCalendar(
Month(2),
Expand Down