# Interpolations.jl: Saving the object

**URL:** <https://discourse.julialang.org/t/interpolations-jl-saving-the-object/26368>\
**Category:** General Usage\
**Tags:** package\
**Created:** [July 15, 2019, 3:27am UTC](https://discourse.julialang.org/t/interpolations-jl-saving-the-object/26368 "2019-07-15T03:27:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krenova](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@krenova](https://discourse.julialang.org/u/krenova)\
**Post date:** [July 15, 2019, 3:27am UTC](https://discourse.julialang.org/t/interpolations-jl-saving-the-object/26368/1 "2019-07-15T03:27:47Z")

</div>

Hi,

I’m using the Interpolations.jl package to approximate a dynamic programming value function and intend to save the interpolated approximation automatically upon completion of the algorithm with the JLD2 package.

I realized however that there are some errors or issues loading the saved Interpolation object be it through packages JLD2 or JLD. For example,

```julia
A_x1 = 1:.1:10
A_x2 = 1:.5:20
f(x1, x2) = log(x1+x2)
A = [f(x1,x2) for x1 in A_x1, x2 in A_x2]
itp = interpolate(A, BSpline(Cubic(Line(OnGrid()))))
sitp = Interpolations.scale(itp, A_x1, A_x2)
lala = 0.0

@save "./data_proc/data_proc_structural/test.jld2" sitp
@load "./data_proc/data_proc_structural/test.jld2" sitp

save("./data_proc/data_proc_structural/test2.jld", "stip", sitp)
tmp = load("./data_proc/data_proc_structural/test2.jld", "sitp")

```

Calling saved JLD2 object through the command `sitp` returns the following error

```julia
Error showing value of type ScaledInterpolation{Float64,2,getfield(JLD2.ReconstructedTypes, Symbol("##Interpolations.BSplineInterpolation{Float64,2,getfield(JLD2.ReconstructedTypes, Symbol("##OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}}#474")),BSpline{Cubic{Line{OnGrid}}},Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}#475")),BSpline{Cubic{Line{OnGrid}}},Tuple{StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}}}:
ERROR: MethodError: no method matching size(::getfield(JLD2.ReconstructedTypes, Symbol("##Interpolations.BSplineInterpolation{Float64,2,getfield(JLD2.ReconstructedTypes, Symbol("##OffsetArrays.OffsetArray{Float64,2,Array{Float64,2}}#474")),BSpline{Cubic{Line{OnGrid}}},Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}}#475")))
Closest candidates are:
  size(::BitArray{1}) at bitarray.jl:70
  size(::BitArray{1}, ::Any) at bitarray.jl:74
  size(::Core.Compiler.StmtRange) at show.jl:1561

```

Calling saved JLD object through the command `tmp["sitp"]` returns me this

```julia
ERROR: MethodError: no method matching getindex(::getfield(JLD, Symbol("##Interpolations.ScaledInterpolation{Core.Float64,2,Interpolations.BSplineInterpolation{Core.Float64,2,OffsetArrays.OffsetArray{Core.Float64,2,Core.Array{Core.Float64,2}},Interpolations.BSpline{Interpolations.Cubic{Interpolations.Line{Interpolations.OnGrid}}},Core.Tuple{Base.OneTo{Core.Int64},Base.OneTo{Core.Int64}}},Interpolations.BSpline{Interpolations.Cubic{Interpolations.Line{Interpolations.OnGrid}}},Core.Tuple{Base.StepRangeLen{Core.Float64,Base.TwicePrecision{Core.Float64},Base.TwicePrecision{Core.Float64}},Base.StepRangeLen{Core.Float64,Base.TwicePrecision{Core.Float64},Base.TwicePrecision{Core.Float64}}}}#464")), ::String)
Stacktrace:
 [1] top-level scope at none:0

```
