diff --git a/ext/TimeVaryingInputs0DExt.jl b/ext/TimeVaryingInputs0DExt.jl index 0788ebb7..ddc79f32 100644 --- a/ext/TimeVaryingInputs0DExt.jl +++ b/ext/TimeVaryingInputs0DExt.jl @@ -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", ) diff --git a/test/time_varying_inputs.jl b/test/time_varying_inputs.jl index c0e710be..10353a4e 100644 --- a/test/time_varying_inputs.jl +++ b/test/time_varying_inputs.jl @@ -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),