Skip to content

Commit 84de3c6

Browse files
kaandocaldevmotion
andauthored
Added vcat for ColVecs/RowVecs (#291)
Co-authored-by: David Widmann <[email protected]>
1 parent fbfb242 commit 84de3c6

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "KernelFunctions"
22
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
3-
version = "0.10.4"
3+
version = "0.10.5"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/utils.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Base.getindex(D::ColVecs, i::CartesianIndex{1}) = view(D.X, :, i)
7676
Base.getindex(D::ColVecs, i) = ColVecs(view(D.X, :, i))
7777
Base.setindex!(D::ColVecs, v::AbstractVector, i) = setindex!(D.X, v, :, i)
7878

79+
Base.vcat(a::ColVecs, b::ColVecs) = ColVecs(hcat(a.X, b.X))
80+
7981
dim(x::ColVecs) = size(x.X, 1)
8082

8183
pairwise(d::PreMetric, x::ColVecs) = Distances.pairwise(d, x.X; dims=2)
@@ -144,6 +146,8 @@ Base.getindex(D::RowVecs, i::CartesianIndex{1}) = view(D.X, i, :)
144146
Base.getindex(D::RowVecs, i) = RowVecs(view(D.X, i, :))
145147
Base.setindex!(D::RowVecs, v::AbstractVector, i) = setindex!(D.X, v, i, :)
146148

149+
Base.vcat(a::RowVecs, b::RowVecs) = RowVecs(vcat(a.X, b.X))
150+
147151
dim(x::RowVecs) = size(x.X, 2)
148152

149153
pairwise(d::PreMetric, x::RowVecs) = Distances.pairwise(d, x.X; dims=1)

test/utils.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
pairwise(SqEuclidean(), X; dims=2)
3434
@test KernelFunctions.pairwise(SqEuclidean(), DX, DY)
3535
pairwise(SqEuclidean(), X, Y; dims=2)
36+
@test vcat(DX, DY) isa ColVecs
37+
@test vcat(DX, DY).X == hcat(X, Y)
3638
K = zeros(N, N)
3739
KernelFunctions.pairwise!(K, SqEuclidean(), DX)
3840
@test K pairwise(SqEuclidean(), X; dims=2)
@@ -72,6 +74,8 @@
7274
pairwise(SqEuclidean(), X; dims=1)
7375
@test KernelFunctions.pairwise(SqEuclidean(), DX, DY)
7476
pairwise(SqEuclidean(), X, Y; dims=1)
77+
@test vcat(DX, DY) isa RowVecs
78+
@test vcat(DX, DY).X == vcat(X, Y)
7579
K = zeros(D, D)
7680
KernelFunctions.pairwise!(K, SqEuclidean(), DX)
7781
@test K pairwise(SqEuclidean(), X; dims=1)

0 commit comments

Comments
 (0)