Skip to content

Commit 3d94c82

Browse files
committed
ENH: 1d interp does the expected thing when u is a vector
1 parent fcc8507 commit 3d94c82

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

interpolation/multilinear/mlinterp.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,21 @@ def {funname}(*args):
158158
return source
159159

160160
elif it.eval == 'cartesian':
161-
if it.d != 2:
162-
return None
163-
source = f"""
161+
if it.d==1:
162+
source = f"""
163+
from numpy import zeros
164+
def {funname}(*args):
165+
grid = {grid_s}
166+
C = args[{it.d}]
167+
points_x = args[2]
168+
N = points_x.shape[0]
169+
res = zeros(N)
170+
for n in range(N):
171+
res[n] = mlinterp(grid, C, (points_x[n],))
172+
return res
173+
"""
174+
elif it.d==2:
175+
source = f"""
164176
from numpy import zeros
165177
def {funname}(*args):
166178
grid = {grid_s}
@@ -175,6 +187,8 @@ def {funname}(*args):
175187
res[n,m] = mlinterp(grid, C, (points_x[n], points_y[m]))
176188
return res
177189
"""
190+
else:
191+
return None
178192
return source
179193

180194

@@ -186,7 +200,10 @@ def interp(*args):
186200
aa = args[0].types
187201

188202
it = detect_types(aa)
203+
if it.d==1 and it.eval=='point':
204+
it = itt(it.d, it.values, 'cartesian')
189205
source = make_mlinterp(it,'__mlinterp')
206+
print(source)
190207
import ast
191208
tree = ast.parse(source)
192209
code = compile(tree, "<string>", "exec")

0 commit comments

Comments
 (0)