# Gridded Interpolation using Interpolation.jl not working in VSCode (but working in regular Julia repl)

**URL:** <https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716>\
**Category:** General Usage\
**Tags:** bug, vscode, interpolations\
**Created:** [June 14, 2022, 12:49am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716 "2022-06-14T00:49:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpro](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpro](https://discourse.julialang.org/u/jpro)\
**Post date:** [June 14, 2022, 12:49am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/1 "2022-06-14T00:49:22Z")

</div>

Hi, I’d like to interpolate data from a 2d array in which the spacing is nonuniform. A is an 11x13 array that is imported from a .csv file, so below I just made it a random array of values (should be good enough while I’m debugging).

```julia
using Interpolations

alpha = [-20;-15;-10;-4;-1;0;1;4;10;15;20] #11x1 array nonuniform spacing
mach = [0.1;0.3;0.7;0.8;0.9;1.2;1.5;2.0;3.0;5.0;7.0;8.0;9.0] #13x1 array nonuniform spacing
A = rand(11, 13) #e.g. A[6, 1] should correspond to value with alpha = 0 and mach = 0.1

nodes = ([alpha], [mach])
interp = interpolate(nodes, A, Gridded(Linear()))
display(interp(0.25, 1.4))

```

This seems to me to follow the Gridded Interpolation example from [Interpolation algorithms · Interpolations.jl](http://juliamath.github.io/Interpolations.jl/latest/control/)  
however outputs the following error:

```julia
ERROR: MethodError: no method matching interpolate(::Tuple{Vector{Matrix{Int64}}, Vector{Matrix{Float64}}}, ::Matrix{Float64}, ::Gridded{Linear{Throw{OnGrid}}})
Closest candidates are:
  interpolate(::Any, ::Any, ::Any, ::Any, ::Any) at c:\Git\sep_dynamics_julia\scripts\relative_motion.jl:37
  interpolate(::Any, ::Any) at c:\Git\sep_dynamics_julia\scripts\relative_motion.jl:36

```

The first “closest candidate” seems to me to suggest that it is expecting a 5th input, so I changed interp to `interp = interpolate(nodes, A, Gridded(Linear()), Gridded(Linear()))` but that simply produces the same output.

I’m not sure where to go from here, any help would be much appreciated. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [June 14, 2022, 1:06am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/2 "2022-06-14T01:06:42Z")

</div>

You’re passing your knots as a tuple of vectors of vectors instead of a tuple of vectors.

```julia
julia> typeof(nodes)
Tuple{Vector{Vector{Int64}}, Vector{Vector{Float64}}}

julia> interp = interpolate((alpha, mach), A, Gridded(Linear()))
11×13 interpolate((::Vector{Int64},::Vector{Float64}), ::Matrix{Float64}, Gridded(Linear())) with element type Float64:
 0.279071 0.332534 0.287125 0.0237718 0.0798587 … 0.449468 0.662033 0.172981 0.93074 0.561894
 0.0788037 0.335184 0.0122311 0.27252 0.0515833 0.451489 0.102317 0.431503 0.113232 0.781979
 0.583828 0.617984 0.609332 0.149146 0.121515 0.769664 0.925578 0.538336 0.943607 0.84304
[...]

```

---

<div class="post-metadata">

**Author:** ![jpro](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpro](https://discourse.julialang.org/u/jpro)\
**Post date:** [June 14, 2022, 1:14am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/3 "2022-06-14T01:14:19Z")

</div>

Thanks for your reply. I see what you’re saying, so I changed my code to

```julia
using Interpolations

alpha = [-20;-15;-10;-4;-1;0;1;4;10;15;20] #11x1 array nonuniform spacing
mach = [0.1;0.3;0.7;0.8;0.9;1.2;1.5;2.0;3.0;5.0;7.0;8.0;9.0] #13x1 array nonuniform spacing
A = rand(11, 13) #e.g. A[6, 1] should correspond to value with alpha = 0 and mach = 0.1

nodes = (alpha, mach)
interp = interpolate(nodes, A, Gridded(Linear()))
display(interp(0.25, 1.4))

```

however, I’m still getting an error for a tuple of matrices.

```julia
ERROR: MethodError: no method matching interpolate(::Tuple{Matrix{Int64}, Matrix{Float64}}, ::Matrix{Float64}, ::Gridded{Linear{Throw{OnGrid}}})
Closest candidates are:
  interpolate(::Any, ::Any, ::Any, ::Any, ::Any) at c:\Git\sep_dynamics_julia\scripts\relative_motion.jl:37

```

and equivalently for a tuple of vectors if I instead do  
`interp = interpolate((alpha[:], mach[:]), A, Gridded(Linear()))`

```julia
ERROR: MethodError: no method matching interpolate(::Tuple{Vector{Int64}, Vector{Float64}}, ::Matrix{Float64}, ::Gridded{Linear{Throw{OnGrid}}})
Closest candidates are:
  interpolate(::Any, ::Any, ::Any, ::Any, ::Any) at c:\Git\sep_dynamics_julia\scripts\relative_motion.jl:37

```

---

<div class="post-metadata">

**Author:** ![jpro](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpro](https://discourse.julialang.org/u/jpro)\
**Post date:** [June 14, 2022, 1:26am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/4 "2022-06-14T01:26:06Z")

</div>

Edit: it works completely fine when I execute this in the Julia REPL. However, when I implement in VSCode I receive the errors.

It seems like this could be a bigger issue with my setup in VSCode. Any ideas as to the discrepancy are welcomed.

---

<div class="post-metadata">

**Author:** ![jpro](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpro](https://discourse.julialang.org/u/jpro)\
**Post date:** [June 14, 2022, 1:28am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/5 "2022-06-14T01:28:37Z")

</div>

Seems similar to this issue: [MethodError occur running under viscode-REPL but not under normal REPL · Issue #1404 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/issues/1404)

which seems to suggest I could be dealing with a Julia bug instead?

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [June 14, 2022, 2:18am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/6 "2022-06-14T02:18:53Z")

</div>

It’s possible that you’re dealing with a VSCode plugin bug, but that particular issue was fixed two years ago, so before troubleshooting further, you’ll want to first make sure that your VSCode plugins are up to date and try restarting the editor.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 14, 2022, 7:42am UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/7 "2022-06-14T07:42:02Z")

</div>

Can’t repro that issue. Are you on the latest version of the Julia extension?

---

<div class="post-metadata">

**Author:** ![jpro](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jpro](https://discourse.julialang.org/u/jpro)\
**Post date:** [June 14, 2022, 3:28pm UTC](https://discourse.julialang.org/t/gridded-interpolation-using-interpolation-jl-not-working-in-vscode-but-working-in-regular-julia-repl/82716/8 "2022-06-14T15:28:41Z")

</div>

Well restarting the editor worked! Thanks for all your input.
