JuliaSpace / SatelliteToolbox.jl

A toolbox for satellite analysis written in julia language.
MIT License
248 stars 33 forks source link

Tests error with Interpolations v0.13.3 #58

Closed fgasdia closed 3 years ago

fgasdia commented 3 years ago

Tests of this package error with Interpolations v0.13.3 but pass with v0.13.2. The error message is:

Testing Running tests...
Function jb2008: Error During Test at C:\dev\SatelliteToolbox.jl\test\earth\atmospheric_models\jb2008\jb2008.jl:41
  Got exception outside of a @test
  MethodError: Cannot `convert` an object of type 
    Interpolations.GriddedInterpolation{Float64{},1,Float64{},Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}},Tuple{Array{Float64{},1}}} to an object of type 
    Interpolations.GriddedInterpolation{Float64{},1,Float64{},Interpolations.Gridded{Interpolations.Linear},Tuple{Array{Float64{},1}}}
  Closest candidates are:
    convert(::Type{T}, ::Factorization) where T<:AbstractArray at C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\factorization.jl:58
    convert(::Type{T}, ::T) where T<:AbstractArray at abstractarray.jl:14
    convert(::Type{T}, ::T) where T at essentials.jl:205
    ...
  Stacktrace:
    [1] SatelliteToolbox._DTCFILE_Structure(DstΔTc::Interpolations.GriddedInterpolation{Float64, 1, Float64, Interpolations.Gridded{Interpolations.Linear{Interpolations.Throw{Interpolations.OnGrid}}}, Tuple{Vector{Float64}}})
      @ SatelliteToolbox C:\dev\SatelliteToolbox.jl\src\earth\space_indices\dtcfile.jl:27
    [2] _parse_dtcfile(path::String)
      @ SatelliteToolbox C:\dev\SatelliteToolbox.jl\src\earth\space_indices\dtcfile.jl:167
    [3] _init_dtcfile(; force_download::Bool, local_path::String)
      @ SatelliteToolbox C:\dev\SatelliteToolbox.jl\src\earth\space_indices\dtcfile.jl:103
    [4] init_space_indices(; enabled_files::Vector{Symbol}, dtcfile_path::String, dtcfile_force_download::Bool, fluxtable_path::String, fluxtable_force_download::Bool, solfsmy_path::String, solfsmy_force_download::Bool, wdcfiles_dir::Nothing, wdcfiles_force_download::Bool, wdcfiles_oldest_year::Int64, wdcfiles_newest_year::Nothing)
      @ SatelliteToolbox C:\dev\SatelliteToolbox.jl\src\earth\space_indices\space_indices.jl:277

This can be triggered with init_space_indices(). Looking at the source code briefly it's probably the definition https://github.com/JuliaSpace/SatelliteToolbox.jl/blob/0100e74ab187622154de2bc7cc42ac20ad8d8d59/src/earth/space_indices/space_indices.jl#L17-L19

I wonder if there is a more general way to handle these Interpolations types while maintaining type stability here. After all, it shouldn't have broken on a patch version update of Interpolations.

ronisbr commented 3 years ago

Hi @fgasdia !

Thanks for pointing this out. It is something I want to fix a long time ago but I ended up forgetting. I have a solution, the problem is that it can slow down the precompilation at some points.

ronisbr commented 3 years ago

Correcting, I cannot make this because the structure is global and based on OptionalData.jl. If it is not fully defined, then we will have type instability. I will update to work with 0.13.3.