JuliaDynamics/ComplexityMeasures.jl

The function `lt` in `OrdinalPatternEncoding` isn't actually used

Offen

#378 geöffnet am 13.01.2024

 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Julia (19 Forks)auto 404
buggood first issue

Repository-Metriken

Stars
 (79 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

The OrdinalPatterns documentation string promises that the user can provide a comparator function (defaults to lt = isless) to determine how two elements of a state are deemed to be "equal" (useful to prevent bias when there are tied values).

This function lt gets stored in the encoding::OrdinalPatternEncoding field of the OrdinalPatterns struct. However, the function isn't actually used in encode. We did use it before, but after we transitioned to the formal encode/decode interface, we forgot to pass the argument on to the underlying sortperm! call.

The fix is easy. Here's the source code:

function encode(encoding::OrdinalPatternEncoding{m}, χ::AbstractVector) where {m}
    if m != length(χ)
        throw(ArgumentError("Permutation order and length of input must match!"))
    end
    perm = sortperm!(encoding.perm, χ)
    return permutation_to_integer(perm)
end

TODO:

  • Pass on lt to sortperm! when computing the permutation pattern.

Contributor Guide