Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type declarations in te_embed (and likely other parts of the code) are too restrictive #347

Open
Datseris opened this issue Oct 3, 2023 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Datseris
Copy link
Member

Datseris commented Oct 3, 2023

I am working on using CausalityTools.jl on 32-bit climate data. I do not bother to convert data to 64 bit. I just noticed that out of the box te_embed doesn't work. I would speculate that this would happen in other parts of the library. Here is a MWE:

using CausalityTools
x = rand(Float32, 100)
y = rand(Float32, 100)
z = copy(y)
embedding = EmbeddingTE(; dS = 4, dT = 4, dC = 4)
independence_test = LocalPermutationTest(TEShannon(; embedding), FPVP(), nshuffles = 50)
independence(independence_test, x, y, z)

which gives on latest stable 2.9.1:

ERROR: MethodError: no method matching te_embed(::EmbeddingTE, ::Vector{Float64}, ::Vector{Float32}, ::Vector{Float32})

Closest candidates are:
  te_embed(::Any, ::Any, ::Any, ::EmbeddingTE)
   @ CausalityTools deprecated.jl:103
  te_embed(::EmbeddingTE, ::AbstractVector{T}, ::AbstractVector{T}) where T
   @ CausalityTools C:\Users\gd419\.julia\dev\CausalityTools\src\methods\infomeasures\transferentropy\utils.jl:146 
  te_embed(::EmbeddingTE, ::AbstractVector{T}, ::AbstractVector{T}, ::AbstractVector{T}) where T
   @ CausalityTools C:\Users\gd419\.julia\dev\CausalityTools\src\methods\infomeasures\transferentropy\utils.jl:184 
  ...

Stacktrace:
 [1] individual_marginals_te(::EmbeddingTE, ::Vector{Float64}, ::Vararg{AbstractVector})
   @ CausalityTools C:\Users\gd419\.julia\dev\CausalityTools\src\methods\infomeasures\transferentropy\transferentropy.jl:151
 [2] independence(::LocalPermutationTest{TEShannon{Shannon{Int64}, EmbeddingTE}, FPVP{Chebyshev, Chebyshev}, CausalityTools.NeighborCloseness, TaskLocalRNG}, ::Vector{Float64}, ::Vector{Float32}, ::Vector{Float32})
   @ CausalityTools C:\Users\gd419\.julia\dev\CausalityTools\src\independence_tests\local_permutation\transferentropy.jl:14
 [3] top-level scope
   @ c:\Users\gd419\OneDrive - University of Exeter\Projects\CloudControlingRTSA\_research\ccf_basic_te_analysis.jl:47
@Datseris Datseris added bug Something isn't working good first issue Good for newcomers labels Oct 3, 2023
@kahaaga
Copy link
Member

kahaaga commented Oct 3, 2023

Yep, te_embed(::EmbeddingTE, ::AbstractVector{T}, ::AbstractVector{T}) where T (and the conditional variant) requires that all input timeseries have the same element type. This shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants