Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
artememelin committed Sep 10, 2024
1 parent 774092c commit bc61e0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,13 @@ julia> TimeArray{Float64,Float64}(TimeTickIter(5))
```
"""
function TimeArray(iter)
return TimeArray(map(item -> convert(TimeTick, item), iter))
t = map(item -> convert(TimeTick, item), iter)
return isempty(t) ? TimeArray{TimeLike,Any}() : TimeArray(t)
end

function TimeArray{T,V}(iter) where {T,V}
return TimeArray(map(item -> convert(TimeTick{T,V}, item), iter))
t = map(item -> convert(TimeTick{T,V}, item), iter)
return isempty(t) ? TimeArray{T,V}() : TimeArray{T,V}(t)
end

"""
Expand Down
4 changes: 4 additions & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ end
@test TimeArray{Time,Float64}(time_anything) == TimeArray{Time,Float64}(reverse(time_anything))

@test TimeArray{Int64,Float64}(value_anything) == TimeArray{Int64,Float64}(reverse(value_anything))

@test TimeArray([]) == TimeArray{TimeArrays.TimeLike,Any}([])

@test TimeArray{DateTime,Float64}([]) == TimeArray{DateTime,Float64}([])
end

@testset "Case №4: TimeArray from timestamps and values" begin
Expand Down

0 comments on commit bc61e0a

Please sign in to comment.