JuliaDynamics/DelayEmbeddings.jl

Error with Dataset's hcat function

tom-plaa opened this issue · 8 comments

I tried to run the example at https://juliadynamics.github.io/DynamicalSystems.jl/latest/embedding/unified/ for the pecuzal embedding using a unidimensional timeseries I have.

This is the error message I get:

julia> Y, τ_vals, ts_vals, Ls, εs = pecuzal_embedding(test_series; τs = 0:Tmax , w = theiler, econ = true)
Initializing PECUZAL algorithm for univariate input...
Starting 1-th embedding cycle...
Starting 2-th embedding cycle...
Algorithm stopped due to increasing L-values. VALID embedding achieved ✓.
ERROR: The function body AST defined by this @generated function is not pure. This likely means it contains a closure, a comprehension or a generator.
Stacktrace:
 [1] Dataset(::SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}, ::Vararg{SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}})
   @ DelayEmbeddings ~/.julia/packages/DelayEmbeddings/DdOZb/src/dataset.jl:202
 [2] hcat_lagged_values(Y::Vector{Float64}, s::Vector{Float64}, τ::Int64)
   @ DelayEmbeddings ~/.julia/packages/DelayEmbeddings/DdOZb/src/utils.jl:147
 [3] pecuzal_embedding(s::Vector{Float64}; τs::UnitRange{Int64}, w::Int64, samplesize::Int64, K::Int64, KNN::Int64, L_threshold::Int64, α::Float64, p::Float64, max_cycles::Int64, econ::Bool, verbose::Bool)
   @ DelayEmbeddings ~/.julia/packages/DelayEmbeddings/DdOZb/src/unified_de/pecuzal.jl:127
 [4] top-level scope
   @ REPL[21]:1
 [5] top-level scope
   @ ~/.julia/packages/CUDA/Axzxe/src/initialization.jl:52

My package versions:

(@v1.7) pkg> st
      Status `~/.julia/environments/v1.7/Project.toml`
  [f20549b4] AlphaStableDistributions v1.1.3
  [a134a8b2] BlackBoxOptim v0.6.1
  [336ed68f] CSV v0.10.3
  [052768ef] CUDA v3.8.3
  [a93c6f00] DataFrames v1.3.2
  [2b5f629d] DiffEqBase v6.82.0
  [aae7a2af] DiffEqFlux v1.45.1
  [0c46a032] DifferentialEquations v7.1.0
  [31c24e10] Distributions v0.25.49
  [61744808] DynamicalSystems v1.8.3
  [587475ba] Flux v0.12.9
  [7073ff75] IJulia v1.23.2
  [2b0e0bc5] LanguageServer v4.1.1-DEV `/home/tomas/julia-langserver/LanguageServer.jl#master`
  [2fda8390] LsqFit v0.12.1
  [961ee093] ModelingToolkit v8.5.1
  [429524aa] Optim v1.6.2
  [91a5bcdd] Plots v1.26.0
  [e409e4f3] PoissonRandom v0.4.0
  [e6cf234a] RandomNumbers v1.5.3
  [276daf66] SpecialFunctions v1.8.4
  [99342f36] StateSpaceModels v0.6.1
  [90137ffa] StaticArrays v1.4.1
  [cf896787] SymbolServer v7.2.0
  [0c5d862f] Symbolics v4.3.0
  [ac1d9e8a] ThreadsX v0.1.9
  [9e3dc215] TimeSeries v0.23.0
  [f218859d] TimeseriesPrediction v0.7.0
  [ade2ca70] Dates
  [37e2e46d] LinearAlgebra
  [10745b16] Statistics

Additionally, this error also occurs just by copy and pasting the code in the example page.

CC @hkraemer have you encountered this before?

No, I didn't. I will check @tom-plaa and @Datseris .

Hey @tom-plaa , I can not reproduce the error. When I ran the examples from the docs it works just fine. I see that you run on DynamicalSystems v1.8.3. Would you mind updating this to the current version (or at least to v2.x) and try again? If the error still exists let me know. Cheers

Hey @hkraemer , thanks for checking.
The 1.8.3 version is the one currently being installed by the julia package manager for 1.7.2, so I imagine regular users might experience this as well. Before reporting this issue, I tried to force the package manager to update DynamicalSystems (or maybe just DelayEmbeddings) to v2 and I believe I got a critical error with the dependency on SpecialFunctions.
I will retry and report back.

The 1.8.3 version is the one currently being installed by the julia package manager for 1.7.2,

That is not true. You must have other dependencies pinned to older versions that prevents the correct install. On clean session you get versions v2+. We test this via continuous integration so I can guarantee that. You seem to already have found the issue: an older version of SpecialFunctions is holding everything back. This older version is likely demanded by another package you have installed.

Thanks @Datseris , I will try to confirm it. I haven't manually pinned anything, so I wasn't considering that possibility. I'll get back to you and close the issue if I manage to confirm it.

I found the culprit package: TimeseriesPrediction. It forces a bunch of older versions for many packages, including DynamicalSystems to 1.8.3.
The bug isn't reproducible with the latest version.
Thanks for the help @Datseris and @hkraemer .