# Gridded Interplation with NoInterp fails when specifying nodes

**URL:** <https://discourse.julialang.org/t/gridded-interplation-with-nointerp-fails-when-specifying-nodes/46756>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 17, 2020, 7:19am UTC](https://discourse.julialang.org/t/gridded-interplation-with-nointerp-fails-when-specifying-nodes/46756 "2020-09-17T07:19:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [September 17, 2020, 7:19am UTC](https://discourse.julialang.org/t/gridded-interplation-with-nointerp-fails-when-specifying-nodes/46756/1 "2020-09-17T07:19:35Z")

</div>

I have a function `f(z,k)` where I am trying to interpolate along k. Both `z` and `k` may be non-uniform. I do not want any interpolation along z. I am using `Interpolations.jl` and trying out the following:

```julia
julia> interpolate((1:2:9, 1:5), ones(5,5), (NoInterp(), Gridded(Linear())))
ERROR: for NoInterp knot vector should be Base.OneTo(5), got 1:2:9

```

I’m not sure what’s going on here, is it not possible to specify nodes alongside `NoInterp()`? This works as expected using any other interpolation specifier, eg.

```julia
julia> interpolate((1:2:9, 1:5), ones(5,5), (Gridded(Constant()), Gridded(Linear())))
5×5 interpolate((1:2:9,1:5), ::Array{Float64,2}, (Gridded(Constant()), Gridded(Linear()))) with element type Float64:
 1.0 1.0 1.0 1.0 1.0
 1.0 1.0 1.0 1.0 1.0
 1.0 1.0 1.0 1.0 1.0
 1.0 1.0 1.0 1.0 1.0
 1.0 1.0 1.0 1.0 1.0

```

---

<div class="post-metadata">

**Author:** ![ric.cioffi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ric.cioffi/32/18373_2.png) [@ric.cioffi](https://discourse.julialang.org/u/ric.cioffi)\
**Post date:** [September 17, 2020, 9:46pm UTC](https://discourse.julialang.org/t/gridded-interplation-with-nointerp-fails-when-specifying-nodes/46756/2 "2020-09-17T21:46:49Z")

</div>

From what I saw digging through Interpolations’ code I believe the reason is that `NoInterp` is not on grid, which means you can only specify a `UnitRange` as acceptable knots.  
Internally the code checks that `axes(ones(5,5))` is the same as the supplied knots. However, in this case `axes` returns an object of type `Base.OneTo(5) != 1:2:9`.

I’m not sure what is the rationale behind this but I can see two approaches to bypassing the problem:

1. Specify the knots along the first dimensions to be `1:5` as well (not sure if you actually need the spacing to be different than 1)
2. Define a new function that re-adjusts your indices and use that instead: `itp(x, y) = interpolate((1:5, 1:5), ones(5,5), (NoInterp(), Gridded(Linear())))(Int((1 + x)/2), y)`
