Skip to content

Commit 7286dd5

Browse files
Adding vcat and tests (#349)
* Adding vcat and tests * Decoupling tests and swapping conditionals for dispatch * Patch bump * Version bump
1 parent b8ae35c commit 7286dd5

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
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.14"
3+
version = "0.10.15"
44

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

src/mokernels/moinput.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ end
7676

7777
Base.size(inp::IsotopicMOInputs) = (inp.out_dim * length(inp.x),)
7878

79+
function Base.vcat(x::MOInputIsotopicByFeatures, y::MOInputIsotopicByFeatures)
80+
x.out_dim == y.out_dim || throw(DimensionMismatch("out_dim mismatch"))
81+
return MOInputIsotopicByFeatures(vcat(x.x, y.x), x.out_dim)
82+
end
83+
84+
function Base.vcat(x::MOInputIsotopicByOutputs, y::MOInputIsotopicByOutputs)
85+
x.out_dim == y.out_dim || throw(DimensionMismatch("out_dim mismatch"))
86+
return MOInputIsotopicByOutputs(vcat(x.x, y.x), x.out_dim)
87+
end
88+
7989
"""
8090
MOInput(x::AbstractVector, out_dim::Integer)
8191

test/mokernels/moinput.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
type_2 = AbstractVector{Tuple{AbstractVector{Vector{Float64}},Int}}
55

66
@testset "isotopicbyoutputs" begin
7-
ibo = MOInput(x, 3)
7+
ibo = KernelFunctions.MOInputIsotopicByOutputs(x, 3)
8+
ibo2 = KernelFunctions.MOInputIsotopicByOutputs(x, 2)
89

9-
@test ibo == KernelFunctions.MOInputIsotopicByOutputs(x, 3)
10+
@test_throws DimensionMismatch vcat(ibo, ibo2)
1011

12+
@test ibo == MOInput(x, 3)
1113
@test isa(ibo, type_1) == true
1214
@test isa(ibo, type_2) == false
1315

@@ -18,6 +20,7 @@
1820
@test lastindex(ibo) == 12
1921
@test firstindex(ibo) == 1
2022
@test_throws BoundsError ibo[0]
23+
@test vcat(ibo, ibo) == MOInput(vcat(x, x), 3)
2124

2225
@test ibo[2] == (x[2], 1)
2326
@test ibo[5] == (x[1], 2)
@@ -30,14 +33,14 @@
3033

3134
@test isa(ibf, type_1) == true
3235
@test isa(ibf, type_2) == false
33-
3436
@test length(ibf) == 12
3537
@test size(ibf) == (12,)
3638
@test size(ibf, 1) == 12
3739
@test size(ibf, 2) == 1
3840
@test lastindex(ibf) == 12
3941
@test firstindex(ibf) == 1
4042
@test_throws BoundsError ibf[0]
43+
@test vcat(ibf, ibf) == KernelFunctions.MOInputIsotopicByFeatures(vcat(x, x), 3)
4144

4245
@test ibf[2] == (x[1], 2)
4346
@test ibf[5] == (x[2], 2)

0 commit comments

Comments
 (0)