Skip to content

Commit b5af459

Browse files
MOInput Type Stability (JuliaGaussianProcesses#465)
* Parametrise type of MOInput * Bump patch version * Formatting Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * MOInputByFeatures and fix up doctests * Add inference tests * Uncomment tests * Formatting Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Drop 1.3 CI * Change Zygote bound that we weren't checking Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent bda66f8 commit b5af459

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
matrix:
2323
version:
2424
- '1'
25-
- '1.3'
25+
- '1.6'
2626
- 'nightly'
2727
os:
2828
- ubuntu-latest

Project.toml

+1-1
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.40"
3+
version = "0.10.41"
44

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

src/mokernels/moinput.jl

+11-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
julia> x = [1, 2, 3];
88
99
julia> KernelFunctions.MOInputIsotopicByFeatures(x, 2)
10-
6-element KernelFunctions.MOInputIsotopicByFeatures{Int64, Vector{Int64}}:
10+
6-element KernelFunctions.MOInputIsotopicByFeatures{Int64, Vector{Int64}, Int64}:
1111
(1, 1)
1212
(1, 2)
1313
(2, 1)
@@ -24,9 +24,10 @@ The first `out_dim` elements represent all outputs for the first input, the seco
2424
2525
See [Inputs for Multiple Outputs](@ref) in the docs for more info.
2626
"""
27-
struct MOInputIsotopicByFeatures{S,T<:AbstractVector{S}} <: AbstractVector{Tuple{S,Int}}
27+
struct MOInputIsotopicByFeatures{S,T<:AbstractVector{S},Tout_dim<:Integer} <:
28+
AbstractVector{Tuple{S,Int}}
2829
x::T
29-
out_dim::Integer
30+
out_dim::Tout_dim
3031
end
3132

3233
"""
@@ -38,7 +39,7 @@ end
3839
julia> x = [1, 2, 3];
3940
4041
julia> KernelFunctions.MOInputIsotopicByOutputs(x, 2)
41-
6-element KernelFunctions.MOInputIsotopicByOutputs{Int64, Vector{Int64}}:
42+
6-element KernelFunctions.MOInputIsotopicByOutputs{Int64, Vector{Int64}, Int64}:
4243
(1, 1)
4344
(2, 1)
4445
(3, 1)
@@ -53,9 +54,10 @@ As shown above, an `MOInputIsotopicByOutputs` represents a vector of tuples.
5354
The first `length(x)` elements represent the inputs for the first output, the second
5455
`length(x)` elements represent the inputs for the second output, etc.
5556
"""
56-
struct MOInputIsotopicByOutputs{S,T<:AbstractVector{S}} <: AbstractVector{Tuple{S,Int}}
57+
struct MOInputIsotopicByOutputs{S,T<:AbstractVector{S},Tout_dim<:Integer} <:
58+
AbstractVector{Tuple{S,Int}}
5759
x::T
58-
out_dim::Integer
60+
out_dim::Tout_dim
5961
end
6062

6163
const IsotopicMOInputsUnion = Union{MOInputIsotopicByFeatures,MOInputIsotopicByOutputs}
@@ -96,7 +98,7 @@ A data type to accommodate modelling multi-dimensional output data.
9698
julia> x = [1, 2, 3];
9799
98100
julia> MOInput(x, 2)
99-
6-element KernelFunctions.MOInputIsotopicByOutputs{Int64, Vector{Int64}}:
101+
6-element KernelFunctions.MOInputIsotopicByOutputs{Int64, Vector{Int64}, Int64}:
100102
(1, 1)
101103
(2, 1)
102104
(3, 1)
@@ -136,7 +138,7 @@ julia> Y = [1.1 2.1 3.1; 1.2 2.2 3.2]
136138
julia> inputs, outputs = prepare_isotopic_multi_output_data(x, ColVecs(Y));
137139
138140
julia> inputs
139-
6-element KernelFunctions.MOInputIsotopicByFeatures{Float64, Vector{Float64}}:
141+
6-element KernelFunctions.MOInputIsotopicByFeatures{Float64, Vector{Float64}, Int64}:
140142
(1.0, 1)
141143
(1.0, 2)
142144
(2.0, 1)
@@ -184,7 +186,7 @@ julia> Y = [1.1 1.2; 2.1 2.2; 3.1 3.2]
184186
julia> inputs, outputs = prepare_isotopic_multi_output_data(x, RowVecs(Y));
185187
186188
julia> inputs
187-
6-element KernelFunctions.MOInputIsotopicByOutputs{Float64, Vector{Float64}}:
189+
6-element KernelFunctions.MOInputIsotopicByOutputs{Float64, Vector{Float64}, Int64}:
188190
(1.0, 1)
189191
(2.0, 1)
190192
(3.0, 1)

test/mokernels/moinput.jl

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@test ibo[5] == (x[1], 2)
2727
@test ibo[7] == (x[3], 2)
2828
@test all([(x_, i) for i in 1:3 for x_ in x] .== ibo)
29+
@inferred getindex(ibo, 1)
2930
end
3031

3132
@testset "isotopicbyfeatures" begin
@@ -46,6 +47,7 @@
4647
@test ibf[5] == (x[2], 2)
4748
@test ibf[7] == (x[3], 1)
4849
@test all([(x_, i) for x_ in x for i in 1:3] .== ibf)
50+
@inferred getindex(ibf, 1)
4951
end
5052

5153
@testset "prepare_isotopic_multi_output_data" begin

test/utils.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
@test back(ones(size(X)))[1].X == ones(size(X))
6464
end
6565

66-
if VERSION >= v"1.6"
66+
if VERSION >= v"1.7"
6767
@testset "Zygote type-inference" begin
6868
ctx = NoContext()
6969
x = ColVecs(randn(2, 4))

0 commit comments

Comments
 (0)