@@ -639,7 +639,7 @@ def interp(var, indexes_coords, method: InterpOptions, **kwargs):
639
639
var .transpose (* original_dims ).data , x , destination , method , kwargs
640
640
)
641
641
642
- result = Variable (new_dims , interped , attrs = var .attrs )
642
+ result = Variable (new_dims , interped , attrs = var .attrs , fastpath = True )
643
643
644
644
# dimension of the output array
645
645
out_dims : OrderedSet = OrderedSet ()
@@ -648,7 +648,8 @@ def interp(var, indexes_coords, method: InterpOptions, **kwargs):
648
648
out_dims .update (indexes_coords [d ][1 ].dims )
649
649
else :
650
650
out_dims .add (d )
651
- result = result .transpose (* out_dims )
651
+ if len (out_dims ) > 1 :
652
+ result = result .transpose (* out_dims )
652
653
return result
653
654
654
655
@@ -709,28 +710,24 @@ def interp_func(var, x, new_x, method: InterpOptions, kwargs):
709
710
]
710
711
new_x_arginds = [item for pair in new_x_arginds for item in pair ]
711
712
712
- args = (
713
- var ,
714
- range (ndim ),
715
- * x_arginds ,
716
- * new_x_arginds ,
717
- )
713
+ args = (var , range (ndim ), * x_arginds , * new_x_arginds )
718
714
719
715
_ , rechunked = chunkmanager .unify_chunks (* args )
720
716
721
717
args = tuple (elem for pair in zip (rechunked , args [1 ::2 ]) for elem in pair )
722
718
723
719
new_x = rechunked [1 + (len (rechunked ) - 1 ) // 2 :]
724
720
721
+ new_x0_chunks = new_x [0 ].chunks
722
+ new_x0_shape = new_x [0 ].shape
723
+ new_x0_chunks_is_not_none = new_x0_chunks is not None
725
724
new_axes = {
726
- ndim + i : new_x [0 ].chunks [i ]
727
- if new_x [0 ].chunks is not None
728
- else new_x [0 ].shape [i ]
725
+ ndim + i : new_x0_chunks [i ] if new_x0_chunks_is_not_none else new_x0_shape [i ]
729
726
for i in range (new_x [0 ].ndim )
730
727
}
731
728
732
729
# if useful, re-use localize for each chunk of new_x
733
- localize = (method in ["linear" , "nearest" ]) and ( new_x [ 0 ]. chunks is not None )
730
+ localize = (method in ["linear" , "nearest" ]) and new_x0_chunks_is_not_none
734
731
735
732
# scipy.interpolate.interp1d always forces to float.
736
733
# Use the same check for blockwise as well:
0 commit comments