Skip to content

Commit 22f5464

Browse files
committed
Adding more docs to transforms
1 parent 33fc054 commit 22f5464

File tree

6 files changed

+49
-5
lines changed

6 files changed

+49
-5
lines changed

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
build/
22
site/
3+
src/assets/*.png
4+
5+
#Temp to avoid to many changes

src/kernelmatrix.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,18 @@ function kerneldiagmatrix(
114114
end
115115
end
116116

117+
"""
118+
```
119+
kerneldiagmatrix!(K::AbstractVector,κ::Kernel, X::Matrix; obsdim::Int=2)
120+
```
121+
In place version of `kerneldiagmatrix`
122+
"""
117123
function kerneldiagmatrix!(
118-
K::AbstractVector{T₁},
119-
κ::Kernel{T},
120-
X::AbstractMatrix{T₂};
124+
K::AbstractVector,
125+
κ::Kernel,
126+
X::AbstractMatrix;
121127
obsdim::Int = defaultobs
122-
) where {T,T₁,T₂}
128+
)
123129
if length(K) != size(X,obsdim)
124130
throw(DimensionMismatch("Dimensions of the target array K $(size(K)) are not consistent with X $(size(X))"))
125131
end

src/transform/functiontransform.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
22
FunctionTransform
3-
3+
```
4+
f(x) = abs.(x)
5+
tr = FunctionTransform(f)
6+
```
47
Take a function `f` as an argument which is going to act on each vector individually.
58
Make sure that `f` is supposed to act on a vector by eventually using broadcasting
69
For example `f(x)=sin(x)` -> `f(x)=sin.(x)`

src/transform/lowranktransform.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""
2+
LowRankTransform
3+
```
4+
P = rand(10,5)
5+
tr = LowRankTransform(P)
6+
```
7+
Apply the low-rank projection realised by the matrix `P`
8+
The second dimension of `P` must match the number of features of the target.
9+
"""
110
struct LowRankTransform{T<:AbstractMatrix{<:Real}} <: Transform
211
proj::T
312
end

src/transform/scaletransform.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
"""
22
Scale Transform
3+
```
4+
l = 2.0
5+
tr = ScaleTransform(l)
6+
v = rand(3)
7+
tr = ScaleTransform(v)
8+
```
9+
Multiply every element of the matrix by `l` for a scalar
10+
Multiply every vector of observation by `v` element-wise for a vector
311
"""
412
struct ScaleTransform{T<:Union{Real,AbstractVector{<:Real}}} <: Transform
513
s::T

src/transform/transform.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ include("scaletransform.jl")
77
include("lowranktransform.jl")
88
include("functiontransform.jl")
99

10+
11+
"""
12+
ChainTransform
13+
```
14+
t1 = ScaleTransform()
15+
t2 = LowRankTransform(rand(3,4))
16+
ct = ChainTransform([t1,t2]) #t1 will be called first
17+
ct == t2∘t1
18+
```
19+
Chain a series of transform, here `t1` is called first
20+
"""
1021
struct ChainTransform <: Transform
1122
transforms::Vector{Transform}
1223
end
@@ -28,7 +39,11 @@ end
2839
Base.:(t₁::Transform,t₂::Transform) = ChainTransform([t₂,t₁])
2940
Base.:(t::Transform,tc::ChainTransform) = ChainTransform(vcat(tc.transforms,t))
3041
Base.:(tc::ChainTransform,t::Transform) = ChainTransform(vcat(t,tc.transforms))
42+
"""
43+
IdentityTransform
3144
45+
Return exactly the input
46+
"""
3247
struct IdentityTransform <: Transform end
3348

3449
transform(t::IdentityTransform,x::AbstractArray,obsdim::Int=defaultobs) = x

0 commit comments

Comments
 (0)