diff --git a/src/encoding_implementations/ordinal_pattern.jl b/src/encoding_implementations/ordinal_pattern.jl index 603a62e9..1c106413 100644 --- a/src/encoding_implementations/ordinal_pattern.jl +++ b/src/encoding_implementations/ordinal_pattern.jl @@ -68,7 +68,7 @@ function encode(encoding::OrdinalPatternEncoding{m}, χ::AbstractVector) where { if m != length(χ) throw(ArgumentError("Permutation order and length of input must match!")) end - perm = sortperm!(encoding.perm, χ) + perm = sortperm!(encoding.perm, χ; lt = encoding.lt) return permutation_to_integer(perm) end diff --git a/test/encodings/encodings/ordinal_pattern_encoding.jl b/test/encodings/encodings/ordinal_pattern_encoding.jl index c457f199..4df124d1 100644 --- a/test/encodings/encodings/ordinal_pattern_encoding.jl +++ b/test/encodings/encodings/ordinal_pattern_encoding.jl @@ -58,7 +58,7 @@ end @test missing_outcomes(OrdinalPatterns(; m, τ), x) == 0 end -@testset "Pretty printing" begin +@testset "Pretty printing" begin o = OrdinalPatterns{3}() @test occursin("OrdinalPatterns{3}", repr(o)) @test occursin("encoding = OrdinalPatternEncoding(perm = [0, 0, 0], lt = isless_rand), τ = 1", repr(o)) @@ -67,3 +67,12 @@ end s = "[OrdinalPatterns{3}(encoding = OrdinalPatternEncoding(perm = [0, 0, 0], lt = isless_rand), τ = 1), OrdinalPatterns{3}(encoding = OrdinalPatternEncoding(perm = [0, 0, 0], lt = isless_rand), τ = 1), OrdinalPatterns{3}(encoding = OrdinalPatternEncoding(perm = [0, 0, 0], lt = isless_rand), τ = 1)]" @test occursin(s, repr(os)) end + +@testset "usage of isless" begin + o = OrdinalPatternEncoding{2}() # random is less + res = [encode(o, [1,1]) for i in 1:1000] + @test unique(res) == [1, 2] + o = OrdinalPatternEncoding{2}(isless) # random is less + res = [encode(o, [1,1]) for i in 1:1000] + @test unique(res) == [1] +end