@@ -1557,24 +1557,26 @@ def get_siblings(self, a):
1557
1557
1558
1558
1559
1559
def simple_linear_interpolation (a , steps ):
1560
- if steps == 1 :
1561
- return a
1562
-
1563
- steps = int (np .floor (steps ))
1564
- new_length = ((len (a ) - 1 ) * steps ) + 1
1565
- new_shape = list (a .shape )
1566
- new_shape [0 ] = new_length
1567
- result = np .zeros (new_shape , a .dtype )
1568
-
1569
- result [0 ] = a [0 ]
1570
- a0 = a [0 :- 1 ]
1571
- a1 = a [1 :]
1572
- delta = ((a1 - a0 ) / steps )
1573
- for i in range (1 , steps ):
1574
- result [i ::steps ] = delta * i + a0
1575
- result [steps ::steps ] = a1
1560
+ """
1561
+ Resample an array with ``steps - 1`` points between original point pairs.
1576
1562
1577
- return result
1563
+ Parameters
1564
+ ----------
1565
+ a : array, shape (n, ...)
1566
+ steps : int
1567
+
1568
+ Returns
1569
+ -------
1570
+ array, shape ``((n - 1) * steps + 1, ...)``
1571
+
1572
+ Along each column of *a*, ``(steps - 1)`` points are introduced between
1573
+ each original values; the values are linearly interpolated.
1574
+ """
1575
+ fps = a .reshape ((len (a ), - 1 ))
1576
+ xp = np .arange (len (a )) * steps
1577
+ x = np .arange ((len (a ) - 1 ) * steps + 1 )
1578
+ return (np .column_stack ([np .interp (x , xp , fp ) for fp in fps .T ])
1579
+ .reshape ((len (x ),) + a .shape [1 :]))
1578
1580
1579
1581
1580
1582
@deprecated ('2.1' , alternative = 'shutil.rmtree' )
0 commit comments