Skip to content

Commit

Permalink
Fix parameter colnames of merge (#478)
Browse files Browse the repository at this point in the history
* combine: fix merge colnames param

fix #475

* typo
  • Loading branch information
iblislin committed Jan 21, 2021
1 parent 31245f6 commit 3152612
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 3 additions & 2 deletions src/combine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ function merge(ta1::TimeArray{T,N,D}, ta2::TimeArray{T,M,D};

end

merge(x::TimeArray{T}, y::TimeArray{T}, z::TimeArray{T}, a::TimeArray{T}...; kw...) where {T} =
merge(merge(x, y; kw...), z, a...; kw...)
merge(x::TimeArray{T}, y::TimeArray{T}, z::TimeArray{T}, a::TimeArray{T}...;
colnames::Vector = Symbol[], kw...) where {T} =
rename!(merge(merge(x, y; kw...), z, a...; kw...), colnames)


# hcat ##########################
Expand Down
19 changes: 11 additions & 8 deletions test/combine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,20 @@ end
ba = tail(BA)

@testset "takes colnames kwarg correctly" begin
@test colnames(merge(cl, ohlc[:High, :Low], colnames=[:a, :b, :c])) == [:a, :b, :c]
@test colnames(merge(cl, op, colnames=[:a, :b])) == [:a, :b]
@test_throws ArgumentError merge(cl, op, colnames=[:a])
@test_throws ArgumentError merge(cl, op, colnames=[:a, :b, :c])
@test colnames(merge(cl, ohlc[:High, :Low], colnames = [:a, :b, :c])) == [:a, :b, :c]
@test colnames(merge(cl, op, colnames = [:a, :b])) == [:a, :b]
@test_throws ArgumentError merge(cl, op, colnames = [:a])
@test_throws ArgumentError merge(cl, op, colnames = [:a, :b, :c])

for mode [:inner, :left, :right, :outer]
@test colnames(merge(cl, ohlc[:High, :Low], method = mode, colnames=[:a, :b, :c])) == [:a, :b, :c]
@test colnames(merge(cl, op, method = mode, colnames=[:a, :b])) == [:a, :b]
@test_throws ArgumentError merge(cl, op, method = mode, colnames=[:a])
@test_throws ArgumentError merge(cl, op, method = mode, colnames=[:a, :b, :c])
@test colnames(merge(cl, ohlc[:High, :Low], method = mode, colnames = [:a, :b, :c])) == [:a, :b, :c]
@test colnames(merge(cl, op, method = mode, colnames = [:a, :b])) == [:a, :b]
@test_throws ArgumentError merge(cl, op, method = mode, colnames = [:a])
@test_throws ArgumentError merge(cl, op, method = mode, colnames = [:a, :b, :c])
end

# issue #475
@test colnames(merge(cl, cl, cl, colnames = [:a, :b, :c])) == [:a, :b, :c]
end

@testset "returns correct alignment with Dates and values" begin
Expand Down

0 comments on commit 3152612

Please sign in to comment.