@@ -617,10 +617,6 @@ def interp(var, indexes_coords, method, **kwargs):
617617 for indexes_coords in decompose_interp (indexes_coords ):
618618 var = result
619619
620- # simple speed up for the local interpolation
621- if method in ["linear" , "nearest" ]:
622- var , indexes_coords = _localize (var , indexes_coords )
623-
624620 # target dimensions
625621 dims = list (indexes_coords )
626622 x , new_x = zip (* [indexes_coords [d ] for d in dims ])
@@ -691,21 +687,22 @@ def interp_func(var, x, new_x, method, kwargs):
691687 if is_duck_dask_array (var ):
692688 import dask .array as da
693689
694- nconst = var .ndim - len (x )
690+ ndim = var .ndim
691+ nconst = ndim - len (x )
695692
696- out_ind = list (range (nconst )) + list (range (var . ndim , var . ndim + new_x [0 ].ndim ))
693+ out_ind = list (range (nconst )) + list (range (ndim , ndim + new_x [0 ].ndim ))
697694
698695 # blockwise args format
699696 x_arginds = [[_x , (nconst + index ,)] for index , _x in enumerate (x )]
700697 x_arginds = [item for pair in x_arginds for item in pair ]
701698 new_x_arginds = [
702- [_x , [var . ndim + index for index in range (_x .ndim )]] for _x in new_x
699+ [_x , [ndim + index for index in range (_x .ndim )]] for _x in new_x
703700 ]
704701 new_x_arginds = [item for pair in new_x_arginds for item in pair ]
705702
706703 args = (
707704 var ,
708- range (var . ndim ),
705+ range (ndim ),
709706 * x_arginds ,
710707 * new_x_arginds ,
711708 )
@@ -717,7 +714,7 @@ def interp_func(var, x, new_x, method, kwargs):
717714 new_x = rechunked [1 + (len (rechunked ) - 1 ) // 2 :]
718715
719716 new_axes = {
720- var . ndim + i : new_x [0 ].chunks [i ]
717+ ndim + i : new_x [0 ].chunks [i ]
721718 if new_x [0 ].chunks is not None
722719 else new_x [0 ].shape [i ]
723720 for i in range (new_x [0 ].ndim )
@@ -743,6 +740,9 @@ def interp_func(var, x, new_x, method, kwargs):
743740 concatenate = True ,
744741 dtype = dtype ,
745742 new_axes = new_axes ,
743+ # TODO: uncomment when min dask version is > 2.15
744+ # meta=var._meta,
745+ align_arrays = False ,
746746 )
747747
748748 return _interpnd (var , x , new_x , func , kwargs )
0 commit comments